I am developing an embedded Linux device using an ARM iMX6 processor. The main goal is to read the incoming serial stream from an external source.
Due to the atypical nature of the serial stream, I came across several roadblocks with the Linux serial driver for imx processors. But nothing that goes beyond the capabilities of the iMX6. For example, an incoming serial stream is inverted logic. IMX6 has a special register for inverting the RX signal. From what I can tell, the Linux driver does not open it.
Another complication is that incoming serial data arrives in 3ms packets. An external source continuously transmits 3 ms, then 3 ms of inactivity, then 3 ms of data, then idle, etc. To synchronize with the first byte of each packet, it is very useful to be able to detect when the line is in standby mode. Again, iMX6 is case sensitive specifically to indicate that the RX line is idle, but the Linux driver does not open it.
I am also very confused about how buffering works in the driver. I know that iMX6 has a 32-byte FIFO buffer, but I can’t say whether the driver uses this buffer or uses external RAM for buffering. I ran into a problem when the command readfreezes for a second every time so often when I'm in lock mode, which should not be because the data stream is continuous.
For reference, here is how I configured the serial port in my C code and read 50 bytes (I changed it to non-blocking at the moment):
#include <stropts.h>
#include <asm/termios.h>
#include <unistd.h>
#include <fcntl.h>
int main()
{
int fd;
struct termios2 terminal;
unsigned char v[50];
fd = open ("/dev/ttymxc2", O_RDONLY | O_NOCTTY | O_NONBLOCK );
ioctl(fd, TCGETS2, &terminal);
terminal.c_cflag |= (CLOCAL | CREAD) ;
terminal.c_cflag |= PARENB ;
terminal.c_cflag &= ~PARODD ;
terminal.c_cflag |= CSTOPB ;
terminal.c_cflag &= ~CSIZE ;
terminal.c_cflag |= CS8 ;
terminal.c_lflag &= ~(ICANON | IEXTEN | ECHO | ECHOE | ISIG) ;
terminal.c_oflag &= ~OPOST ;
terminal.c_cflag &= ~CBAUD;
terminal.c_cflag |= BOTHER;
terminal.c_ispeed = 100000;
terminal.c_ospeed = 100000;
ioctl(fd, TCSETS2, &terminal);
...
for(i=0;i<50;i++)
{
read(fd,v+i,1)
}
...
}
I have two questions:
"" , , ? , , , . ?
- iMX? , , . , , , .