Skip to content

Instantly share code, notes, and snippets.

@bantic
Created January 10, 2009 15:36
Show Gist options
  • Save bantic/45471 to your computer and use it in GitHub Desktop.
Save bantic/45471 to your computer and use it in GitHub Desktop.
irb(main):001:0> require 'serialport'
=> true
irb(main):002:0> port_str = "/dev/tty.usbserial-A6007bRb"
=> "/dev/tty.usbserial-A6007bRb"
irb(main):003:0> baud_rate = 2400
=> 2400
irb(main):004:0> data_bits=8
=> 8
irb(main):005:0> stop_bits=1
=> 1
irb(main):006:0> parity = SerialPort::NONE
=> 0
irb(main):007:0> sp = SerialPort.new(port_str, baud_rate, data_bits, stop_bits, parity)
=> #<SerialPort:0x39ad0>
irb(main):008:0> sp.putc("V") # ask for input
=> "V"
irb(main):009:0> while char = sp.readchar
irb(main):010:1> printf("%c",char)
irb(main):011:1> end
V
-6:
2(
1(;((
1.:*6"/(: 8E?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment