python icon indicating copy to clipboard operation
python copied to clipboard

Timeout Error on rpi0 via serial

Open vogt31337 opened this issue 11 months ago • 6 comments

Hi,

I am trying to use the api on my rpi0, but even listing the nodes crashes (meshtastic --serial /dev/ttyUSB0 --nodes):

Traceback (most recent call last):
  File "/home/m/venv/bin/meshtastic", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/m/venv/lib/python3.11/site-packages/meshtastic/__main__.py", line 1988, in main
    common()
  File "/home/m/venv/lib/python3.11/site-packages/meshtastic/__main__.py", line 1242, in common
    client = meshtastic.serial_interface.SerialInterface(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/m/venv/lib/python3.11/site-packages/meshtastic/serial_interface.py", line 65, in __init__
    StreamInterface.__init__(
  File "/home/m/venv/lib/python3.11/site-packages/meshtastic/stream_interface.py", line 55, in __init__
    self.connect()
  File "/home/m/venv/lib/python3.11/site-packages/meshtastic/stream_interface.py", line 79, in connect
    self._waitConnected()
  File "/home/m/venv/lib/python3.11/site-packages/meshtastic/mesh_interface.py", line 1019, in _waitConnected
    raise MeshInterface.MeshInterfaceError(
meshtastic.mesh_interface.MeshInterface.MeshInterfaceError: Timed out waiting for connection completion

Running Rasbpian bookworm (Debian 12), installed meshtastic via apt-get And meshtastic 2.5.18.89ebafc Beta on a Heltec Wireless Stick Lite V3 Using client.meshtastic.org it runs fine on my developer PC...

BR

vogt31337 avatar Jan 27 '25 18:01 vogt31337

I am getting the same type of error but on Windows 11

PS C:\Users\user> meshtastic --version
2.5.11
PS C:\Users\user> meshtastic.exe --port COM5 --info
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\jsievert\AppData\Local\Programs\Python\Python312\Scripts\meshtastic.exe\__main__.py", line 7, in <module>
  File "C:\Users\jsievert\AppData\Local\Programs\Python\Python312\Lib\site-packages\meshtastic\__main__.py", line 1988, in main
    common()
  File "C:\Users\jsievert\AppData\Local\Programs\Python\Python312\Lib\site-packages\meshtastic\__main__.py", line 1242, in common
    client = meshtastic.serial_interface.SerialInterface(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\jsievert\AppData\Local\Programs\Python\Python312\Lib\site-packages\meshtastic\serial_interface.py", line 65, in __init__
    StreamInterface.__init__(
  File "C:\Users\jsievert\AppData\Local\Programs\Python\Python312\Lib\site-packages\meshtastic\stream_interface.py", line 55, in __init__
    self.connect()
  File "C:\Users\jsievert\AppData\Local\Programs\Python\Python312\Lib\site-packages\meshtastic\stream_interface.py", line 79, in connect
    self._waitConnected()
  File "C:\Users\jsievert\AppData\Local\Programs\Python\Python312\Lib\site-packages\meshtastic\mesh_interface.py", line 1020, in _waitConnected
    raise MeshInterface.MeshInterfaceError(
meshtastic.mesh_interface.MeshInterface.MeshInterfaceError: Timed out waiting for connection completion

putz612 avatar Feb 09 '25 03:02 putz612

I think the main problem is finding the start in the communication: It times out, since it does not find a valid start symbol. Probably resetting will help, but this seems like a bad solution since the modem looses all its partners...

vogt31337 avatar Mar 03 '25 17:03 vogt31337

One issue for me (at least on MacOS, but not on RPI) appears to be this block of code: https://github.com/meshtastic/python/blob/ed908fc4b63b95d7948e969127331696df665610/meshtastic/serial_interface.py#L51-L57 After I commented out that code the meshtastic cli worked with an old usb tty device on my mac.

If you want to use the meshtastic serial module rather than otg usb on your rpi0 you will need to make sure your serial port is setup for BAUD_115200 correctly (for example on an e290):

meshtastic --set serial.enabled true --set serial.rxd 44 --set serial.txd 43 --set serial.mode PROTO --set serial.echo 0 --set serial.baud BAUD_115200 --set serial.timeout 0

(note that if you just use the number 115200 the serial module will fall back to 38400, it needs to be BAUD_115200)

To setup the serial port on the RPI you need to run sudo raspi-config -> 'Interface Options' -> 'Serial Port' -> 'No Login Shell' -> 'Yes Enable' -> Reboot.

and then after installing pip and setting up a venv on the RPI used a command like ./venv/bin/meshtastic -s /dev/ttyS0 --infoto successfully interact with the API.

erikwilson avatar Mar 06 '25 10:03 erikwilson

Similar scenario here. Odd thing is, I have 3 identical setups. Only one of them behaves this way.

admin@eventheim:~ $ meshtastic --port /dev/ttyUSB0 --set lora.tx_power 20
Traceback (most recent call last):
  File "/home/admin/.local/bin/meshtastic", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/admin/.local/lib/python3.11/site-packages/meshtastic/__main__.py", line 2062, in main
    common()
  File "/home/admin/.local/lib/python3.11/site-packages/meshtastic/__main__.py", line 1261, in common
    client = meshtastic.serial_interface.SerialInterface(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/admin/.local/lib/python3.11/site-packages/meshtastic/serial_interface.py", line 74, in __init__
    StreamInterface.__init__(
  File "/home/admin/.local/lib/python3.11/site-packages/meshtastic/stream_interface.py", line 55, in __init__
    self.connect()
  File "/home/admin/.local/lib/python3.11/site-packages/meshtastic/stream_interface.py", line 79, in connect
    self._waitConnected()
  File "/home/admin/.local/lib/python3.11/site-packages/meshtastic/mesh_interface.py", line 1073, in _waitConnected
    raise MeshInterface.MeshInterfaceError(
meshtastic.mesh_interface.MeshInterface.MeshInterfaceError: Timed out waiting for connection completion

*Windows 11>SSH>RPI4>Heltec V3

Liberty-Chris avatar Apr 11 '25 04:04 Liberty-Chris

I had the same problem,The device is RAK4631:

C:\Users\10842>ver
Microsoft Windows [10.0.22631.5189]
C:\Users\10842>meshtastic --version
2.6.1
C:\Users\10842>meshtastic --port COM7 --info
Traceback (most recent call last):
  File "C:\Users\10842\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\10842\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Users\10842\AppData\Local\Programs\Python\Python310\Scripts\meshtastic.exe\__main__.py", line 7, in <module>
  File "C:\Users\10842\AppData\Local\Programs\Python\Python310\lib\site-packages\meshtastic\__main__.py", line 2062, in main
    common()
  File "C:\Users\10842\AppData\Local\Programs\Python\Python310\lib\site-packages\meshtastic\__main__.py", line 1261, in common
    client = meshtastic.serial_interface.SerialInterface(
  File "C:\Users\10842\AppData\Local\Programs\Python\Python310\lib\site-packages\meshtastic\serial_interface.py", line 74, in __init__
    StreamInterface.__init__(
  File "C:\Users\10842\AppData\Local\Programs\Python\Python310\lib\site-packages\meshtastic\stream_interface.py", line 55, in __init__
    self.connect()
  File "C:\Users\10842\AppData\Local\Programs\Python\Python310\lib\site-packages\meshtastic\stream_interface.py", line 79, in connect
    self._waitConnected()
  File "C:\Users\10842\AppData\Local\Programs\Python\Python310\lib\site-packages\meshtastic\mesh_interface.py", line 1073, in _waitConnected
    raise MeshInterface.MeshInterfaceError(
meshtastic.mesh_interface.MeshInterface.MeshInterfaceError: Timed out waiting for connection completion

jacob-l-s avatar Apr 16 '25 02:04 jacob-l-s

The solution (and discovery) in my case was I could not set the region on a newly flashed device from CLI. And without that set, I couldn't do anything. I had to Bluetooth into the module and use the mobile app to set the region. I made my own firmware after to speed up subsequent device setups.

I could not do these from serial until manually enabled over Bluetooth: meshtastic --port /dev/ttyUSB0 --set is_serial_enabled true meshtastic --port /dev/ttyUSB0 --set lora.region 1

Liberty-Chris avatar Apr 17 '25 17:04 Liberty-Chris