lhemmen / python-xbee

Automatically exported from code.google.com/p/python-xbee
MIT License
0 stars 0 forks source link

Provide helpful error message when an XBee may be unexpectedly in command mode #18

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. using the Tx16Request(0x0000, payload, sizeof(payload));
2. and XBeeAddress64(0x0013a200, 0x4055cbfa);

What is the expected output? What do you see instead?
A new xbee packet
RAW Hex Dump for Tx16 Request:
 7E 00 34 01 01 FF FF 00 30 34 31 35 41 46 43 31 46 42 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 B2

Got:
Traceback (most recent call last):
  File "test.py", line 15, in <module>
    response = xbee.wait_read_frame()
  File "/usr/local/lib/python2.6/dist-packages/xbee/base.py", line 381, in wait_read_frame
    return self._split_response(frame.data)
  File "/usr/local/lib/python2.6/dist-packages/xbee/base.py", line 213, in _split_response
    % data[0])
KeyError: 'Unrecognized response packet with id byte \x01'

What version of the product are you using? On what operating system?
2.0 on both win and linuxfor python-xbee

2.7 python on win 
2.6 python on linux

Original issue reported on code.google.com by jasonlig...@gmail.com on 21 May 2011 at 1:36

GoogleCodeExporter commented 9 years ago
Hi Jason,

Could you explain to me what your hardware setup is? 

The reason you're receiving this error is because the python-xbee is receiving 
a TX request frame. This is unexpected; in normal operation, python-xbee would 
send this type of packet to an XBee device, and would receive an RX packet (of 
ID 0x80 or 0x81) from an XBee when the XBee receives data over the air.

Original comment by pmalms...@gmail.com on 21 May 2011 at 1:59

GoogleCodeExporter commented 9 years ago
Arduino Uno with the XBee Shield (http://www.sparkfun.com/products/9976)

PC Side XBee Explorer USB. http://www.sparkfun.com/products/8687

I am new to the xbee world so I am lost in the API....

Original comment by jasonlig...@gmail.com on 21 May 2011 at 2:04

GoogleCodeExporter commented 9 years ago
somehow one of my xbee lost its api setting :-(  

what about a hook that can tell user to check to make user the xbee is in api 
mode.

Original comment by jasonlig...@gmail.com on 21 May 2011 at 2:08

GoogleCodeExporter commented 9 years ago
Yeah, the API is a little verbose. For more information about it, take a look 
at the XBee documentation, the Product Manual in particular: 
http://www.digi.com/products/wireless-wired-embedded-solutions/zigbee-rf-modules
/point-multipoint-rfmodules/xbee-series1-module.jsp#docs. I attached it to this 
comment. All the information you need is under the API Operation section. For 
info about how to use python-xbee, look at the documentation posted here and 
some of the examples.

Now, about your setup. When you start your Arduino after downloading a program, 
make sure that the Arduino USB cable is not connected to your computer. The 
Arduino will send serial data to its XBee over the same wires, so your computer 
will also hear that chatter if its plugged in.

Next, make sure that your Python program uses the serial port attached to your 
XBee Explorer USB.

Finally, if you haven't done so already, grab the X-CTU program at the link 
listed above (Windows only unfortunately); it makes XBee configuration a 
breeze. Also, use this program to update the firmware on both of your XBee 
devices; Out of date firmware might behave unexpectedly. See the product manual 
for more information about this stuff.

Original comment by pmalms...@gmail.com on 21 May 2011 at 2:18

Attachments:

GoogleCodeExporter commented 9 years ago
Oh, and by the way; the product I linked to above is the XBee 802.15.4 model, 
not the XBee ZigBee model. I assume you're using the former.

Original comment by pmalms...@gmail.com on 21 May 2011 at 2:19

GoogleCodeExporter commented 9 years ago
ya, my least update cleared out my api setting. Driving me up the wall trying 
to debug the api error

Original comment by jasonlig...@gmail.com on 21 May 2011 at 2:20

GoogleCodeExporter commented 9 years ago
Oh yeah, that's right....command mode would just pass along the API frame as 
is...ouch.

It might be worth improving the error message a bit to mention that possibility 
if it gets a funky packet like that. Do you think that would have helped you 
discover the problem earlier? 

Original comment by pmalms...@gmail.com on 21 May 2011 at 2:35

GoogleCodeExporter commented 9 years ago
YES.  I had them both set to api mode, but after doing some other changes later 
down the line I lost that setting.  Becasue I thought I still had it set, I 
never looked.

Original comment by jasonlig...@gmail.com on 21 May 2011 at 2:39

GoogleCodeExporter commented 9 years ago
Okay, I'll throw something in for that.

Original comment by pmalms...@gmail.com on 21 May 2011 at 2:46

GoogleCodeExporter commented 9 years ago
it will mostly help us n00bs out ;-)

Original comment by jasonlig...@gmail.com on 21 May 2011 at 2:48

GoogleCodeExporter commented 9 years ago
This feature has been added as of revision 126:3f5132e65deb 
(http://code.google.com/p/python-xbee/source/detail?r=3f5132e65debaa6a10ab40bbc9
8ccec166ed4474). 

Original comment by pmalms...@gmail.com on 21 May 2011 at 4:06