mirror of
https://github.com/lowobservable/coax.git
synced 2026-01-12 00:43:00 +00:00
Add DFU tool
This commit is contained in:
parent
a855732f0c
commit
4b0376f0ec
@ -76,6 +76,16 @@ class SerialInterface(Interface):
|
||||
|
||||
return _unpack_receive_data(message[1:])
|
||||
|
||||
def enter_dfu_mode(self):
|
||||
message = bytes([0xf2])
|
||||
|
||||
self._write_message(message)
|
||||
|
||||
message = self._read_message()
|
||||
|
||||
if message[0] != 0x01:
|
||||
raise _convert_error(message)
|
||||
|
||||
def _calculate_timeout_milliseconds(self, timeout):
|
||||
milliseconds = 0
|
||||
|
||||
|
||||
0
pycoax/coax/tools/__init__.py
Normal file
0
pycoax/coax/tools/__init__.py
Normal file
21
pycoax/coax/tools/dfu.py
Normal file
21
pycoax/coax/tools/dfu.py
Normal file
@ -0,0 +1,21 @@
|
||||
import time
|
||||
import argparse
|
||||
from coax import open_serial_interface
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser()
|
||||
|
||||
parser.add_argument('serial_port', help='Serial port')
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
with open_serial_interface(args.serial_port) as interface:
|
||||
interface.enter_dfu_mode()
|
||||
|
||||
# Wait for the interface to restart in DFU mode.
|
||||
time.sleep(3)
|
||||
|
||||
print('Interface should now be in DFU mode...')
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
Loading…
x
Reference in New Issue
Block a user