mirror of
https://github.com/lowobservable/coax.git
synced 2026-03-04 02:36:48 +00:00
Implement READ_DATA
This commit is contained in:
@@ -213,9 +213,11 @@ def read_address_counter_lo(interface, **kwargs):
|
||||
|
||||
return _execute_read_command(interface, command_word, **kwargs)[0]
|
||||
|
||||
def read_data(interface):
|
||||
def read_data(interface, **kwargs):
|
||||
"""Execute a READ_DATA command."""
|
||||
raise NotImplementedError
|
||||
command_word = _pack_command_word(Command.READ_DATA)
|
||||
|
||||
return _execute_read_command(interface, command_word, **kwargs)
|
||||
|
||||
def read_multiple(interface):
|
||||
"""Execute a READ_MULTIPLE command."""
|
||||
|
||||
40
pycoax/examples/09_read_data.py
Executable file
40
pycoax/examples/09_read_data.py
Executable file
@@ -0,0 +1,40 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
import time
|
||||
from serial import Serial
|
||||
|
||||
sys.path.append('..')
|
||||
|
||||
from coax import Interface1, read_address_counter_hi, read_address_counter_lo, read_data, load_address_counter_hi, load_address_counter_lo, write_data
|
||||
|
||||
print('Opening serial port...')
|
||||
|
||||
with Serial('/dev/ttyUSB0', 115200) as serial:
|
||||
print('Sleeping to allow interface time to wake up...')
|
||||
|
||||
time.sleep(3)
|
||||
|
||||
interface = Interface1(serial)
|
||||
|
||||
print('Resetting interface...')
|
||||
|
||||
version = interface.reset()
|
||||
|
||||
print(f'Firmware version is {version}')
|
||||
|
||||
load_address_counter_hi(interface, 0)
|
||||
load_address_counter_lo(interface, 80)
|
||||
write_data(interface, bytes.fromhex('a7 84 8b 8b 8e 33 00 96 8e 91 8b 83 19'))
|
||||
|
||||
load_address_counter_hi(interface, 0)
|
||||
load_address_counter_lo(interface, 81)
|
||||
|
||||
print('READ_DATA...')
|
||||
|
||||
print(read_data(interface))
|
||||
|
||||
hi = read_address_counter_hi(interface)
|
||||
lo = read_address_counter_lo(interface)
|
||||
|
||||
print(f'hi = {hi}, lo = {lo}')
|
||||
Reference in New Issue
Block a user