Handling FromRadio, possibly corrupted?

Hi,
I’m trying the example from https://meshtastic.github.io/Meshtastic-python/meshtastic/index.html#meshtastic.MeshInterface
import meshtastic
from pubsub import pub

def onReceive(packet): # called when a packet arrives
    print(f"Received: {packet}")

def onConnection(): # called when we (re)connect to the radio
    # defaults to broadcast, specify a destination ID if you wish
    interface.sendText("hello mesh")

pub.subscribe(onReceive, "meshtastic.receive")
pub.subscribe(onConnection, "meshtastic.connection.established")
# By default will try to find a meshtastic device, otherwise provide a device path like /dev/ttyUSB0
interface = meshtastic.StreamInterface()

I’m on Windows 10 with https://www.aliexpress.com/item/4001178678568.html

and I receive this error:

ERROR:root:Error handling FromRadio, possibly corrupted? Some optional args unknown in call to sendMessage('('meshtastic', 'connection', 'established')', interface): interface
Traceback (most recent call last):
File "C:\Users\user\git\test\lib\site-packages\meshtastic\__init__.py", line 501, in __reader
self._handleFromRadio(self._rxBuf[HEADER_LEN:])
File "C:\Users\user\git\test\lib\site-packages\meshtastic\__init__.py", line 250, in _handleFromRadio
self._connected()
File "C:\Users\user\git\test\lib\site-packages\meshtastic\__init__.py", line 202, in _connected
pub.sendMessage("meshtastic.connection.established", interface=self)
File "C:\Users\user\git\test\lib\site-packages\pubsub\core\publisher.py", line 216, in sendMessage
topicObj.publish(**msgData)
File "C:\Users\user\git\test\lib\site-packages\pubsub\core\topicobj.py", line 433, in publish
self._getListenerSpec().check(msgData)
File "C:\Users\user\git\test\lib\site-packages\pubsub\core\topicargspec.py", line 229, in check
raise SenderUnknownMsgDataError(self.topicNameTuple,
pubsub.core.topicargspec.SenderUnknownMsgDataError: Some optional args unknown in call to sendMessage('('meshtastic', 'connection', 'established')', interface): interface
1 Like

Oops - I think that example is a bit stale. I’ll fix. In the meantime:

if you change onConnection & onReceive to the following:

def onConnection(interface, topic):

def onReceive(packet, interface):

I think you’ll be okay. Can you try that?

Hi Thank you for your help:
Code

import meshtastic
from pubsub import pub

def onReceive(packet, interface): # called when a packet arrives
    print(f"Received: {packet}")

def onConnection(interface, topic): # called when we (re)connect to the radio
    # defaults to broadcast, specify a destination ID if you wish
    interface.sendText("hello mesh")

pub.subscribe(onReceive, "meshtastic.receive")
pub.subscribe(onConnection, "meshtastic.connection.established")
# By default will try to find a meshtastic device, otherwise provide a device path like /dev/ttyUSB0
interface = meshtastic.StreamInterface()

and I receive this error:

ERROR:root:Error handling FromRadio, possibly corrupted? Some required args missing in call to sendMessage(‘meshtastic.connection.established’, interface): topic
Traceback (most recent call last):
File “C:\Users\user\git\test\lib\site-packages\meshtastic_init_.py”, line 501, in __reader
self._handleFromRadio(self.rxBuf[HEADER_LEN:])
File "C:\Users\user\git\test\lib\site-packages\meshtastic_init
.py", line 250, in _handleFromRadio
self.connected()
File "C:\Users\user\git\test\lib\site-packages\meshtastic_init
.py", line 202, in _connected
pub.sendMessage(“meshtastic.connection.established”, interface=self)
File “C:\Users\user\git\test\lib\site-packages\pubsub\core\publisher.py”, line 216, in sendMessage
topicObj.publish(**msgData)
File “C:\Users\user\git\test\lib\site-packages\pubsub\core\topicobj.py”, line 433, in publish
self._getListenerSpec().check(msgData)
File “C:\Users\user\git\test\lib\site-packages\pubsub\core\topicargspec.py”, line 222, in check
raise SenderMissingReqdMsgDataError(
pubsub.core.topicargspec.SenderMissingReqdMsgDataError: Some required args missing in call to sendMessage(‘meshtastic.connection.established’, interface): topic
ERROR:root:Node not found for fromId
Received: {‘from’: 862621965, ‘to’: 862621333, ‘decoded’: {‘user’: {‘id’: ‘!c44f336a910d’, ‘longName’: ‘Unknown 910d’, ‘shortName’: ‘?0D’, ‘macaddr’: ‘xE8zapEN’}}, ‘id’: 1323205705, ‘rxSnr’: 9.75, ‘hopLimit’: 3, ‘fromId’: None, ‘toId’: ‘!c44f336a8e95’}

doh! my memory was wrong. onConnection prototype must be:

def onConnection(interface, topic=pub.AUTO_TOPIC)

(I forgot that pubsub requires a default value for extra parameters)

I works, thank you for your help:
Code

import meshtastic
from pubsub import pub

def onReceive(packet, interface): # called when a packet arrives
    print(f"Received: {packet}")

def onConnection(interface, topic=pub.AUTO_TOPIC): # called when we (re)connect to the radio
    # defaults to broadcast, specify a destination ID if you wish
    interface.sendText("hello mesh")

pub.subscribe(onReceive, "meshtastic.receive")
pub.subscribe(onConnection, "meshtastic.connection.established")
# By default will try to find a meshtastic device, otherwise provide a device path like /dev/ttyUSB0
interface = meshtastic.StreamInterface()
1 Like

No:I receive nothing … from the second module (nothing is printed)

I Receive that after some minutes:
ERROR:root:Node not found for fromId
Received: {‘from’: 862621965, ‘to’: 4294967295, ‘decoded’: {‘position’: {}}, ‘id’: 1323205740, ‘rxSnr’: 11.5, ‘hopLimit’: 3, ‘fromId’: None, ‘toId’: ‘^all’}

I open a second Topic for the sender: I have error also

hmm - what version of the firmware is on the devices? (it is printed on the screen at power on, or you can run meshtastic --info to get it)

It is possible that I’ve accidentially made a non backward compatible change in the python lib and the firmware that ttgo is prepopulating is pretty old…

I upload the firmware today:
meshtastic --info
?? ? ??? ? ? ??? ?? ? ? ? ? ??? ?? ?? ? ?? ? ?? ? ?? ? ?? ? ??? ??? ? ??? ? ??? ??? ?? ??? ? ??? ? ? ??? ?? ? ?? ? ? ? ?? ??? ??? ?? ?? ?? ??? ? ?? ?? ?? ??? ?? ?? ? ??? ? ?? ? ? ??? ?? ?? ??? ?? ?? ?? ? ? ? ? ?? ??? ??? ?? ? ??? ??? ??? ? ? ? ??? ? ? ?? ? ? ? ? ??? ? ? ?? ? ? ? ??? ? ? ?? ? ? ? ? ?? ? ??? ? ? ?? ? ? ? ?? ??? ? ? ?? ? ? ? ??? ??? ? ? ?? ? ? ?? ? ??? ??? ? ? ?? ?? ? ? ? ? ??? ??? ?? ?? ?? ? ?? ? ??? ? ? ? ?? ? ? ? ? ? ??? ? ?? ? ? ?? ? ??? ? ? ? ?? ? ? ? ? ? ? ? ??? ? ?? ? ? ? ? ?? ? ??? ? ? ? ? ? ?? ? ??? ? ?? ? ? ? ?? ? ??? ? ? ? ? ? ? ? ??? ? ?? ? ??? ?? ? ?? ? ?? ?? ?? ? ? ? ? ? ?? ??? ? ??? ??? ?? ? ?? ??? ??? ? ??? ?? ? ?? ??? ? ? ? ? ? ?? ??? ?? ? ?? ??? ? ??? ?? ?? ? ? ? ? ??? ?? ??? ??? ? ?? ? ??? ? ? ??? ? ??? ? ?Emitting reboot packet for serial shell
booted, wake cause 0 (boot count 1), reset_reason=reset
I2C device found at address 0x3c
ssd1306 display found
done
Meshtastic swver=0.9.5, hwver=1.0-EU865
Setting random seed 2542763664
Total heap: 265492
Free heap: 238292
Total PSRAM: 4194252
Free PSRAM: 4194252
NVS: UsedEntries 68, FreeEntries 562, AllEntries 630
AXP192 not found
Turning on screen
Read RTC time as 0 (cur millis 101) valid=0
Connected to UBLOX GPS successfully
RadioConfig reset!
Installing AES128 key!
Initial packet id 2087468601, numPacketId 4294967295
Loading saved preferences
Loaded saved preferences version 11
Installing AES128 key!
NODENUM=0x336a8e95, dbsize=1
Starting meshradio init…
Set radio: name=Default, config=3, ch=0, power=17
RF95 init result 0
[D][esp32-hal-cpu.c:189] setCpuFrequencyMhz(): PLL: 320 / 4 = 80 Mhz, APB: 80000000 Hz
GPS fix type 0
Ignoring invalid GPS month=11, year=-1901, unixtime=-2040326656
New GPS pos lat=0.000000, lon=0.000000, alt=0, pdop=0.000000, heading=0.000000, sats=255
Sending position to mesh
Update DB node 0x336a8e95, rx_time=0
Node status update: 1 online, 1 total
showing standard frames
Providing time to mesh 0
Adding packet record (id=0x7c6c3e3c Fr0x95 To0xff, WantAck0, HopLim3 Payload:Position)
enqueuing for send (id=0x7c6c3e3c Fr0x95 To0xff, WantAck0, HopLim3 encrypted)
txGood=0,rxGood=0,rxBad=0
Screen: Started…
sending owner !c44f336a8e95/Unknown 8e95/?95
Update DB node 0x336a8e95, rx_time=0
old user !c44f336a8e95/Unknown 8e95/?95
updating changed=0 user !c44f336a8e95/Unknown 8e95/?95
Adding packet record (id=0x7c6c3e3d Fr0x95 To0xff, WantAck0, HopLim3 Payload:User)
enqueuing for send (id=0x7c6c3e3d Fr0x95 To0xff, WantAck0, HopLim3 encrypted)
txGood=0,rxGood=0,rxBad=0
Trigger powerFSM 9
Trigger powerFSM 11
Connected to radio
my_node_num: 862621333
has_gps: true
num_channels: 10
region: “1.0-EU865”
hw_model: “tbeam”
firmware_version: “0.9.5”
packet_id_bits: 32
current_packet_id: 2087468605
node_num_bits: 32
message_timeout_msec: 300000
min_app_version: 172

preferences {
  position_broadcast_secs: 900
  send_owner_interval: 4
  wait_bluetooth_secs: 120
  screen_on_secs: 300
  phone_timeout_secs: 900
  phone_sds_timeout_sec: 7200
  mesh_sds_timeout_secs: 7200
  sds_secs: 31536000
  ls_secs: 3600
}
channel_settings {
  modem_config: Bw125Cr48Sf4096
  psk: "\324\361\273: )\007Y\360\274\377\253\317Ni\277"
  name: "Default"
}

Nodes in mesh:
{'num': 862621333, 'user': {'id': '!c44f336a8e95', 'longName': 'Unknown 8e95', 'shortName': '?95', 'macaddr': 'xE8zao6V'}, 'position': {}}