回复: Re: uart does not work

787562067 googcheng at qq.com
Wed Mar 27 01:19:01 UTC 2019


usart_set_attributes in rtems project all return -1 at v4.11.3 , 
 should i put usart_read_polled function to a new task?




------------------ 原始邮件 ------------------
发件人: "787562067"<googcheng at qq.com>; 
发送时间: 2019年3月26日(星期二) 晚上11:09
收件人: "joel"<joel at rtems.org>; 
抄送: "users"<users at rtems.org>; 
主题: 回复: Re: uart does not work



stm32f4 ,log odd , read seems nonblocked
---原始邮件---
发件人:"joel"<joel at rtems.org>
发送时间:2019年3月26日 星期二 下午8:39
收件人:"787562067"<googcheng at qq.com>
抄送:"rtems-users at rtems.org"<users at rtems.org>
主题:Re: uart does not work
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&#xA0;http://zhgyuan.cn/downloads/uploads-file/201707/myapp.tar.gz&#xA0;


[19:51:16.847]收←◆hello,this is my print task test!


RTEMS Shell on /dev/console. Use 'help' to list commands.
[/] #&#xA0;
[19:51:17.177]收←◆hello,this is my print task test!


RTEMS Shell on /dev/console. Use 'help' to list commands.
[/] #&#xA0;
[19:51:18.020]收←◆hello,this is my print task test!


RTEMS Shell on /dev/console. Use 'help' to list commands.
[/] #&#xA0;
[19:51:19.306]收←◆hello,this is my print task test!


RTEMS Shell on /dev/console. Use 'help' to list commands.
[/] #&#xA0;
[19:51:20.589]收←◆hello,this is my print task test!


RTEMS Shell on /dev/console. Use 'help' to list commands.
[/] #&#xA0;
[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&#xA0;


void testCom1(void) {
&#xA0; char buffer[256] = {0};


&#xA0; printf("*** Simple COM1 Test ***\n");


&#xA0; //int fd = open("/dev/ttyS1", O_RDWR | O_NOCTTY | _FNDELAY);
&#xA0; int fd = open("/dev/ttyS2", O_RDWR | O_NOCTTY);


&#xA0; printf("\nOpened COM1, fd=%d\n\n", fd);
&#xA0; if(fd < 0)
&#xA0; &#xA0; &#xA0; printf("open error\n");


&#xA0; #if 0
&#xA0; if(fcntl(fd, F_SETFL, 0) < 0)&#xA0;&#xA0;
&#xA0; {&#xA0;&#xA0;
&#xA0; &#xA0; printf("fcntl failed!\n");&#xA0;&#xA0;
&#xA0; &#xA0; return;&#xA0;&#xA0;
&#xA0; }&#xA0; &#xA0; &#xA0; &#xA0;
&#xA0; else&#xA0;&#xA0;
&#xA0; {&#xA0;&#xA0;
&#xA0; &#xA0; &#xA0; printf("fcntl=%d\n",fcntl(fd, F_SETFL,0));&#xA0;&#xA0;
&#xA0; }
&#xA0; #endif
&#xA0; //fcntl(fd, F_SETFL, 0); // set blocked
&#xA0;&#xA0;
&#xA0; struct termios options;
&#xA0; tcgetattr(fd, &options);
&#xA0; bzero(&options, sizeof(options));
/* setting the baud rate */
&#xA0; cfsetispeed(&options, B115200);
&#xA0; cfsetospeed(&options, B115200);



&#xA0; options.c_cflag |= (CLOCAL | CREAD);


&#xA0; //options.c_cflag &= ~PARENB;
&#xA0; //options.c_cflag &= ~CSTOPB;
&#xA0; //options.c_cflag &= ~CSIZE;
&#xA0; options.c_cflag |= (CS8 | CRTSCTS);


&#xA0; options.c_iflag = IGNPAR| ICRNL;
&#xA0; options.c_oflag = 0;
&#xA0; options.c_lflag = ICANON;


&#xA0; options.c_cc[VEOF] = 4;
&#xA0; options.c_cc[VMIN] = 1;
&#xA0; options.c_cc[VTIME] = 0;


&#xA0; tcflush(fd, TCIFLUSH);
&#xA0; tcsetattr(fd, TCSANOW, &options);&#xA0;&#xA0;
&#xA0; &#xA0; &#xA0;&#xA0;
&#xA0; if(0 == isatty(fd))&#xA0;&#xA0;
&#xA0; {&#xA0;&#xA0;
&#xA0; &#xA0; &#xA0; printf("input is not a terminal device\n");&#xA0;&#xA0;
&#xA0; &#xA0; &#xA0; //return;&#xA0;&#xA0;
&#xA0; }


&#xA0; int numBytes = write(fd, "Hello, I'm waiting for input..\r\n", 33);


&#xA0; if (numBytes < 0) {
&#xA0; &#xA0; printf("\nFailed to send from COM1!\n");
&#xA0; }


&#xA0;&#xA0;
&#xA0; //wait input&#xA0;
&#xA0; printf("wait 5s \n");


&#xA0; #if 1
&#xA0; //(void) rtems_task_wake_after( 5 * rtems_clock_get_ticks_per_second() );
&#xA0; numBytes = read(fd, buffer, 20);
&#xA0; printf("read bytes %d\n", numBytes);
&#xA0; strerror(errno);
&#xA0; if (numBytes < 0) {
&#xA0; &#xA0; printf("\nFailed to read from COM1!\n");


&#xA0; }
&#xA0; else if(numBytes == 0)
&#xA0; {
&#xA0; &#xA0; printf("read error return 0\n");
&#xA0; }
&#xA0; else
&#xA0; {
&#xA0; &#xA0; //buffer[numBytes] = 0; // terminate
&#xA0; &#xA0; printf("rev: %s\n", buffer);
&#xA0; }
&#xA0; #endif


&#xA0; //int read_cnt = uart_recv(fd, buffer, 20);
&#xA0; //printf("rev: %s\n", buffer);
&#xA0; //printf("read_cnt: %d\n", read_cnt);
&#xA0; close(fd);
&#xA0; 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/20190327/dbebc49b/attachment-0002.html>


More information about the users mailing list