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/.
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/\.
Almost a year ago I used serialport | RubyGems.org | your community gem host 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/\.
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/.
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.
This might help also.
It also supports windows as well as linux (and theoretically mac)
Andrew McElroy
···
On Sat, Apr 16, 2011 at 4:14 PM, Brian Candler <b.candler@pobox.com> wrote:
--
Posted via http://www.ruby-forum.com/\.