Class: TimexDatalinkClient::NotebookAdapter
- Inherits:
-
Object
- Object
- TimexDatalinkClient::NotebookAdapter
- Defined in:
- lib/timex_datalink_client/notebook_adapter.rb
Constant Summary collapse
- BYTE_SLEEP_DEFAULT =
0.025
- PACKET_SLEEP_DEFAULT =
0.25
Instance Attribute Summary collapse
-
#byte_sleep ⇒ Object
Returns the value of attribute byte_sleep.
-
#packet_sleep ⇒ Object
Returns the value of attribute packet_sleep.
-
#serial_device ⇒ Object
Returns the value of attribute serial_device.
-
#verbose ⇒ Object
Returns the value of attribute verbose.
Instance Method Summary collapse
-
#initialize(serial_device:, byte_sleep: nil, packet_sleep: nil, verbose: false) ⇒ NotebookAdapter
constructor
Create a NotebookAdapter instance.
-
#write(packets) ⇒ void
Write packets of bytes to serial device.
Constructor Details
#initialize(serial_device:, byte_sleep: nil, packet_sleep: nil, verbose: false) ⇒ NotebookAdapter
Create a NotebookAdapter instance.
19 20 21 22 23 24 |
# File 'lib/timex_datalink_client/notebook_adapter.rb', line 19 def initialize(serial_device:, byte_sleep: nil, packet_sleep: nil, verbose: false) @serial_device = serial_device @byte_sleep = byte_sleep || BYTE_SLEEP_DEFAULT @packet_sleep = packet_sleep || PACKET_SLEEP_DEFAULT @verbose = verbose end |
Instance Attribute Details
#byte_sleep ⇒ Object
Returns the value of attribute byte_sleep.
10 11 12 |
# File 'lib/timex_datalink_client/notebook_adapter.rb', line 10 def byte_sleep @byte_sleep end |
#packet_sleep ⇒ Object
Returns the value of attribute packet_sleep.
10 11 12 |
# File 'lib/timex_datalink_client/notebook_adapter.rb', line 10 def packet_sleep @packet_sleep end |
#serial_device ⇒ Object
Returns the value of attribute serial_device.
10 11 12 |
# File 'lib/timex_datalink_client/notebook_adapter.rb', line 10 def serial_device @serial_device end |
#verbose ⇒ Object
Returns the value of attribute verbose.
10 11 12 |
# File 'lib/timex_datalink_client/notebook_adapter.rb', line 10 def verbose @verbose end |
Instance Method Details
#write(packets) ⇒ void
This method returns an undefined value.
Write packets of bytes to serial device.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/timex_datalink_client/notebook_adapter.rb', line 30 def write(packets) packets.each do |packet| packet.each do |byte| printf("%.2X ", byte) if verbose serial_port.write(byte.chr) sleep(byte_sleep) end sleep(packet_sleep) puts if verbose end end |