Last edit: Peter Favrholdt on July 2, 2006 18:08 (3922 days, 9 hours and 14 minutes ago) (diff)
Rtai.Dk | RecentChanges | Preferences | DIAPM RTAI

From the mailinglist on how to use QT and realtime fifos:
you cannot mix blocking I/O with Qt's own event handling system. The
followind code skeletton shows how you can react on incoming data on a
RT FIFO using Qt's QSocketNotifier class:
At initialization:

1. int K2UDataFifo = open("/dev/rtfX", O_RDONLY | O_NONBLOCK);

2. QSocketNotifier *Data = new QSocketNotifier(K2UDataFifo,

3. QObject::connect(Data, SIGNAL(activated(int)),
   &WhateverQObjectShouldReceiveTheSignal, SLOT(YourReadHandler()));

At programm termination:

1. close(K2UDataFifo);

Your read-handler-slot which will be called every time new data is

void WhateverQObjectShouldReceiveTheSignal::YourReadHandler(){
  read(K2UDataFifo, &YourDataStructure, sizeof(YourDataStructure));
  //process your data, ...

That is all. For writing data from user to kernel, just use write() as
you would do from any user space application.

Edit text of this page | View other revisions | Download Rtai.dk