1

I send "top" to the device through serailport,then read the top info
After that, I don't known how to stop the "top"!

require 'serialport'
port       = 2
args       ={"baud"=>57600, "data_bits"=>8,"stop_bits"=>1,"parity"=>SerialPort::NONE}
serial_obj = SerialPort.new(port, args)
serial_obj.read_timeout=1000
serial_obj.write("top\n")
print serial_obj.read
wuhlcom
  • 119
  • 1
  • 9

1 Answers1

0

You have to write the ETX character, which is "\x03". You may also be able to use Ruby's "control" escape sequences, such as "\cc" or "\C-c", as referenced here, but I haven't tried this myself.

Shotgun Ninja
  • 2,540
  • 3
  • 26
  • 32