Last edit: Peter Favrholdt on July 2, 2006 18:08 (1528 days, 10 hours and 8 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,
QSocketNotifier::Read);
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
available:
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.