I'm using this code to send a Xbee-Xbee packet through API mode to print (in a real printer) on the end node. I'm reading a .txt file, saving some lines in a var and sending a API packet. On that file there's also some ESC/POS commands. When I try to group some lines in another variable using "data +=eval(line)" I got an error. Why? If I don't use eval, the printer is going to print the commands instead of doing it....
lines = f.readlines()
for line in lines[:-1]:
data += eval(line)
if len(data.encode('utf-8')) >= 220:
xbee.tx(frame_id = b'\x01', dest_addr = b'\x77\x71', dest_addr_long = ENDERECO, data = data)
print data
data = ''
I've tried to use exec but didn't work either. Nor using the Eval() in the xbee.tx function after grouping it... Any suggestions?
Error when I use data+=eval(line)
:
Traceback (most recent call last):
SyntaxError: unexpected EOF while parsing