I’m interfacing with a device that uses character framing(0x7e) in it’s communication protocol. Is read() with FORWARD CHAR set in the struct termios what I should use?
So far:
// Set struct termios
ret = tcgetattr( fd, &termio );
termio.c_cc[VFWD] = 0x7e;
termio.c_cc[VTIME] = 5;
ret = tcsetattr( fd, TCSANOW, &termio );
// prepare and write the command to fd...
// flush
readcond(fd, buf1, 30, 0, 0, 0);
// read 1 byte
tmp = readcond(fd, buffer, 1, 1, 0, 2);
if(buffer[0] == 0x7e)
{
// keep on reading until next framing char
tmp = read(fd, &buffer[1], 29);
}
else
{
// Flush...
readcond(fd, buffer, 30, 0, 0, 0);
}
Is it the way of using it?
It works, but it misses ~ 20%…
TY!