- 論壇徽章:
- 0
|
回復(fù) 3# hellioncu - // Get the header, and check command
- memcpy(buf, line.c_str(), sizeof(GK301_header) + sizeof(GK301_login) + sizeof(GK301_tail));
- GK301_login *glg;
- glg = (GK301_login *)malloc(sizeof(GK301_login));
- memcpy(glg, buf + sizeof(GK301_header), sizeof(GK301_login));
- printf("ID=%x%x%x%x%x%x%x%x, Rec=0x%x\n", glg->id[0], glg->id[1], glg->id[2],glg->id[3],
- glg->id[4],glg->id[5],glg->id[6],glg->id[7],glg->id_num);
- // Get the tail, may be we need the serial number
- GK301_tail *gtl;
- gtl = (GK301_tail *)malloc(sizeof(GK301_tail));
- memcpy(gtl, buf + sizeof(GK301_header) + sizeof(GK301_login), sizeof(GK301_tail));
- printf("Serial=0x%x, CRC=0x%x, Stop=0x%x\n", gtl->seq, gtl->crc, gtl->stop);
- // At last, we should reply a package to the terminal device
- bzero(buf, sizeof(buf));
- memcpy(buf, line.c_str(), sizeof(GK301_header));
- memcpy(buf + sizeof(GK301_header), gtl, sizeof(GK301_tail));
- result = buf;
復(fù)制代碼 那么請(qǐng)看以上的代碼,我的處理有問(wèn)題嗎,無(wú)法獲得我想要的數(shù)據(jù)啊,只能獲得部分?jǐn)?shù)據(jù)。
 |
|