add sanity prerelease tests

This commit is contained in:
Kevin Hester
2020-12-09 09:21:41 +08:00
parent 0662c2b2ac
commit 1f91f541ef
6 changed files with 21 additions and 2 deletions

2
.vscode/launch.json vendored
View File

@@ -18,7 +18,7 @@
"request": "launch",
"module": "meshtastic",
"justMyCode": true,
"args": ["--debug", "--info"]
"args": ["--info"]
},
{
"name": "meshtastic debug",

View File

@@ -16,6 +16,7 @@ then run the following python3 code:
import meshtastic
interface = meshtastic.SerialInterface() # By default will try to find a meshtastic device, otherwise provide a device path like /dev/ttyUSB0
interface.sendText("hello mesh") # or sendData to send binary data, see documentations for other options.
interface.close()
```
For the rough notes/implementation plan see [TODO](https://github.com/meshtastic/Meshtastic-python/blob/master/TODO.md).

7
bin/prerelease-tests.sh Executable file
View File

@@ -0,0 +1,7 @@
set -e
echo "Running (crude) prerelease tests to verify sanity"
python3 tests/hello_world.py
bin/run.sh --help
bin/run.sh --info
bin/run.sh --sendtext "Sanity complete"

View File

@@ -575,7 +575,8 @@ class StreamInterface(MeshInterface):
self._rxBuf = bytes() # empty
self._wantExit = False
self._rxThread = threading.Thread(target=self.__reader, args=(), daemon=True)
# FIXME, figure out why daemon=True causes reader thread to exit too early
self._rxThread = threading.Thread(target=self.__reader, args=())
MeshInterface.__init__(self, debugOut=debugOut, noProto=noProto)
@@ -595,6 +596,7 @@ class StreamInterface(MeshInterface):
time.sleep(0.1) # wait 100ms to give device time to start running
self._rxThread.start()
self._waitConnected()
def _disconnected(self):
"""We override the superclass implementation to close our port"""

View File

@@ -129,15 +129,18 @@ def onConnected(interface):
closeNow = False # Should we drop the connection after we finish?
try:
if args.settime:
closeNow = True
print("Setting device RTC time")
# can include lat/long/alt etc: latitude = 37.5, longitude = -122.1
interface.sendPosition()
if args.setowner:
closeNow = True
print(f"Setting device owner to {args.setowner}")
interface.setOwner(args.setowner)
if args.sendtext:
closeNow = True
print(f"Sending text message {args.sendtext} to {args.destOrAll}")
interface.sendText(args.sendtext, args.destOrAll,
wantAck=True, wantResponse=True)

6
tests/hello_world.py Normal file
View File

@@ -0,0 +1,6 @@
import meshtastic
import time
interface = meshtastic.SerialInterface() # By default will try to find a meshtastic device, otherwise provide a device path like /dev/ttyUSB0
interface.sendText("hello mesh")
interface.close()