Post a new topicPost a reply Page 1 of 1   [ 8 posts ]
Author Message
 Post subject: Escape Characters
PostPosted: Mon May 21, 2012 1:22 pm 

Joined: Sun May 16, 2010 5:59 pm
Posts: 96
Hi

We are trying to parse the frames that arrive to meshlium, to rebuild them when they get fragmented, and to send commands to the waspmotes network . We found a problem that maybe you know the solution. When a frame arrives, we get the following:

Xbee Header:
Start: 0x7e
MSB: 0
LSB: 109
Length: 110
API ID: 0x80
Source Address:0x0 0x7d 0x33 0xa2 0x0 0x40 0x3d 0x6c 0x77
RSSI: 0x25
Options: 0x2

Libelium header:
App_ID: 0x52
Num_Fragment: 0x1
Fragments: 1
First fragment indicator: #
Source Type: 0x1
Source ID: 0x0 0x7d 0x33 0xa2 0x0 0x40 0x3d 0x6c 0x77
Data: $ Meteo07 # -46.12 # -19.90 # 0.36 # 0.00 # 0.00 # 89 # 0.00 # 482.81 # 157.50 # SSE # 47.22 # 1.136552 # 34.03

Source Address and Source ID are 9 bytes instead of 8, and it is because the byte 0x7d indicates that the next byte is "escaped" so it has made ​​an XOR operation between the real value and 0x20. How can we know what was the real value before the XOR? We need know the correct Source Address.

Thanks in advanced


Top
 Profile  
 
 Post subject: Re: Escape Characters
PostPosted: Tue May 22, 2012 11:41 am 

Joined: Mon Sep 28, 2009 1:06 pm
Posts: 7516
Hello alex,

Can you tell us, witch method you use to reveive data from Waspmote?

Best Regards


Top
 OnlineProfile  
 
 Post subject: Re: Escape Characters
PostPosted: Tue May 22, 2012 12:36 pm 

Joined: Sun May 16, 2010 5:59 pm
Posts: 96
We have developed a python program that reads the port (ttyS0) and parses the headers of incoming frames. Depending on the values ​​received, send a statement to the mote, but we must receive proper mac address. Orders can be open or close a relay or other type of actuator.


Top
 Profile  
 
 Post subject: Re: Escape Characters
PostPosted: Wed May 23, 2012 10:25 am 

Joined: Mon Sep 28, 2009 1:06 pm
Posts: 7516
Hello alex,

A suggestion, you can identify the Waspmote with a name instead of mac in the frame that you send. if this not interest you, change the structure of the frame sent and parse it otherwise.

Best Regards


Top
 OnlineProfile  
 
 Post subject: Re: Escape Characters: SOLVED
PostPosted: Wed May 23, 2012 10:44 am 

Joined: Sun May 16, 2010 5:59 pm
Posts: 96
I've solved with this small python code:
Code:
lista_escape=[0x7e,0x83,0x13,0x11]
      i=0
      while i <7:
         byte=hex (ord(s.read()))
         
         if (byte != '0x7d'):
             Dir_ORIG.append(byte)
             
             i=i+1
                   else:
           
           
           byte=hex(ord(s.read()))
           byte=int(byte,0)
           
           
           byte_escape=hex(byte^0x20)
           
           for x in range(0,len(lista_escape)):
                 
                  if  hex(lista_escape[x])== byte_escape:
                
                     Dir_ORIG.append(byte_escape)
      
      
       
      print "Direccion de origen: "+ str(Dir_ORIG)
      

Regards


Top
 Profile  
 
 Post subject: Re: Escape Characters
PostPosted: Wed May 23, 2012 2:59 pm 

Joined: Mon Sep 28, 2009 1:06 pm
Posts: 7516
Thanks alex,

It is a good example for other users.


Top
 OnlineProfile  
 
 Post subject: Re: Escape Characters
PostPosted: Wed May 23, 2012 4:35 pm 

Joined: Sun May 16, 2010 5:59 pm
Posts: 96
Could install SVN, Mercurial or other repository where users can access the API, and where we can make contributions relating to Waspmote and meshlium?


Top
 Profile  
 
 Post subject: Re: Escape Characters
PostPosted: Tue May 29, 2012 1:49 pm 

Joined: Mon Sep 28, 2009 1:06 pm
Posts: 7516
Dear alex,

This is a great suggestion. We have included that in the "wish list" from the clients, but we must say there are many things which are more urgent.

Best regards


Top
 OnlineProfile  
 
Display posts from previous:  Sort by  
Post a new topicPost a reply Page 1 of 1   [ 8 posts ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
cron


Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Libelium theme based on 610nm Style by Daniel St. Jules of http://www.gamexe.net


© Libelium Comunicaciones Distribuidas S.L. | Terms of use