I'm trying to send serial data to a device I'm building through a USB to TTL chip. When I had a PL2303HX in the input, things worked fine. I've changed to an MCP2221 and now there seems to be some sort of termio buffer limit of 16 chars. Anything above that and I lose data. I thought that I had the program on the linux side setup to just send raw unbuffered data to the device, but clearly that's not happening. I've been working on this problem for three days straight and I'm stumped. Any help would truly be appreciated.
Here is the termio setup I'm using:
Code:
memset(&tioPLL,0,sizeof(tioPLL)); /* start with clean tioPLL */
tioPLL.c_cflag |= (CS8 | CLOCAL | CREAD); /* 8N1 */
tioPLL.c_cflag &= ~CSTOPB; /* 1 stop bit */
tioPLL.c_iflag &= ~(IXON | IXOFF | IXANY); /*disable software flow control*/
tioPLL.c_iflag &= ~(INPCK | PARMRK); /* no parity check*/
tioPLL.c_iflag |= IGNPAR; /* ignore parity errors*/
tioPLL.c_oflag &= ~OPOST; /* enable raw output */
tioPLL.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG); /* enable raw input */
tioPLL.c_cc[VTIME] = 1;
cfsetospeed(&tioPLL,B57600); // 9600 baud
cfsetispeed(&tioPLL,B57600); // 9600 baud
tcsetattr(ttyPLL,TCSANOW,&tioPLL);
Here is an idea of how I'm passing data to the device:
Code:
/* if there's input from STDIN */
if(FD_ISSET(STDIN_FILENO, &readfs))
{
/* if new data is available on the console,
* send it to the serial port */
if(read(STDIN_FILENO,&kbdByte,1)>0)
{
if(kbdByte != 'q')
{
write(STDOUT_FILENO,&kbdByte,1);
write(ttyPLL,&kbdByte,1);
if(kbdByte == '\r')
write(ttyPLL, "\r\n", 2);
}
}
}
I've just made sure that the PIC using the PL2303HX with the same version of the PIC program (and the same user program on linux) works fine for more than 16 chars of input.