Python API release notes

I have pySerial 3.4 on my Windows system, and I couldn’t get this to work. It looks like the defaults are supposed to be False for both of these settings(assuming you meant dsrdtr=False).

1 Like

hmm - I bet the person who posted about “timeout waiting for device” on connection might be seeing the same thing (assuming RTS is getting asserted by Windows when the port is opened, thus resetting the TBEAM).

Based on reading this pyserial bug:

@isinglass or @mc-hamster would you be willing to try the following on your machines? Replace the SerialInterface code as follows:

        # Note: we provide None for port here, because we will be opening it later
        self.stream = serial.Serial(
            None, 921600, exclusive=True, timeout=0.5, dsrdtr=False, rtscts=False)

        # rts=False Needed to prevent TBEAMs resetting on OSX, because rts is connected to reset
        self.stream.port = devPath

        self.stream.dtr = True
        self.stream.rts = False
        self.stream.open()

        StreamInterface.__init__(
            self, debugOut=debugOut, noProto=noProto, connectNow=connectNow)

    def _disconnected(self):
        """We override the superclass implementation to close our port"""

        StreamInterface._disconnected(self)

I’ll be able to do this in ~1hr when I come back from walking the dogs.

1 Like

when calling --info I get

Exception in thread Thread-1:
Traceback (most recent call last):
File “/usr/local/Cellar/python@3.9/3.9.0_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/threading.py”, line 950, in _bootstrap_inner
self.run()
File “/usr/local/Cellar/python@3.9/3.9.0_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/threading.py”, line 888, in run
self._target(*self._args, **self._kwargs)
File “/usr/local/lib/python3.9/site-packages/meshtastic/init.py”, line 690, in __reader
self._disconnected()
File “/usr/local/lib/python3.9/site-packages/meshtastic/init.py”, line 611, in _disconnected
self.stream.close()
File “/usr/local/lib/python3.9/site-packages/serial/serialposix.py”, line 533, in close
os.close(self.fd)
OSError: [Errno 9] Bad file descriptor

when --set ls_sec 301 I get

Traceback (most recent call last):
File “/usr/local/bin/meshtastic”, line 8, in
sys.exit(main())
File “/usr/local/lib/python3.9/site-packages/meshtastic/main.py”, line 407, in main
client = SerialInterface(
File “/usr/local/lib/python3.9/site-packages/meshtastic/init.py”, line 735, in init
StreamInterface._disconnected(self)
File “/usr/local/lib/python3.9/site-packages/meshtastic/init.py”, line 611, in _disconnected
self.stream.close()
File “/usr/local/lib/python3.9/site-packages/serial/serialposix.py”, line 533, in close
os.close(self.fd)
OSError: [Errno 9] Bad file descriptor

The file I modified

http://www.casler.org/temp/__init__.py.zip

1 Like

I think there is an indentation error in your override of _disconnected. The “def_disconnected” needs to be four characters to the left.

Seriously, who ever thought getting rid of curly braces was a good idea?

Nope, that change didn’t work.

jmcasler@Mac-mini meshtastic % meshtastic --port /dev/cu.SLAB_USBtoUART --info
Traceback (most recent call last):
File “/usr/local/bin/meshtastic”, line 8, in
sys.exit(main())
File “/usr/local/lib/python3.9/site-packages/meshtastic/main.py”, line 407, in main
client = SerialInterface(
File “/usr/local/lib/python3.9/site-packages/meshtastic/init.py”, line 729, in init
StreamInterface.init(
File “/usr/local/lib/python3.9/site-packages/meshtastic/init.py”, line 588, in init
self.connect()
File “/usr/local/lib/python3.9/site-packages/meshtastic/init.py”, line 603, in connect
self._waitConnected()
File “/usr/local/lib/python3.9/site-packages/meshtastic/init.py”, line 314, in _waitConnected
raise Exception(“Timed out waiting for connection completion”)
Exception: Timed out waiting for connection completion

^CException ignored in: <module ‘threading’ from ‘/usr/local/Cellar/python@3.9/3.9.0_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/threading.py’>
Traceback (most recent call last):
File “/usr/local/Cellar/python@3.9/3.9.0_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/threading.py”, line 1424, in _shutdown
lock.acquire()
KeyboardInterrupt:

File:

http://www.casler.org/temp/init.py-new.zip

1 Like

btw - it sounds like @isinglass might have the optimal fix: https://github.com/meshtastic/Meshtastic-python/issues/41

While working on the IP tunnel feature, I found a bug where we were corrupting the node table. So anyone using the python api should update to 1.1.26

Raspberry Pi OS “buster” complained about pytap2 missing, after installing it everything was fine again (1.1.27).

1 Like

1.1.44 released

This version fixes a problem that could cause the first sent packet (either from the API or the command line tool doing operations) to be discarded. Everyone should update.

2 Likes