Hello everyone!
I am using the old "open" function to access the serial port to try and read some incoming data. The problem is when I receive beyond the standard ascii characters, 0x80 and above, when I do a read I get 0xffff(msb)(lsb). I'm assuming that these f's are getting tacked on because I'm doing a read - and it's expecting ascii chars. How do I get around this? It goes something like this...
Code:
int fd;
fd = open("/dev/ttyS0", O_RDWR | O_NOCTTY | O_NDELAY);
...setup async handler and serial settings..
Now.. in my signal handler
Code:
int raw_rx_data;
char in_bufer[128];
//read two bytes
read(fd, in_buffer, 2);
//convert to 16 bit integer
raw_rx_data = (in_buffer[0] << 8) | in_buffer[1];
1. Now do you think the issue is the way I'm converting the string to integer? (Note: I don't want to just mask the bits for other reasons).
2. Is there a way to use the open function with a binary flag (searched and couldn't find one)?
3. Is there a way to use the fopen function with the serial port? I don't think fopen supports the noctty / ndelay flags.
Thanks!