18 #ifndef IIOTHREADEDQ_H_ 19 #define IIOTHREADEDQ_H_ 31 struct sched_param param;
32 param.sched_priority = 96;
33 if (sched_setscheduler(0, SCHED_FIFO, & param) == -1) {
34 perror(
"sched_setscheduler");
38 struct timespec lockStart, lockStop;
40 Eigen::Array<unsigned short, Eigen::Dynamic, Eigen::Dynamic> *b;
42 cout<<
"entering the thread while loop"<<endl;
45 if( clock_gettime( CLOCK_REALTIME, &lockStart) == -1 )
46 cout<<
"clock lockStart get time error"<<endl;
50 cout<<
"threadMain : Error : couldn't get a valid empty buffer - possibly dropping samples.\n";
56 int ret=
read(nframes, *b);
68 if( clock_gettime( CLOCK_REALTIME, &lockStop) == -1 )
69 cout<<
"clock lockStop get time error"<<endl;
71 double duration = 1.e3*( lockStop.tv_sec - lockStart.tv_sec ) + (
double)( lockStop.tv_nsec - lockStart.tv_nsec )/1.e6;
72 cout<<
"thread duration = "<<duration<<
'\t';
73 if (duration<(.5*(
float)nframes/
sampleRate*1.e3)){
75 usleep((
int)floor((
float)nframes*.5/
sampleRate*1.e6));
78 if( clock_gettime( CLOCK_REALTIME, &lockStop) == -1 )
79 cout<<
"clock lockStop get time error"<<endl;
81 duration = 1.e3*( lockStop.tv_sec - lockStart.tv_sec ) + (
double)( lockStop.tv_nsec - lockStart.tv_nsec )/1.e6;
82 cout<<
"thread duration now = "<<duration<<
'\n';
85 cout<<
"IIO read thread stopped due to error"<<endl;
100 Eigen::Array<unsigned short, Eigen::Dynamic, Eigen::Dynamic> b;
105 ch=(int)ceil((
float)ch/(float)
operator[](0).getChCnt());
108 cout<<
"resizing buffers to "<<b.rows()<<
" rows and "<<ch<<
" cols"<<endl;
135 #endif // IIOTHREADEDQ_H_ void putFullBuffer(Eigen::Array< unsigned short, Eigen::Dynamic, Eigen::Dynamic > *fb)
int resizeBuffers(int N, int ch)
int getReadArraySampleCount(Eigen::Array< TYPE, Eigen::Dynamic, Eigen::Dynamic > &array)
#define NO_ERROR
There is no error.
int read(uint N, const Eigen::Array< TYPE, Eigen::Dynamic, Eigen::Dynamic > &array)
The iio_channel_info structure is external.
int getReadArray(uint N, Eigen::Array< TYPE, Eigen::Dynamic, Eigen::Dynamic > &array)
int setSampleCountChannelCount(uint N, uint ch)
void resizeBuffers(int rows, int cols)
Eigen::Array< unsigned short, Eigen::Dynamic, Eigen::Dynamic > * getEmptyBuffer(void)