I have a bash script that tests for WiFi connectivity with a device, then launches a series of meshtastic commands. For some reason connected to my device or my setup, it fails often. That's not the topic of this post. What concerns me is that the Python code reports success before the routine concludes. The success message needs to be at the very very end.
meshtastic --tcp $ATEIP --get security.publicKey --timeout $MTIMEOUT
echo "Assigned admin key: $MADMIN"
When these two commands run, here's what I get: the answer I wanted, the success message ("Completed getting preferences"), then fourteen lines of error before the next bash command executes.
Connected to radio
security.public_key: base64:OCTJspv5EzWOFZnfNp7Noy4vABl2O5sX6tvLjRRXVSo=
Completed getting preferences
ERROR file:tcp_interface.py _writeBytes line:106 Socket send error, reconnecting: [Errno 9] Bad file descriptor
ERROR file:stream_interface.py __reader line:221 Error while handling message from radio [Errno 9] Bad file descriptor
Traceback (most recent call last):
File "/home/rhadow/Documents/personal/ham/Meshtastic/meshtastic_env/lib/python3.12/site-packages/meshtastic/stream_interface.py", line 219, in __reader
self._handleFromRadio(self._rxBuf[HEADER_LEN:])
File "/home/rhadow/Documents/personal/ham/Meshtastic/meshtastic_env/lib/python3.12/site-packages/meshtastic/mesh_interface.py", line 1368, in _handleFromRadio
self._handleConfigComplete()
File "/home/rhadow/Documents/personal/ham/Meshtastic/meshtastic_env/lib/python3.12/site-packages/meshtastic/mesh_interface.py", line 1294, in _handleConfigComplete
self._connected() # Tell everyone else we are ready to go
^^^^^^^^^^^^^^^^^
File "/home/rhadow/Documents/personal/ham/Meshtastic/meshtastic_env/lib/python3.12/site-packages/meshtastic/mesh_interface.py", line 1190, in _connected
self._startHeartbeat()
File "/home/rhadow/Documents/personal/ham/Meshtastic/meshtastic_env/lib/python3.12/site-packages/meshtastic/mesh_interface.py", line 1181, in _startHeartbeat
callback() # run our periodic callback now, it will make another timer if necessary
^^^^^^^^^^
File "/home/rhadow/Documents/personal/ham/Meshtastic/meshtastic_env/lib/python3.12/site-packages/meshtastic/mesh_interface.py", line 1179, in callback
self.sendHeartbeat()
File "/home/rhadow/Documents/personal/ham/Meshtastic/meshtastic_env/lib/python3.12/site-packages/meshtastic/mesh_interface.py", line 1168, in sendHeartbeat
self._sendToRadio(p)
File "/home/rhadow/Documents/personal/ham/Meshtastic/meshtastic_env/lib/python3.12/site-packages/meshtastic/mesh_interface.py", line 1243, in _sendToRadio
self._sendToRadioImpl(toRadio)
File "/home/rhadow/Documents/personal/ham/Meshtastic/meshtastic_env/lib/python3.12/site-packages/meshtastic/stream_interface.py", line 137, in _sendToRadioImpl
self._writeBytes(header + b)
File "/home/rhadow/Documents/personal/ham/Meshtastic/meshtastic_env/lib/python3.12/site-packages/meshtastic/tcp_interface.py", line 104, in _writeBytes
self.socket.sendall(b)
OSError: [Errno 9] Bad file descriptor
Assigned admin key: base64:OCTJspv5EzWOFZnfNp7Noy4vABl2O5sX6tvLjRRXVSo=
Don't declare victory before the battle is won. When this code is next refactored, please move the success message to the end.
BB38.info.txt
BB38.support.txt
I have a bash script that tests for WiFi connectivity with a device, then launches a series of meshtastic commands. For some reason connected to my device or my setup, it fails often. That's not the topic of this post. What concerns me is that the Python code reports success before the routine concludes. The success message needs to be at the very very end.
When these two commands run, here's what I get: the answer I wanted, the success message ("Completed getting preferences"), then fourteen lines of error before the next bash command executes.
Don't declare victory before the battle is won. When this code is next refactored, please move the success message to the end.
BB38.info.txt
BB38.support.txt