0

I'm reading data from virtual serial ports under Linux (the connected devices are xbee modules)

At the moment the reading is done with a thread that checks the buffer of the port. But in case of many devices this isn't good, becuase on one port data maybe comes in every ms and on another every second, so it becomes a burden on the CPU.

I want to know if there is something like an an interrupt, that fires en event only when new data is available (i know this principal works on microcontrollers).

How to make this in C++?

I don't know how to use this information, because of a lack of knowledge from my side. If I have something like this:

while(1){

   int n= PollComport(comport_number, buf, 4095);
   if(n>0){
   //make somemthing with the new data
   }
}

I want to remove the while loop. Where and how do I use the epoll_wait?

1
  • If you could replace PollComport with a function that did exactly what you wanted, what precisely would that function do? Sep 1, 2012 at 11:14

1 Answer 1

2

It's not your problem. The OS does that. Just use a blocking read or some kind of I/O multiplexing (like select or epoll_wait). There's nothing special you need to do.

3
  • If you want blocking semantics, just remove the | O_NDELAY from OpenComport. Sep 1, 2012 at 11:13
  • I have found, what I was searching: The key word is evend based serial port dirver: sourceforge.net/projects/qspd
    – User_12399
    Sep 1, 2012 at 11:16
  • Yeah, probably a good idea to use code that does want you want in the first place. Sep 1, 2012 at 11:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.