Class: Meshtastic::StreamInterface
- Inherits:
-
Object
- Object
- Meshtastic::StreamInterface
- Defined in:
- lib/meshtastic/stream_interface.rb
Instance Attribute Summary collapse
-
#cur_log_line ⇒ Object
Returns the value of attribute cur_log_line.
-
#is_windows11 ⇒ Object
Returns the value of attribute is_windows11.
-
#rx_buf ⇒ Object
Returns the value of attribute rx_buf.
-
#stream ⇒ Object
Returns the value of attribute stream.
-
#want_exit ⇒ Object
Returns the value of attribute want_exit.
Instance Method Summary collapse
-
#authors ⇒ Object
- Author(s)
-
0day Inc.
-
#connect(opts = {}) ⇒ Object
- Supported Method Parameters
-
packet_id = Meshtastic.generate_packet_id( last_packet_id: ‘optional - Last Packet ID (Default: 0)’ ).
-
#help ⇒ Object
Display Usage for this Module.
-
#initialize(opts = {}) ⇒ StreamInterface
constructor
A new instance of StreamInterface.
-
#reader ⇒ Object
- Supported Method Parameters
-
Meshtastic::StreamInterface.reader.
Constructor Details
#initialize(opts = {}) ⇒ StreamInterface
Returns a new instance of StreamInterface.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/meshtastic/stream_interface.rb', line 14 def initialize(opts = {}) debug_out = opts[:debug_out] no_proto = false if opts[:no_proto].nil? no_proto = true if opts[:no_proto] connect_now = true if opts[:connect_now].nil? connect_now = false if opts[:connect_now] no_nodes = false if opts[:no_nodes].nil? no_nodes = true if opts[:no_nodes] # Note: In Ruby, we don't need to explicitly define a type hint for self. raise Exception("StreamInterface is now abstract (to update existing code create SerialInterface instead)") if !defined?(@stream) && !no_proto @stream = nil @rx_buf = [] @want_exit = false @is_windows11 = RUBY_PLATFORM =~ /win32/ @cur_log_line = "" # Note: Ruby's threading API is different from Python. We use the Thread class instead of threading.Thread. rx_thread = Thread.new do reader end if connect_now connect unless no_proto wait_for_config end end rescue StandardError => e raise e end |
Instance Attribute Details
#cur_log_line ⇒ Object
Returns the value of attribute cur_log_line.
8 9 10 |
# File 'lib/meshtastic/stream_interface.rb', line 8 def cur_log_line @cur_log_line end |
#is_windows11 ⇒ Object
Returns the value of attribute is_windows11.
8 9 10 |
# File 'lib/meshtastic/stream_interface.rb', line 8 def is_windows11 @is_windows11 end |
#rx_buf ⇒ Object
Returns the value of attribute rx_buf.
8 9 10 |
# File 'lib/meshtastic/stream_interface.rb', line 8 def rx_buf @rx_buf end |
#stream ⇒ Object
Returns the value of attribute stream.
8 9 10 |
# File 'lib/meshtastic/stream_interface.rb', line 8 def stream @stream end |
#want_exit ⇒ Object
Returns the value of attribute want_exit.
8 9 10 |
# File 'lib/meshtastic/stream_interface.rb', line 8 def want_exit @want_exit end |
Instance Method Details
#authors ⇒ Object
- Author(s)
-
0day Inc. <[email protected]>
76 77 78 79 80 |
# File 'lib/meshtastic/stream_interface.rb', line 76 def "AUTHOR(S): 0day Inc. <[email protected]> " end |
#connect(opts = {}) ⇒ Object
- Supported Method Parameters
-
packet_id = Meshtastic.generate_packet_id(
last_packet_id: 'optional - Last Packet ID (Default: 0)')
52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/meshtastic/stream_interface.rb', line 52 def connect(opts = {}) # Send some bogus UART characters to force a sleeping device to wake, and # if the reading statemachine was parsing a bad packet make sure we write enough start bytes to force it to resync (we don't use START1 because we want to ensure it is looking for START1) p = [START2] * 32 self._write_bytes(p) sleep(0.1) # wait 100ms to give device time to start running @rx_thread.start mui = Meshtastic::MeshInfoUser.new mui.start_config rescue StandardError => e raise e end |
#help ⇒ Object
Display Usage for this Module
84 85 86 87 88 89 90 |
# File 'lib/meshtastic/stream_interface.rb', line 84 def help puts "USAGE: #{self}.connect #{self}.authors " end |
#reader ⇒ Object
- Supported Method Parameters
-
Meshtastic::StreamInterface.reader
69 70 71 72 |
# File 'lib/meshtastic/stream_interface.rb', line 69 def reader rescue StandardError => e raise e end |