uart does not work

Joel Sherrill joel at rtems.org
Tue Mar 26 12:39:28 UTC 2019


Which bsp? Does the console driver have a set_attributes handler? Does it
return false?

On Tue, Mar 26, 2019, 7:08 AM 787562067 <googcheng at qq.com> wrote:

> HI, ALL!
>
> *when i run fileio test case, i got nothing;*
>
> when i run example from here
> http://zhgyuan.cn/downloads/uploads-file/201707/myapp.tar.gz
>
> [19:51:16.847]收←◆hello,this is my print task test!
>
> RTEMS Shell on /dev/console. Use 'help' to list commands.
> [/] #
> [19:51:17.177]收←◆hello,this is my print task test!
>
> RTEMS Shell on /dev/console. Use 'help' to list commands.
> [/] #
> [19:51:18.020]收←◆hello,this is my print task test!
>
> RTEMS Shell on /dev/console. Use 'help' to list commands.
> [/] #
> [19:51:19.306]收←◆hello,this is my print task test!
>
> RTEMS Shell on /dev/console. Use 'help' to list commands.
> [/] #
> [19:51:20.589]收←◆hello,this is my print task test!
>
> RTEMS Shell on /dev/console. Use 'help' to list commands.
> [/] #
> [19:56:17.932]TX→◇help
>> [19:56:17.941]RX←◆h
>
>
> i dont know why. the uart read also does not work for me
>
> void testCom1(void) {
>   char buffer[256] = {0};
>
>   printf("*** Simple COM1 Test ***\n");
>
>   //int fd = open("/dev/ttyS1", O_RDWR | O_NOCTTY | _FNDELAY);
>   int fd = open("/dev/ttyS2", O_RDWR | O_NOCTTY);
>
>   printf("\nOpened COM1, fd=%d\n\n", fd);
>   if(fd < 0)
>       printf("open error\n");
>
>   #if 0
>   if(fcntl(fd, F_SETFL, 0) < 0)
>   {
>     printf("fcntl failed!\n");
>     return;
>   }
>   else
>   {
>       printf("fcntl=%d\n",fcntl(fd, F_SETFL,0));
>   }
>   #endif
>   //fcntl(fd, F_SETFL, 0); // set blocked
>
>   struct termios options;
>   tcgetattr(fd, &options);
>   bzero(&options, sizeof(options));
> /* setting the baud rate */
>   cfsetispeed(&options, B115200);
>   cfsetospeed(&options, B115200);
>
>   options.c_cflag |= (CLOCAL | CREAD);
>
>   //options.c_cflag &= ~PARENB;
>   //options.c_cflag &= ~CSTOPB;
>   //options.c_cflag &= ~CSIZE;
>   options.c_cflag |= (CS8 | CRTSCTS);
>
>   options.c_iflag = IGNPAR| ICRNL;
>   options.c_oflag = 0;
>   options.c_lflag = ICANON;
>
>   options.c_cc[VEOF] = 4;
>   options.c_cc[VMIN] = 1;
>   options.c_cc[VTIME] = 0;
>
>   tcflush(fd, TCIFLUSH);
>   tcsetattr(fd, TCSANOW, &options);
>
>   if(0 == isatty(fd))
>   {
>       printf("input is not a terminal device\n");
>       //return;
>   }
>
>   int numBytes = write(fd, "Hello, I'm waiting for input..\r\n", 33);
>
>   if (numBytes < 0) {
>     printf("\nFailed to send from COM1!\n");
>   }
>
>
>   //wait input
>   printf("wait 5s \n");
>
>   #if 1
>   //(void) rtems_task_wake_after( 5 * rtems_clock_get_ticks_per_second() );
>   numBytes = read(fd, buffer, 20);
>   printf("read bytes %d\n", numBytes);
>   strerror(errno);
>   if (numBytes < 0) {
>     printf("\nFailed to read from COM1!\n");
>
>   }
>   else if(numBytes == 0)
>   {
>     printf("read error return 0\n");
>   }
>   else
>   {
>     //buffer[numBytes] = 0; // terminate
>     printf("rev: %s\n", buffer);
>   }
>   #endif
>
>   //int read_cnt = uart_recv(fd, buffer, 20);
>   //printf("rev: %s\n", buffer);
>   //printf("read_cnt: %d\n", read_cnt);
>   close(fd);
>   rtems_task_delete(RTEMS_SELF);
> }
>
>
> hope you could help me check it , thx!
> _______________________________________________
> users mailing list
> users at rtems.org
> http://lists.rtems.org/mailman/listinfo/users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/users/attachments/20190326/4e5576e7/attachment-0002.html>


More information about the users mailing list