Problem in reading/writing binary data in Linux
I am currently running Linux 7.2 and I am having some problems in reading and writing the serial ports with "binary" data. I can properly set up the serial port for reading and writing of ASCII data, but when it comes to binary data then I have the problem.... some of my code looks like the following:
unsigned char XYStatusRequest;
XYStatusRequest = 0xB3; // this is just a request buffer to obtain data
XYStatusRequest = 0x58; // from some hardware that I interface to
XYStatusRequest = 0x59;
XYStatusRequest = 0x0D;
Then, I write the data out of serial port #3 with the assistance of a "timer" as follows....
c = write(fd_serial_port_3, (void *) &XYStatusRequest, sizeof(long));
This code appears to be working for the writing of the binary data out of the serial port to the hardware device or to Procomm. If you see a problem in how I have coded it, please let me know as well. Thank you very much!
Then, the readback function expects 12 bytes of binary data from serial port #3. This code to read back the data from serial port #3 with the assistance of a "timer" looks like the following....
unsigned char XYStatusRequestReadback;
c = read(fd_serial_port_3, (void *) &XYStatusRequestReadback,
THIS code FAILS to retrieve the binary data and only will retrieve ASCII data, and to boot it needs a <CR> or 0x0D on the end of the data to even read the bytes that I send to it!
I have tried to sending the data to the port via Procomm, but with no luck so far!
Any assistance that you can afford to me would be greatly appreciated! Thank you very much for all of your time and consideration!