Unable to read XBee Api frame on Raspberry Pi 3 with Node-RED v0.17.3

Viewed 741

I hope you'll help me to find out what's wrong with my configuration.

I have to ZigBee nodes, one connected via usb to my mac and one connected via tx/rx ports to the raspberry pi 3.

I wrote two scripts, one that sends Xee Api frame packets (from mac) and one that reads packets (to the pi). The two scripts are based on the python-xbee library.

The scripts are the following - on mac:

import serial
from xbee import XBee, ZigBee 

serial_port = serial.Serial('/dev/tty.usbserial-A5025UGJ', 9600) 
xbee = ZigBee(serial_port, escaped=True) 

# coordinator = 00 13 A2 00 40 8B B1 5A 

while True: 
    try: 
        # Send AT packet 
        xbee.send('tx',frame_id='A', dest_addr_long='\x00\x13\xA2\x00\x40\x8B\xB1\x5A', data='test') 
        parameter = xbee.wait_read_frame() 
        print 'parameter=' 
        print parameter 

    except KeyboardInterrupt: 
        break 

serial_port.close()

On Pi:

import serial
from xbee import XBee, ZigBee 

serial_port = serial.Serial('/dev/serial0', 9600) 
xbee = ZigBee(serial_port, escaped=True) 

while True: 
    try: 

        # Receive AT packet 
        parameter = xbee.wait_read_frame() 
        print 'parameter=' 
        print parameter 

    except KeyboardInterrupt: 
        break 

serial_port.close()

The output of the first script is the following (the sender):

parameter= {'retries': '\x00', 'frame_id': 'A', 'deliver_status': '\x00', 'dest_addr': '\x00\x00', 'discover_status': '\x00', 'id': 'tx_status'}

The output of the second script is the following (the receiver):

parameter= {'source_addr_long': '\x00\x13\xa2\x00@\x8b\xb1L', 'rf_data': 'test', 'source_addr': '\xa3\x19', 'id': 'rx', 'options': '\x01'}

Now if I start Node-Red 0.17.3 and I use the "serial input" module, connected to a debug output module, i cannot see anything incoming if the newline is base on the char "\n". The port is the same of the script (/dev/serial0).

[
    {
        "id": "e6aa5379.9fd8c",
        "type": "debug",
        "z": "35e84ae.5ae88b6",
        "name": "",
        "active": true,
        "console": "false",
        "complete": "true",
        "x": 432.5,
        "y": 213,
        "wires": []
    },
    {
        "id": "63563843.bba178",
        "type": "serial in",
        "z": "35e84ae.5ae88b6",
        "name": "",
        "serial": "fbf0b4fa.9b2918",
        "x": 209.5,
        "y": 201,
        "wires": [
            [
                "e6aa5379.9fd8c"
            ]
        ]
    },
    {
        "id": "fbf0b4fa.9b2918",
        "type": "serial-port",
        "z": "",
        "serialport": "/dev/serial0",
        "serialbaud": "9600",
        "databits": "8",
        "parity": "none",
        "stopbits": "1",
        "newline": "\\n",
        "bin": "false",
        "out": "char",
        "addchar": false
    }
]

If I change the configuration of "serial in" node, setting the split "after a timeour of 5000 ms" and deliver "binary buffers", this is the result in debug view:

[126,0,125,49,144,0,125,51,162,0,64,139,177,76,163,25,1,112,114,111,118,97,13]

Does anyone know how to find the correct way to split input with XBee API frames?

1 Answers
Related