我想从UART读取数据,我遵循this tutorial,写入功能按预期工作,但是读取功能出现问题:
这是uart_init函数:
void uart_init()
{
printf("
+----------------------------------+");
printf("
| Serial Port Write |");
printf("
+----------------------------------+");
/*------------------------------- Opening the Serial Port -------------------------------*/
fd = open("/dev/ttyUSB0",O_RDWR | O_NOCTTY| O_SYNC); /* !!blocks the read */
/* O_RDWR Read/Write access to serial port */
/* O_NOCTTY - No terminal will control the process */
/* O_NDELAY -Non Blocking Mode,Does not care about- */
/* -the status of DCD line,Open() returns immediatly */
if(fd == -1) /* Error Checking */
printf("
Error! in Opening ttyUSB0 ");
else
printf("
<