From e0c260b2f82396190d24901a3d72ae7f2e517669 Mon Sep 17 00:00:00 2001 From: Samwel Opiyo Date: Thu, 28 Feb 2019 05:12:28 +0300 Subject: [PATCH] Streamline scripts in Firmware/tools. New: * Add a requirements.txt to specify script dependencies. * Add import of pexpect and correct import of fdpexpect. --- Firmware/tools/README.md | 1 + Firmware/tools/atcommander.py | 3 ++- Firmware/tools/console.py | 3 ++- Firmware/tools/requirements.txt | 11 +++++++++++ Firmware/tools/rssi.py | 3 ++- Firmware/tools/set_speed.py | 3 ++- Firmware/tools/set_sreg.py | 3 ++- Firmware/tools/show_regs.py | 3 ++- Firmware/tools/show_rssi.py | 3 ++- Firmware/tools/update_mode.py | 3 ++- 10 files changed, 28 insertions(+), 8 deletions(-) create mode 100644 Firmware/tools/README.md create mode 100644 Firmware/tools/requirements.txt mode change 100644 => 100755 Firmware/tools/rssi.py diff --git a/Firmware/tools/README.md b/Firmware/tools/README.md new file mode 100644 index 00000000..b126dab8 --- /dev/null +++ b/Firmware/tools/README.md @@ -0,0 +1 @@ +To install script dependencies, run `pip install -r requirements.txt`. diff --git a/Firmware/tools/atcommander.py b/Firmware/tools/atcommander.py index c7d800c9..3ffbd23e 100755 --- a/Firmware/tools/atcommander.py +++ b/Firmware/tools/atcommander.py @@ -3,7 +3,8 @@ # Provide command line access to AT command set on radios # -import serial, sys, argparse, time, fdpexpect +import serial, sys, argparse, time, pexpect +from pexpect import fdpexpect class ATCommandSet(object): ''' Interface to the AT command set ''' diff --git a/Firmware/tools/console.py b/Firmware/tools/console.py index 2ccc89db..02131934 100755 --- a/Firmware/tools/console.py +++ b/Firmware/tools/console.py @@ -1,7 +1,8 @@ #!/usr/bin/env python # a trivial serial console -import serial, sys, optparse, fdpexpect +import serial, sys, optparse, pexpect +from pexpect import fdpexpect parser = optparse.OptionParser("console") parser.add_option("--baudrate", type='int', default=57600, help='baud rate') diff --git a/Firmware/tools/requirements.txt b/Firmware/tools/requirements.txt new file mode 100644 index 00000000..7b1fe68f --- /dev/null +++ b/Firmware/tools/requirements.txt @@ -0,0 +1,11 @@ +future==0.17.1 +iso8601==0.1.12 +lxml==4.3.1 +pexpect==4.6.0 +ptyprocess==0.6.0 +pycairo==1.18.0 +PyGObject==3.30.4 +pymavlink==2.3.4 +pyserial==3.4 +PyYAML==3.13 +serial==0.0.97 diff --git a/Firmware/tools/rssi.py b/Firmware/tools/rssi.py old mode 100644 new mode 100755 index 665381a0..069b93b8 --- a/Firmware/tools/rssi.py +++ b/Firmware/tools/rssi.py @@ -1,7 +1,8 @@ #!/usr/bin/env python # RSSI production test -import serial, sys, optparse, time, fdpexpect +import serial, sys, optparse, time, pexpect +from pexpect import fdpexpect parser = optparse.OptionParser("update_mode") parser.add_option("--baudrate", type='int', default=57600, help='baud rate') diff --git a/Firmware/tools/set_speed.py b/Firmware/tools/set_speed.py index 49076a2d..efaff21d 100755 --- a/Firmware/tools/set_speed.py +++ b/Firmware/tools/set_speed.py @@ -1,7 +1,8 @@ #!/usr/bin/env python # set air data rate -import serial, sys, optparse, time, fdpexpect +import serial, sys, optparse, time, pexpect +from pexpect import fdpexpect parser = optparse.OptionParser("set_speed") parser.add_option("--baudrate", type='int', default=57600, help='baud rate') diff --git a/Firmware/tools/set_sreg.py b/Firmware/tools/set_sreg.py index d9a41b6d..8d72d979 100755 --- a/Firmware/tools/set_sreg.py +++ b/Firmware/tools/set_sreg.py @@ -1,7 +1,8 @@ #!/usr/bin/env python # set air data rate -import serial, sys, optparse, time, fdpexpect +import serial, sys, optparse, time, pexpect +from pexpect import fdpexpect parser = optparse.OptionParser("set_speed") parser.add_option("--baudrate", type='int', default=57600, help='baud rate') diff --git a/Firmware/tools/show_regs.py b/Firmware/tools/show_regs.py index ccbbec8d..301c04cb 100755 --- a/Firmware/tools/show_regs.py +++ b/Firmware/tools/show_regs.py @@ -1,7 +1,8 @@ #!/usr/bin/env python # set air data rate -import serial, sys, optparse, time, fdpexpect +import serial, sys, optparse, time, pexpect +from pexpect import fdpexpect parser = optparse.OptionParser("show_regs") parser.add_option("--baudrate", type='int', default=57600, help='baud rate') diff --git a/Firmware/tools/show_rssi.py b/Firmware/tools/show_rssi.py index 2a5c29e4..0b8bec0a 100755 --- a/Firmware/tools/show_rssi.py +++ b/Firmware/tools/show_rssi.py @@ -1,7 +1,8 @@ #!/usr/bin/env python # set air data rate -import serial, sys, optparse, time, fdpexpect +import serial, sys, optparse, time, pexpect +from pexpect import fdpexpect parser = optparse.OptionParser("show_rssi") parser.add_option("--baudrate", type='int', default=57600, help='baud rate') diff --git a/Firmware/tools/update_mode.py b/Firmware/tools/update_mode.py index 9654e76d..fb03c3c6 100755 --- a/Firmware/tools/update_mode.py +++ b/Firmware/tools/update_mode.py @@ -1,7 +1,8 @@ #!/usr/bin/env python # put a HopeRF into update mode -import serial, sys, optparse, time, fdpexpect +import serial, sys, optparse, time, pexpect +from pexpect import fdpexpect parser = optparse.OptionParser("update_mode") parser.add_option("--baudrate", type='int', default=57600, help='baud rate')