Skip to content

Minor refactoring due to what it seems a fail in the Digi Xbee documentation #61

@GoogleCodeExporter

Description

@GoogleCodeExporter
What steps will reproduce the problem?

1. Trying to issue an 'ND' command (API mode) and later parsing it (the problem 
is in the parsing).
For example: 
    xbee.send("at", frame='A', command='ND')
    print xbee.wait_read_frame()

What is the expected output? What do you see instead?

You were expected to receive the following information associated with the ND 
command refered in the datasheet:

QUOTE:

Node Discover. Discovers and reports all RF modules found. The following 
information is reported for each module discovered.
MY<CR>
SH<CR>
SL<CR>
NI<CR> (Variable length)
PARENT_NETWORK ADDRESS (2 Bytes)<CR>
DEVICE_TYPE<CR> (1 Byte: 0=Coord, 1=Router, 2=End Device)
STATUS<CR> (1 Byte: Reserved)
PROFILE_ID<CR> (2 Bytes)
CRE
MANUFACTURER_ID<CR> (2 Bytes)
<CR>
If ND is sent through the API, each response is returned as a separate
AT_CMD_Response packet. The data consists of the above listed bytes without the 
carriage return delimiters. The NI string will end in a "0x00" null character. 
The radius of the ND command is set by the BH command.

END QUOTE:

Instead it seems like the module sends you additional data (4 bytes) that are 
not refered in the datasheet. To me these 4 bytes seem to be additional info 
refering to the command 'DD' (Device identifier type). This makes the method 
"_parse_ND_at_response(self, packet_info)" send an Error message.


What version of the product are you using? On what operating system?
I m using the Xbee Zigbee Pro S2B, later i will test this with Xbee Zigbee S2B

Please provide any additional information below.

You can solve this adding the following line (in method 
_parse_ND_at_response(self, packet_info)):

"result['device_type_identifier'] = 
packet_info['parameter'][null_terminator_index+9:null_terminator_index+13]"

after the line:

"result['manufacturer'] = 
packet_info['parameter'][null_terminator_index+7:null_terminator_index+9]"

and modifying the test before return of the method to:

"               if null_terminator_index+13 != len(packet_info['parameter']):
                   raise ValueError("Improper ND response length: expected {0}, read {1} bytes".format(len(packet_info['parameter']), null_terminator_index+9))
"


The correct way to solve probably would be to take this last test out, and 
believe in the checksum. This way if Digi decides to add more information to 
the DATA packet you won t have problems and will only parse it if necessary

Original issue reported on code.google.com by [email protected] on 10 Jun 2015 at 10:43

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions