mq_receive: size of buffer

363 Views Asked by At

is there something i failed to see?

My project crashes everytime when it come to this function:

#define SMW 29
float smw

getWert(&smw, SMW, rsq,rrq)

SMW ist the Number of the port (kanal), i want to get "smw"

int MainWindow::getWert(float *erg, int kanal, mqd_t rsq, mqd_t rrq)
{
   char *buff;
   struct mq_attr attr;

   struct mqs qmsg;
   qmsg.msg=GETDATA;
   qmsg.dat.kanal=kanal;
   qmsg.dat.typ='d';

   mmqueue mq;

   mq.sdcmd(rsq,(char *)&qmsg, sizeof(qmsg));

   mq_getattr(rrq, &attr);
   buff = (char *)malloc(attr.mq_msgsize);
    mq_receive(rrq, (char *)buff, attr.mq_msgsize, NULL);
   *erg=atof(buff);
   //qDebug()<<"GetWert"<<*erg;
   return 1;

}

attr.mq_msgsize = 8192

global.h:

struct mqs{
  unsigned int msg;
  char mess[30];
  kanaldef dat;

mmqueue.h:

class mmqueue
{
public:
    int sdcmd (mqd_t sq, char *buf, int len);
};
0

There are 0 best solutions below