0

有什么我没看到的吗?

每次涉及此功能时,我的项目都会崩溃:

#define SMW 29
float smw

getWert(&smw, SMW, rsq,rrq)

SMW 是端口号(kanal),我想得到“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

全球.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);
};
4

0 回答 0