Probleme With Threads.
- From: Florent Blanchon <florent blanchon gmail com>
- To: gtkmm-list gnome org
- Subject: Probleme With Threads.
- Date: Fri, 4 Sep 2009 15:45:48 +0200
Hello to all.
I've a big problem.
I'm using plotmm to display a curve (normal).
the datas I want to display come frome a ComPort (or a blocking Socket).
I've tried with a pthread mechanism, by passing main class in argument, but, when I arrive at
PlotTest->m_plot.scale(PlotMM::AXIS_LEFT)->set_range( Ymin, Ymax);
I've this message :
fatal io error 11 resource temporarily unavailable on x server 0.0
below, is the code I want to be implemented in a thread because I wait before receiving data :
Thanks for your help.
Flo
bool PlotTest::LoopReceive()
{
//PlotTest *MainLoop = (PlotTest*)pt;
double data[2000];
char cbuffer[6033];
int recu;
int taille;
int frequence;
int intcurve;
double ymax;
double ymin;
recu = 0;
memset(cbuffer, 0, 6033);
std::cout << "Top Receive" <<std::endl;
while(recu != 33)
{
recu += Rs->recv((char*)cbuffer + recu, 33 - recu);
}
taille = *(short*)&cbuffer[14];
frequence = *(short*)&cbuffer[2];
while(recu != taille)
{
recu += Rs->recv((char*)cbuffer + recu, taille - recu);
}
// 20Hz
if(taille == 93) intcurve = 20;
if(taille == 633) intcurve = 200;
// 50Hz
if(taille == 183) intcurve = 50;
if(taille == 1533) intcurve = 500;
//100Hz
if(taille == 333) intcurve = 100;
if(taille == 3033) intcurve = 1000;
Glib::Timer timer;
timer.start();
//200Hz
if(taille == 633) intcurve = 200;
if(taille == 6033) intcurve = 2000;
ymax = -G_MAXFLOAT;
ymin = G_MAXFLOAT;
for(int i = 0; i < intcurve; i++)
{
int t =0;
unsigned char *A;
A =(unsigned char*) &t;
int u = 0;
unsigned char *B;
B = (unsigned char*)&u;
*(A+3) = cbuffer[30 + 3*i]&0x80?0xff:0x00;
*(A+2) = cbuffer[30 + 3*i];
*(A+1) = cbuffer[29 + 3*i];
*(A) = cbuffer[28 + 3*i];
data[i] = t;
if(t > ymax) ymax = t;
if(t < ymin) ymin = t;
}
myCurve1->set_data(x,data,intcurve);
m_plot.scale(PlotMM::AXIS_LEFT)->set_range(ymin+ymin/10,ymax + ymax/10);
m_plot.replot();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]