if(a->waitForReadyRead(100)) {
char *datas= new char[DATA_LEN];
a->read(datas,DATA_LEN);
/* Move the last part of the previous buffer, that was not processed,
* on the start of the new buffer. */
memcpy(data,data+DATA_LEN, (FULL_LEN-1)*4);
/* Copy the new data. */
memcpy(data+(FULL_LEN-1)*4,datas, DATA_LEN);
uint8_t *p =data;
qDebug()<<"Data: " << p[2] << (unsigned char)datas[2]<< endl; }
我使用上面的简单代码从主机读取TCP数据,但memcpy
似乎没有用。调试的输出如下:
Data: 0 128 Data: 0 126 Data: 0 126 Data: 0 126 Data: 0 128
我在线程中使用了这个循环,memcpy
之后的数据总是为0。有没有人有任何想法?
PS。 #define MODES_DATA_LEN (16*16384) /* 256k */
#define MODES_FULL_LEN 120