I am using python-xbee and Python 3.7 to send API commands from an XBee connected to UART1 on a Beaglebone Black to a remote XBee. Both are Version 1 Pro models.
My remote XBee (the one I am sending commands to) has the following address:
SH=0013A200
SL=40DD7DCD
When I submit a command using the low portion of the 64-bit address
xbee.remote_at(dest_addr='\x40\xDD\x7D\xCD', command='0x17', parameter=D0_LOW, frame_id='A')
I receive the error:
UnicodeEncodeError: 'ascii' codec can't encode character '\xdd' in position 1: ordinal not in range(128)
My code is as follows:
from xbee import XBee from serial import Serial
PORT = '/dev/ttyO1'
BAUD = 9600
# Send 0x17 AT command with parameter 04 for low (off), 05 for high (on)
# D0=4 Low
# D0=5 High
D0_LOW = 4
D0_HIGH = 5
ser = Serial(PORT, BAUD)
xbee = XBee(ser)
xbee.remote_at(dest_addr='\x40\xDD\x7D\xCD', command='0x17', parameter=D0_LOW, frame_id='A')
# Wait for and get the response
print(xbee.wait_read_frame())
ser.close()
My question is this - what is the correct format for the dest_addr when the upper and lower bytes are known and no controller is being used (point-to-point only)?
If I change the address to use hex (e.g. \0x40\0xDD\0x7D\0xCD) then the error message is
The data provided for 'dest_addr' was not 2 bytes long
Do I need to format the address to ASCII 2 bytes?