I am trying to get a python script to write to a serial port with pyserial, to node.js using serialport2.
I am very confused about bytes() in python, wonder can anyone give me a hand?
python:
ser.write(bytes(chr(160))
ser.write(bytes(chr(157))
so how do I do this in node.js?
serialport2 used in node.js is located here.
From the node-serialport2 readme:
So, you can give a string object or Buffer object as the argument. A Buffer object will probably do what you want (send integer values):
For your data, it would be:
By the way, you don’t need to do any special casting in Python with PySerial. From the PySerial API documentation:
Note the “changed in version 2.5” note.