IMEI_entry = (FLASH_ENTRY_HEADER *)(comp_buff+sizeof(FLASH_BUFFER_HEADER)); TCMD_TRACE("Get IMEI_entry->entryType begin \n"); //TCMD_TRACE( "IMEI entryType: %u", IMEI_entry->entryType);
//TCMD_TRACE("Get IMEI_entry->entryType sucess\n");
TCMD_TRACE( "IMEI entrySize: %d -unsigned long size %d \n", IMEI_entry->entrySize,sizeof(unsigned long)); //memcpy(&IMEI_size, (comp_buff+sizeof(FLASH_BUFFER_HEADER)+4),4);//正确代码
memcpy(&IMEI_size, (IMEI_entry+4),4);//错误代码 TCMD_TRACE( "IMEI entrySize: %u\n", IMEI_size); TCMD_TRACE( "IMEI entryName: %s \n", IMEI_entry->fileName); TCMD_TRACE( "sizeof(FLASH_ENTRY_HEADER): %d\n",izeof(FLASH_ENTRY_HEADER));
//memcpy(IMEI_NO, IMEI_entry+sizeof(FLASH_ENTRY_HEADER), IMEI_entry->entrySize );
memcpy(IMEI_NO, IMEI_entry+8, IMEI_entry->entrySize ); for( i=0; i<40; i++ ) TCMD_TRACE( "IMEI_NO[%d] = %d 0x%x\n", i, IMEI_NO[i],IMEI_NO[i] );
TCMD_TRACE( "IMEI_NO array size is %d content: %s IMEI entrySize: %d\n ", strlen(IMEI_NO),IMEI_NO,IMEI_entry->entrySize);
|
主要是要得到IMEI号,但是memcpy(&IMEI_size, (IMEI_entry+4),4);
前已经把IMEI_entry指针加4,相当于加4个IMEI_entry所指的大小字节,而不是4个字节,这一点浪费了我有半天的时间才找到,正确的做法是memcpy(&IMEI_size, (comp_buff+sizeof(FLASH_BUFFER_HEADER)+4),4);//正确代码
,而不是原来的加4。
做一个opcode时竞然不知到取地址符&的用法。
也改了半天。比如int a=8;
int *b;
memcpy(b, a, sizeof(int) );
是错误的,应该第二个参数是指针,但我没想起&,而是用memcpy(b, (int *)a, sizeof(int) );这样也报错,
正确的做法是memcpy(b, &a, sizeof(int) );
阅读(1263) | 评论(0) | 转发(0) |