Hi all!
I am trying to find out, how should I work with the serialport
library. I have a 3G modem, ZTE MF637. I have a snippet of code to
test the library:
require ‘rubygems’
require ‘serialport’
sp = SerialPort.new(’/dev/ttyUSB2’,9600)
sp.write(“AT\r\n”)
sp.read_timeout = 2000
sp.read
I am trying it in two ways: as commands in irb and just as a script.
All commands go fine, but when I input “sp.read”, the output is empty:
wizard@archie:/tmp/ruby-serialport$ irb
ruby-1.8.7-p302 > require ‘rubygems’
=> true
ruby-1.8.7-p302 > require ‘serialport’
=> true
ruby-1.8.7-p302 > sp = SerialPort.new(’/dev/ttyUSB0’,9600)
=> #SerialPort:0xb76f39e0
ruby-1.8.7-p302 > sp.read_timeout = 200
=> 200
ruby-1.8.7-p302 > sp.write(“AT\r\n”)
=> 4
ruby-1.8.7-p302 > sp.read
=> “”
The modem is fine, I tried to connect to Internet over it, and it
works. I even read the logs of pppd, and I saw that init strings pass
fine. What can I do?
Thanks a lot.