sockets bites

hi

i was fooling around with http://www.digi.com/wiki/developer/index.php/TCP_to_Zigbee_Dynamic_Name_Mapping example.
funny thing, socket connection is biting off some data.

there is this line: data = client_sock.recv(MAX_TCP_PACKET_SIZE)

data packet is in form of ‘NAME:DATA’, if i push ‘USB:123456789’, each time DATA part received is different: ‘1’, ‘12345’, ‘123456’. and there is '’ char at the begining for special purpose, the first byte is bitten of too. sending ‘USB:…’ receives ‘SB’.

why is that?

I wonder if this is occurring because MAX_ZIG_PACKET_SIZE is set incorrectly. Which protocol are you trying to run this app on? 802.15.4? ZB? Have you modified the value of 100 which is listed on that page?

Hi simakas,

When you say the DATA part is receieved, you mean from the XBee device? So the TCP data received by this application is received in parts by the remote XBee node?

Could you please capture a trace of the XBee traffic while reproducing this problem? To setup a trace, open a separate command line session to the device, and send the command ‘set trace mask=mesh:* state=on’, then start the python script and reproduce the problem.

Max

hi,

  • its a ZB
  • MAX_TCP_PACKET_SIZE = 8192, in client_sock this value is used, not 100 i guess.
  • MAX_ZIG_PACKET_SIZE = 100
  • i send DATA from PC telnet session to GW X4. by ‘DATA part’ i mean data received by GW.
  • i set trace, but not sure what to look for. first char is always bitten anyway, for the DATA part - 1…7 bytes are guaranteed, others are usually bitten off. before restart i wasn’t able to send even 2 bytes.

How are you sending the data to the application? I’m using a TCP socket through python, and it’s not truncating the data or name.

Could you post your table.py? There is a line of code that strips out whitespace characters, but I think you’d be getting ERROR: messages in return.

If you haven’t edited the MAX_ZIG_PACKET_SIZE constant, you will be having truncation errors or message too long exceptions when going beyond that number. In this case, the script auto detects the radio hardware type and uses that to determine its ZNet2.5, which in this case is incorrect, and should be ZB. Instead of setting the MAX_ZIG_PACKET_SIZE to 72, it should be 84.

Otherwise, I didn’t experience any issues of truncation sending or receiving.

i’m using windows telnet app. might be this is the problem.

no errors seen. table.py is a dictionary data file.

no exceptions concerning data length either.

Simon

I wouldn’t recommend using telnet, it does special character behavior and options that changes how incoming data is interpreted.

I was using a python TCP socket like this:

from socket import *
s = socket(AF_INET, SOCK_STREAM)
s.connect((‘10.9.109.34’, 20000))
s.send(‘USB:123456789123456789’)

its working! its working! i’ll cut using telnet from now on.