Class: Pwnlib::Tubes::SerialTube
- Defined in:
- lib/pwnlib/tubes/serialtube.rb
Overview
Serial Connections
Constant Summary
Constants inherited from Tube
Instance Method Summary collapse
-
#close ⇒ Object
Closes the active connection.
-
#initialize(port = nil, baudrate: 115_200, convert_newlines: true, bytesize: 8, parity: :none) ⇒ SerialTube
constructor
Instantiate a SerialTube object.
Methods inherited from Tube
#gets, #interact, #puts, #recv, #recvall, #recvline, #recvn, #recvpred, #recvregex, #recvuntil, #send, #sendline, #unrecv
Constructor Details
#initialize(port = nil, baudrate: 115_200, convert_newlines: true, bytesize: 8, parity: :none) ⇒ SerialTube
Instantiate a Pwnlib::Tubes::SerialTube object.
29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/pwnlib/tubes/serialtube.rb', line 29 def initialize(port = nil, baudrate: 115_200, convert_newlines: true, bytesize: 8, parity: :none) super() # go hunting for a port port ||= Dir.glob('/dev/tty.usbserial*').first port ||= '/dev/ttyUSB0' @convert_newlines = convert_newlines @conn = Serial.new(port, baudrate, bytesize, parity) @serial_timer = Timer.new end |
Instance Method Details
#close ⇒ Object
Closes the active connection
44 45 46 47 |
# File 'lib/pwnlib/tubes/serialtube.rb', line 44 def close @conn.close if @conn && !@conn.closed? @conn = nil end |