So, I have some kind of uninformed (maybe?) Question. This is the first time I am working with recording on a serial device. I have a frame [12, 0, 0, 0, 0, 0, 0, 0, 7, 0, X, Y] that I need to send. X and Y are checksum values. My understanding of using the pyserial module is that I need to convert this frame to a string representation. Good, good, but I'm confused about the format in which things should be. I tried to do
a = [12, 0, 0, 0, 0, 0, 0, 0, 7, 0, X, Y]
send = "".join(chr(t) for t in a)
But my confusion comes from the fact that X and Y when using chr are converted to strange strings (assuming they are ascii). For example, if X is 36, chr (x) is "$" instead of "\ x24". Is there a way that I can get a string representing the value "\ xnn" instead of ascii code? What bothers me is that 12 and 7 are correctly converted to "\ x0b" and "\ x07". Did I miss something?
Update:
Perhaps I do not quite understand how serial recordings are performed or what my device expects from me. This is the part of my C code that works:
fd=open("/dev/ttyS2",O_RDWR|O_NDELAY);
char buff_out[20]
for i in buff_out print("%x ",buff_out[i]);
write(fd,buff_out,11);
sleep()
read(fd,buff_in,size);
for i in buff_in print("%x ",buff_in[i]);
Python:
frame = [11, 0, 0, 0, 0, 0, 0, 0, 9] + [crc1, crc1]
senddata = "".join(chr(x) for x in frame)
IEC = serial.Serial(port='/dev/ttyS2', baudrate=1200, timeout=0)
IEC.send(senddata)
IEC.read(18)
? , , , . , serial.send() ?