Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.ruby > #3007 > unrolled thread

Let Ruby read the serial port

Started by"Superpelican X." <superpelican12@gmail.com>
First post2011-04-16 07:58 -0500
Last post2011-04-18 09:26 -0500
Articles 5 — 5 participants

Back to article view | Back to comp.lang.ruby


Contents

  Let Ruby read the serial port "Superpelican X." <superpelican12@gmail.com> - 2011-04-16 07:58 -0500
    Re: Let Ruby read the serial port Brian Candler <b.candler@pobox.com> - 2011-04-16 16:14 -0500
      Re: Let Ruby read the serial port andrew mcelroy <sophrinix@gmail.com> - 2011-04-16 16:38 -0500
    Re: Let Ruby read the serial port Josh Cheek <josh.cheek@gmail.com> - 2011-04-16 17:03 -0500
    Re: Let Ruby read the serial port Regis d'Aubarede <regis.aubarede@gmail.com> - 2011-04-18 09:26 -0500

#3007 — Let Ruby read the serial port

From"Superpelican X." <superpelican12@gmail.com>
Date2011-04-16 07:58 -0500
SubjectLet Ruby read the serial port
Message-ID<1c3018ffaf2482d637183ffea57c2d54@ruby-forum.com>
Hello everyone,

I would like to read a serial port. I'm going to connect want to connect
my Arduino Uno microcontroller board to the computer via USB. It acts as
a virtual serial port automatically. I can already read with the Arduino
IDE' s serialterminal.

Processing can also read a serialport from a Arduino.

But now I would like to let Ruby read the virtual serialport and save
the data in a variable. And then do a lots of stuff with it.

Is there a special library or gem for this? I already installed libusb
for ruby.

Greetings,

Superpelican

-- 
Posted via http://www.ruby-forum.com/.

[toc] | [next] | [standalone]


#3030

FromBrian Candler <b.candler@pobox.com>
Date2011-04-16 16:14 -0500
Message-ID<65b3e432a84a878dc9966d4e0e8477c9@ruby-forum.com>
In reply to#3007
Superpelican X. wrote in post #993185:
> Is there a special library or gem for this?

Which platform are you running under?

The ruby-serialport gem worked fine for me (under Linux) when I last 
tried it, although that was several years ago.

-- 
Posted via http://www.ruby-forum.com/.

[toc] | [prev] | [next] | [standalone]


#3034

Fromandrew mcelroy <sophrinix@gmail.com>
Date2011-04-16 16:38 -0500
Message-ID<BANLkTikeQFyk=K5_oBNrvVPEBGrXM1drfQ@mail.gmail.com>
In reply to#3030
On Sat, Apr 16, 2011 at 4:14 PM, Brian Candler <b.candler@pobox.com> wrote:
> Superpelican X. wrote in post #993185:
>> Is there a special library or gem for this?
>
> Which platform are you running under?
>
> The ruby-serialport gem worked fine for me (under Linux) when I last
> tried it, although that was several years ago.

Make sure you have the baud and port number correct.
It's an often overlooked part of connecting to serial.
https://github.com/tenderlove/ruby-serialport
This might help also.
It also supports windows as well as linux (and theoretically mac)

Andrew McElroy

>
> --
> Posted via http://www.ruby-forum.com/.
>
>

[toc] | [prev] | [next] | [standalone]


#3035

FromJosh Cheek <josh.cheek@gmail.com>
Date2011-04-16 17:03 -0500
Message-ID<BANLkTimexpTfhZ7qTMpV9SFSTF07jiGmmw@mail.gmail.com>
In reply to#3007
[Note:  parts of this message were removed to make it a legal post.]

Almost a year ago I used http://rubygems.org/gems/serialport successfully on
my Mac to talk to USB and Bluetooth Arduinos.

On Sat, Apr 16, 2011 at 7:58 AM, Superpelican X.
<superpelican12@gmail.com>wrote:

> Hello everyone,
>
> I would like to read a serial port. I'm going to connect want to connect
> my Arduino Uno microcontroller board to the computer via USB. It acts as
> a virtual serial port automatically. I can already read with the Arduino
> IDE' s serialterminal.
>
> Processing can also read a serialport from a Arduino.
>
> But now I would like to let Ruby read the virtual serialport and save
> the data in a variable. And then do a lots of stuff with it.
>
> Is there a special library or gem for this? I already installed libusb
> for ruby.
>
> Greetings,
>
> Superpelican
>
> --
> Posted via http://www.ruby-forum.com/.
>
>

[toc] | [prev] | [next] | [standalone]


#3102

FromRegis d'Aubarede <regis.aubarede@gmail.com>
Date2011-04-18 09:26 -0500
Message-ID<7f7e324059eb3bbe4eb5e07ceac63ea2@ruby-forum.com>
In reply to#3007
I use IronRuby  :

require "mscorlib"
require "System.Windows.Forms"



 def portConfigure(portName,bauds,bits,stop,parity)
    @components = System::ComponentModel::Container.new()
    @serialPort1 = System::IO::Ports::SerialPort.new(@components)
    portName ||= "COM3"
    bauds ||= "9600"
    bits ||= "8"
    stopBits ||= "1"
    parity ||= "none"
    #puts "Configure..."
    @serialPort1.DtrEnable = true
    @serialPort1.RtsEnable = true
    @serialPort1.PortName = portName
    @serialPort1.StopBits = stopBits.to_i
    @serialPort1.BaudRate = bauds.to_i
    @serialPort1.DataBits = bits.to_i
    @serialPort1.Open()
    @serialPort1.DataReceived do |sender, e|
       buff = @serialPort1.ReadExisting()
       scanner(buff)
    end
  end
  def writeString(str)
    buf = System::Text::Encoding.GetEncoding("ASCII").GetBytes(str)
    size = buf.Length
    @serialPort1.Write(buf, 0, size)
  end

-- 
Posted via http://www.ruby-forum.com/.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.ruby


csiph-web