Re: serial port canonical mode weirdness?

From: David L
Date: Thu Apr 01 2004 - 10:47:24 EST


> When I configure a serial port for canonical mode (newtio.c_lflag = ICANON),
> I get behavior that isn't what I'd expect.

Can you supply the test program you're using on the receive end?

--
#include <termios.h>
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <unistd.h>

#define BAUDRATE B38400
#define SERIALDEVICE "/dev/ttyS0"

int main()
{
int fd, res;
struct termios newtio;
unsigned char buf[10000];

fd = open(SERIALDEVICE, O_RDWR);
if (fd <0) {perror(SERIALDEVICE); return -1; }

bzero(&newtio, sizeof(newtio));

newtio.c_cflag = BAUDRATE | CS8 | CLOCAL | CREAD;
newtio.c_iflag = IGNPAR;
newtio.c_lflag = ICANON;

newtio.c_cc[VEOL] = 0x0D;

tcsetattr(fd,TCSANOW,&newtio);

while (1) {
res = read(fd,buf,9000);
printf("%d bytes read (%d)\n", res, errno);
printf("%02X %02X %02X %02X %02X %02X\n", buf[0],buf[1],buf[2],buf[3],buf[4],buf[5]);
}
}

_________________________________________________________________
FREE pop-up blocking with the new MSN Toolbar ? get it now! http://toolbar.msn.com/go/onm00200415ave/direct/01/

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/