diff --git a/pycoax/coax/protocol.py b/pycoax/coax/protocol.py index 942db04..7ee7902 100644 --- a/pycoax/coax/protocol.py +++ b/pycoax/coax/protocol.py @@ -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.""" diff --git a/pycoax/examples/11_reset.py b/pycoax/examples/11_reset.py new file mode 100755 index 0000000..82a5e7c --- /dev/null +++ b/pycoax/examples/11_reset.py @@ -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)