Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 01-13-2012, 04:44 AM   #1
LQ Newbie
Registered: Jan 2012
Posts: 4

Rep: Reputation: Disabled
Displaying I/O possible when reading data from the tty(serial) port in Fedora

I have got a problem while reading from the serial port. Whenever I'm trying to read any data through the serial port, it's displaying I/O Possible and the application is being terminated in Fedora.I have highlighted that line in the code Though the same code works fine in RHEL. Kindly advice. Here are snippets of my code

void Serialinit()
struct termios options;
printf("\nSerial Port is open\n");
portfd = open("/dev/ttyS0",O_RDWR | O_NOCTTY | O_NDELAY);
if (portfd == -1) {
/* Could not open the port.*/
perror("open_port: Unable to open /dev/ttyS0 - ");

options.c_iflag = IGNPAR;
options.c_oflag = 0;
options.c_lflag = 0;
options.c_cflag = B4800|CS8|CLOCAL|CREAD;
fcntl(portfd, F_SETFL, FASYNC);

if(tcsetattr(portfd, TCSANOW, &options))
perror("cannot set the attributes\n");
tcflush(portfd, TCIOFLUSH);

then in main

int no_of_char_read = 0;

no_of_char_read =read(portfd, &datas,1);

//printf("datas:%x\n", datas);

if(count < 0)
count = 0;
buffers[count] = datas; // store in buffers array
printf("buffers[%d]: %x\n", count, buffers[count]);


Last edited by Leena; 01-13-2012 at 04:46 AM.
Old 01-14-2012, 07:46 PM   #2
Senior Member
Registered: Jun 2008
Distribution: debian, ubuntu, sidux
Posts: 1,125
Blog Entries: 2

Rep: Reputation: 124Reputation: 124
Hi Leena, I actually replied to this in the other thread, but I'll add it here as well. You either need to turn off NDELAY before doing your read or you need to check your error and see if it is EAGAIN in the loop and not exit out of the loop if it is EAGAIN. NDELAY just tells the read turn return immediately if there is no data with the EAGAIN error (which I'm guessing is what is getting translated into I/O possible for you).


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Displaying I/O possible when reading data from the serial port makphy Programming 9 06-18-2013 06:14 AM
[SOLVED] Serial port : Read data problem, not reading complete data anujmehta Linux - Networking 5 09-06-2010 07:10 AM
help reading data from a serial port skydemon Linux - General 1 08-10-2006 09:48 AM
reading data from a serial port mchitrakar Linux - Networking 3 12-04-2004 02:24 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:34 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration