Implement RESET

This commit is contained in:
Andrew Kay
2019-12-23 18:15:32 -06:00
parent ff2a2de575
commit 1d2b522e65
2 changed files with 32 additions and 2 deletions

View File

@@ -239,9 +239,11 @@ def read_multiple(interface, **kwargs):
return _execute_read_command(interface, command_word, 32,
validate_response_length=False, **kwargs)
def reset(interface):
def reset(interface, **kwargs):
"""Execute a RESET command."""
raise NotImplementedError
command_word = _pack_command_word(Command.RESET)
_execute_write_command(interface, command_word, **kwargs)
def load_control_register(interface, control, **kwargs):
"""Execute a LOAD_CONTROL_REGISTER command."""

28
pycoax/examples/11_reset.py Executable file
View File

@@ -0,0 +1,28 @@
#!/usr/bin/env python
import sys
import time
from serial import Serial
sys.path.append('..')
from coax import Interface1, reset
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}')
print('RESET...')
reset(interface)