View topic - Using read() with Framing char

Using read() with Framing char

anything that doesn't fit to other groups.

Using read() with Framing char

Postby starless » Wed Nov 12, 2003 2:57 am

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:
Code: Select all
// 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!
starless
Active Member
 
Posts: 70
Joined: Sun Sep 21, 2003 1:15 am

Re: Using read() with Framing char

Postby lestat » Wed Nov 12, 2003 5:38 am

starless wrote: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?

in SDLC/HDLC like protocols (and derived from them as PPP, etc) flag character must be sent directly after data was sent. But behaviour depends on your physic line, if your physic line is synchronous then it requires a framing character immediately after data. But anyway I didn't see why to not send framing char directly without using that tty weirdness ? :wink:
lestat
QNX Master
 
Posts: 55
Joined: Fri Aug 23, 2002 4:42 am
Location: Kiev, Ukraine


Return to General Programming

Who is online

Users browsing this forum: No registered users and 1 guest

cron