LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-08-2005, 03:30 AM   #1
lucky6969b
Member
 
Registered: Nov 2005
Posts: 337

Rep: Reputation: 30
read API is blocked


Hi,
I'm reading some data off the serial port known as /dev/ttyS1
when I am reading it like this
res = read (fd, buff, 255);
(fd is opened with the Open API.)
the read was blocked and the debugger did not come thru. Here is the asynchronize code I have

fd = open (MODEMDEVICE, O_RDWR | O_NOCTTY | O_NONBLOCK);

// check for errors
saio.sa_handler = signal_handler_IO;
saio.sa_mask = 0l
saio.sa_flags = 0;
saio.sa_restorer = NULL;
sigaction (SIGIO, &saio, NULL);


fcntl (fd, F_SETOWN, getpid());

fcntl (fd, F_SETFL, FASYNC);

tcgetattr (fd, &oldtio);

newtio.c_cflag = BAUDRATE | CRTSCTS | CS8 | CLOCAL | CREAD);
newtio.c_iflag = IGNPAR | ICRNL;
newtio.c_oflag = 0;
newtio.c_lflag = ICANON;
newtio.c_cc[VMIN] = 1;
newtio.c_cc[VTIME] = 0;
tcflush (fd, TCIFLUSH);

tcsetattr (fd, TCSANOW, &newtio);

while (STOP == FALSE)
{
printf (".\n")
if (wait_flag == FALSE)
{
res = read (fd, buf, 255);
// blocked here
buf[res] = 0;
printf (....) etc...
if (res == 1) STOP=TRUE;
wait_flag = TRUE;
}
}
tcsetattr (fd, TCSANOW, &oldtio);
}

void signal_handler_IO(int status)
{
printf ("received SIGIO signal\n");
wait_flag = FALSE;
}

But "received SIGIO Signal" keeps popping up endlessly

Thanks
Jack
 
Old 12-08-2005, 04:01 AM   #2
lucky6969b
Member
 
Registered: Nov 2005
Posts: 337

Original Poster
Rep: Reputation: 30
I created a thread for handling all these. Are there any danger of this approach?
I want different threads to handle different devices. Thanks
Jack
 
Old 12-08-2005, 07:27 PM   #3
lucky6969b
Member
 
Registered: Nov 2005
Posts: 337

Original Poster
Rep: Reputation: 30
One more thing, saio.sa_mask = 0; is commented out because it says the "=" operator cannot be found in C++ mode which assumes sa_mask or saio is a class. Thanks
Jack
 
  


Reply



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
Blocked bhughesiii Linux - Networking 9 05-12-2005 01:44 PM
Ports Blocked spaceballs Slackware 4 05-02-2005 09:42 PM
How to get that IP blocked from my box? donk3 Linux - Security 6 10-07-2003 11:20 AM
blocked port 80 squi Linux - Newbie 1 09-19-2003 09:57 AM
My CD drives are blocked. Baldorg Linux - Hardware 13 09-13-2003 04:34 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

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

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