Blocking on Reading serial port 2 on MVME162 running RTEMS 4.10.2
AJAI KUMAR MEDHAVI
akmedhavi at rrcat.gov.in
Wed Aug 21 11:40:41 UTC 2013
Hi,
This is with reference to RTEMS 4.10.2 Console driver on MVME162 CPU
Board. The driver file console.c may be found in
rtems-4.10.2\c\src\lib\libbsp\ m68k\mvme162\console
I am trying to receive and write messages on both Console Port ( serial
port 1) and tty00 (serial port 2) .
When Console port is 1 (as given in rtems_io_initialize in console.c at
the time of registering device "/dev/console" with minor no. 0 )
Here :
-- I am able to receive / write messages from/to console port (serial
port 1) by using
printf("\n\nWriting on Console / Serial Port 1");
respmsg[0]=0x31;
respmsg[1]=0x31;
respmsg[2]=0x31;
respmsg[3]=0x31;
len = write(STDOUT_FILENO, &respmsg[0], 4);
if(len == 4)
printf("\nWriting on Serial Port 1 successful");
-- Able to Open "/dev/tty00" and write successfully on serial port 2 (tty00)
-- But not able to receive message on serial port 2 (tty00), it is
indefinetly blocking
Here for serial port 2, I have used following code :
/*----open Console serial port 2 and write/read messages----------*/
fd2=open("/dev/tty00",O_RDWR | O_NOCTTY | O_NONBLOCK);
if (fd2 <0) {
perror("/dev/tty00");
close(fd2);
}
else {
printf("\nPort /dev/console is opened");
printf("\n\nfd2 Value = %d",fd2);
/*fcntl(fd2, F_SETFL, 0);*/
}
fcntl(fd2, F_SETFL, 0);
/*-----get the current options--------------------*/
if(tcgetattr(fd2, &options) < 0)
printf("\nError in getting tty00 settings");
else {
/* setting the baud rate */
cfsetispeed(&options, B9600);
cfsetospeed(&options, B9600);
/* set raw input, 1 second timeout
options.c_cflag |= (CLOCAL | CREAD);
*/
/* 8N1, no parity */
options.c_cflag &= ~PARENB;
options.c_cflag &= ~CSTOPB;
options.c_cflag &= ~CSIZE;
options.c_cflag |= ( CS8 | B9600 );
/*options.c_cflag &= ~(CRTSCTS);*/ /* no hardware flow control */
/*options.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG);
options.c_oflag &= ~(OPOST);
options.c_cc[VMIN] = 0;
options.c_cc[VTIME] = 10;
*/
/* set the options */
tcsetattr(fd2, TCSANOW, &options);
}
printf("\n\nWriting on Serial Port 2");
respmsg[0]=0x32;
respmsg[1]=0x32;
respmsg[2]=0x32;
respmsg[3]=0x32;
len = write(fd2, &respmsg[0], 4);
if(len == 4)
printf("\nWriting on Serial Port 2 successful transmitted 4 bytes");
else{
printf("\nWriting on Serial Port 2 failed");
printf("\nBytes trnasferred %d", len);
}
printf("\nReceiving message2 from serial port 2\n");
nbytes = read(fd2, buf2, sizeof(buf2));
printf("Message2 read = %s\n", buf2);
Even after re-setting tty00 filedesc as given below , the problem remains
same
Does anyone have an advice of what's wrong with the code ( whether in
application and / or console.c driver)
How to fix the problem of reading on the serial port 2 ?
Thank you very much in advance and kind regards,
Please find application code as given below :
--
More information about the users
mailing list