mirror of
https://github.com/meshtastic/python.git
synced 2026-01-09 08:17:55 -05:00
add sanity prerelease tests
This commit is contained in:
2
.vscode/launch.json
vendored
2
.vscode/launch.json
vendored
@@ -18,7 +18,7 @@
|
||||
"request": "launch",
|
||||
"module": "meshtastic",
|
||||
"justMyCode": true,
|
||||
"args": ["--debug", "--info"]
|
||||
"args": ["--info"]
|
||||
},
|
||||
{
|
||||
"name": "meshtastic debug",
|
||||
|
||||
@@ -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
7
bin/prerelease-tests.sh
Executable 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"
|
||||
@@ -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"""
|
||||
|
||||
@@ -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
6
tests/hello_world.py
Normal 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()
|
||||
Reference in New Issue
Block a user