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"<googch...@qq.com>; 
????????: 2019??3??26??(??????) ????11:09
??????: "joel"<j...@rtems.org>; 
????: "users"<users@rtems.org>; 
????: ????: Re: uart does not work



stm32f4 ??log odd , read seems nonblocked
---????????---
??????:"joel"<j...@rtems.org>
????????:2019??3??26?? ?????? ????8:39
??????:"787562067"<googch...@qq.com>
????:"rtems-us...@rtems.org"<users@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 <googch...@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@rtems.org
http://lists.rtems.org/mailman/listinfo/users
_______________________________________________
users mailing list
users@rtems.org
http://lists.rtems.org/mailman/listinfo/users

Reply via email to