hybridgroup / rubyserial

FFI Ruby library for RS-232 serial port communication
https://rubygems.org/gems/rubyserial
Other
154 stars 27 forks source link

How can I send just bytes by rubyserial? #27

Closed asiniy closed 9 years ago

asiniy commented 9 years ago

IE:

require 'rubyserial'
serialport = Serial.new '/dev/ttyACM0', 9600
serialport.write(0xff) # => exception...
zankich commented 9 years ago

@asiniy the write method accepts a string so you can pack, http://ruby-doc.org/core-2.2.1/Array.html#method-i-pack, a single byte like this and that should do what you need

[0xff].pack('C')
asiniy commented 9 years ago

@zankich, thx!