Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Processing Waspmote data frames. #54

Open
GoogleCodeExporter opened this issue Apr 11, 2015 · 5 comments
Open

Processing Waspmote data frames. #54

GoogleCodeExporter opened this issue Apr 11, 2015 · 5 comments

Comments

@GoogleCodeExporter
Copy link

Hi, I've made some code lines to process data frame package and make a 
dictionary. Something like this:

{'sequence': '178', 'waspmote_id': 'WASPMOTE_XBEE', 'frame_type': 128, 
'num_fields': 2, 'sensors_data': [('STR', 'XBee frame'), ('BAT', '48')], 
'serial_id': '356907616', 'source_addr_long': '00-13-a2-00-40-ba-aa-f0'}

Do you think this is useful for your prooject? Would you like I commit it or 
would you like I put it here?


Original issue reported on code.google.com by [email protected] on 31 Jul 2014 at 5:48

@GoogleCodeExporter
Copy link
Author

Sorry, I refer to Libelium Waspmote data frame. I don't know if it is useful 
for you.

Original comment by [email protected] on 31 Jul 2014 at 5:58

@GoogleCodeExporter
Copy link
Author

My apologies for the delay getting back to you.

To make sure I understand - you have extended the python-xbee library to work 
with Waspmote devices?

I'm always interested in accepting contributions to the library. In order to 
accept a contribution, I will need to see:
 - Well-formed code
 - Unit tests demonstrating that the new code works
 - Documentation suitable for users

I'm happy to work with you to make it happen.

Original comment by [email protected] on 15 Aug 2014 at 12:42

  • Changed title: Processing Waspmote data frames.
  • Added labels: Type-Enhancement
  • Removed labels: Priority-Medium, Type-Defect

@GoogleCodeExporter
Copy link
Author

Hi!
We are using Digimesh from waspmote. Could you help me with receiving frames 
with waspmote format? It would be sweet, best regards!

Original comment by [email protected] on 6 Mar 2015 at 9:31

@GoogleCodeExporter
Copy link
Author

[deleted comment]

@GoogleCodeExporter
Copy link
Author

Hello, in my code I use this (for python3).

I create a zb object:

```python3
import serial
from xbee import ZigBee
import binascii
import re
from queue import Queue, Empty

self._zb = ZigBee(self._serial_port, escaped=True, 
callback=self._message_received)
_q_msg_rcv = Queue()
_df_re = 
re.compile(r"^b'<=>(?P<frame_type>\\x\d{2})(?P<num_fields>\\x\d{2})#(?P<serial_i
d>[^#]+)#(?P<waspmote_id>[^#]*)#(?P<sequence>[^#]*)#(?P<sensors_data>.*)'$")

It call _message_received function when data are received and puts the
message into a Queue object (_q_msg_rcv). To parse data frame I use regexp
(_df_re):

   def _message_received(self, data):
        """Process XBee messages by XBee API callback.

        :param data: Data received from ZB.
        :type data: dict
        :return: None
        """
        try:
            # If there are data and they are data frame type, we process.
            if data.get('rf_data') and self._df_re.match('{0}'.format(data['rf_data'])):
                df = self._df_re.match('{0}'.format(data['rf_data'])).groupdict()
                df['sensor_data'] = [tuple(e.split(':')) for e in re.findall(r"([^#]*)#", df['sensors_data'])]
                if df['sensors_data']:
                    del df['sensors_data']
                df['frame_type'] = int(df['frame_type'].replace('\\x', ''), 16)
                df['num_fields'] = int(df['num_fields'].replace('\\x', ''), 16)
                df['source_addr_long'] = re.sub(r'(\w\w)', r'\1-', str(binascii.b2a_hex(data['source_addr_long']))[2:-1])[:-1].lower()
                self._q_msg_rcv.put_nowait(df)
        except Exception as e:
            (my exception)

After I read the queue when I need and drop its elements.


Original comment by `[email protected]` on 7 Mar 2015 at 8:37

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant