00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047 #include "../FEDM.h"
00048 #include "FEDM_BRMTabItem.h"
00049 #include "FEDM_ISCReader.h"
00050
00051 #if _MSC_VER >= 1400
00052 #pragma warning(disable : 4996)
00053 #endif
00054
00055
00056
00057
00058
00059
00060
00061 FEDM_BRMTabItem::FEDM_BRMTabItem()
00062 {
00063 m_iRxDB_BlockCount = 256;
00064 m_iRxDB_BlockSize = 4;
00065
00066 m_uiTabIndex = 0;
00067
00068 for(int i=0; i<4; i++)
00069 m_ucRxDB_TidBank[i] = 0;
00070 }
00071
00072 FEDM_BRMTabItem::FEDM_BRMTabItem(unsigned int uiTabIndex)
00073 {
00074 m_iRxDB_BlockCount = 256;
00075 m_iRxDB_BlockSize = 4;
00076
00077 m_uiTabIndex = uiTabIndex;
00078 }
00079
00080 FEDM_BRMTabItem::~FEDM_BRMTabItem()
00081 {
00082 m_ucRxDB.clear();
00083 }
00084
00085 void FEDM_BRMTabItem::Init()
00086 {
00087 m_iRxDB_BlockCount = 256;
00088 m_iRxDB_BlockSize = 4;
00089
00090 for(int i=0; i<4; i++)
00091 m_ucRxDB_TidBank[i] = 0;
00092
00093 if(m_ucRxDB.size() != FEDM_ISC_BRM_TABLE_RxDB_SIZE)
00094 {
00095 m_ucRxDB.reserve(FEDM_ISC_BRM_TABLE_RxDB_SIZE);
00096 m_ucRxDB.resize(FEDM_ISC_BRM_TABLE_RxDB_SIZE);
00097 }
00098
00099 memset(m_ucSnr, 0, FEDM_ISC_MAX_UID_LENGTH);
00100 memset(m_ucClass1Gen2_PC, 0, 2);
00101 memset(m_ucClass1Gen2_XPC_W1, 0, 2);
00102 memset(m_ucTimer, 0, 4);
00103 memset(m_ucDate, 0, 5);
00104 memset(m_ucMacAddress, 0, 6);
00105 memset(&m_ucRxDB[0], 0, FEDM_ISC_BRM_TABLE_RxDB_SIZE);
00106
00107 m_ucAFI = 0;
00108 m_ucDsfID = 0;
00109 m_ucDBAdr = 0;
00110 m_uiDBN = 0;
00111 m_ucTrType = 0xFF;
00112 m_ucEpcType = 0x00;
00113 m_ucIDDT = 0;
00114 m_ucSnrLen = 8;
00115 m_ucBlockSize = 4;
00116 m_ucAntNr = 0;
00117 m_ucDirection = 0;
00118
00119 m_bIsSnr = false;
00120 m_bIsEpc = false;
00121 m_bIsAFI = false;
00122 m_bIsDB = false;
00123 m_bIsTimer = false;
00124 m_bIsDate = false;
00125 m_bIsAntNr = false;
00126 m_bIsInput = false;
00127 m_bIsRSSI = false;
00128 m_bIsMacAddr = false;
00129 m_bIsDirection = false;
00130 m_ucInput = 0;
00131 m_ucState = 0;
00132
00133 ClearAntennaValues();
00134 }
00135
00136
00137 void FEDM_BRMTabItem::Init(int iRxDB_BlockCount, int iRxDB_BlockSize)
00138 {
00139 m_iRxDB_BlockCount = iRxDB_BlockCount;
00140 m_iRxDB_BlockSize = iRxDB_BlockSize;
00141
00142 for(int i=0; i<4; i++)
00143 m_ucRxDB_TidBank[i] = 0;
00144
00145 if(m_ucRxDB.size() != iRxDB_BlockCount * iRxDB_BlockSize)
00146 {
00147 m_ucRxDB.reserve(iRxDB_BlockCount * iRxDB_BlockSize);
00148 m_ucRxDB.resize(iRxDB_BlockCount * iRxDB_BlockSize);
00149 }
00150
00151 memset(m_ucSnr, 0, FEDM_ISC_MAX_UID_LENGTH);
00152 memset(m_ucClass1Gen2_PC, 0, 2);
00153 memset(m_ucClass1Gen2_XPC_W1, 0, 2);
00154 memset(m_ucTimer, 0, 4);
00155 memset(m_ucDate, 0, 5);
00156 memset(m_ucMacAddress, 0, 6);
00157 memset(&m_ucRxDB[0], 0, iRxDB_BlockCount * iRxDB_BlockSize);
00158
00159 m_ucAFI = 0;
00160 m_ucDsfID = 0;
00161 m_ucDBAdr = 0;
00162 m_uiDBN = 0;
00163 m_ucTrType = 0xFF;
00164 m_ucEpcType = 0x00;
00165 m_ucIDDT = 0;
00166 m_ucSnrLen = 8;
00167 m_ucBlockSize = 4;
00168 m_ucAntNr = 0;
00169 m_ucInput = 0;
00170 m_ucState = 0;
00171 m_ucDirection = 0;
00172
00173 m_bIsSnr = false;
00174 m_bIsEpc = false;
00175 m_bIsAFI = false;
00176 m_bIsDB = false;
00177 m_bIsTimer = false;
00178 m_bIsDate = false;
00179 m_bIsAntNr = false;
00180 m_bIsInput = false;
00181 m_bIsRSSI = false;
00182 m_bIsMacAddr = false;
00183 m_bIsDirection = false;
00184
00185 ClearAntennaValues();
00186 }
00187
00188 void FEDM_BRMTabItem::GetTableSizes(int& iRxDB_BlockCount, int& iRxDB_BlockSize)
00189 {
00190 iRxDB_BlockCount = m_iRxDB_BlockCount;
00191 iRxDB_BlockSize = m_iRxDB_BlockSize;
00192 }
00193
00194 void FEDM_BRMTabItem::ClearAntennaValues()
00195 {
00196 m_ucFlags = 0;
00197 m_ucAntCount = 0;
00198 memset(&m_ucAntNumber[0], 0, FEDM_ISC_BRM_TABLE_MAX_ANTENNA);
00199 memset(&m_ucAntRSSI[0], 0, FEDM_ISC_BRM_TABLE_MAX_ANTENNA);
00200 memset(&m_ucAntRes1[0], 0, FEDM_ISC_BRM_TABLE_MAX_ANTENNA);
00201 }
00202
00203 bool FEDM_BRMTabItem::IsExtendedPC_W1()
00204 {
00205 if(m_ucClass1Gen2_PC[0] & 0x02)
00206 return true;
00207 else
00208 return false;
00209 }
00210
00211
00212
00213 __int64 FEDM_BRMTabItem::GetSnr()
00214 {
00215 __int64 i64Snr = 0;
00216
00217
00218 for ( int i=0; i<8; i++ )
00219 i64Snr += ( (__int64)m_ucSnr[7-i] << (8*i) );
00220
00221 return i64Snr;
00222 }
00223
00224 int FEDM_BRMTabItem::GetEpc(char* cEpc, int iBufLen)
00225 {
00226 if(! m_bIsEpc)
00227 return FEDM_ERROR_NOT_AN_EPC;
00228
00229 switch(m_ucEpcType)
00230 {
00231 case FEDM_ISC_EPC_TYPE_1:
00232 if(iBufLen < 28)
00233 return FEDM_ERROR_BUFFER_LENGTH;
00234
00235 sprintf(cEpc, "%02X.%07lX.%06lX.%09llX", GetEpcHeader(), (unsigned long)GetEpcDomainManager(), (unsigned long)GetEpcObjectClass(), GetEpcSnr());
00236 break;
00237
00238 case FEDM_ISC_EPC_TYPE_2:
00239 if(iBufLen < 23)
00240 return FEDM_ERROR_BUFFER_LENGTH;
00241
00242 sprintf(cEpc, "%02X.%06lX.%05lX.%06lX", GetEpcHeader(), (unsigned long)GetEpcDomainManager(), (unsigned long)GetEpcObjectClass(), (unsigned long)GetEpcSnr());
00243 break;
00244
00245 case FEDM_ISC_EPC_TYPE_3:
00246 if(iBufLen < 23)
00247 return FEDM_ERROR_BUFFER_LENGTH;
00248
00249 sprintf(cEpc, "%02X.%04lX.%04lX.%09llX", GetEpcHeader(), (unsigned long)GetEpcDomainManager(), (unsigned long)GetEpcObjectClass(), GetEpcSnr());
00250 break;
00251
00252 case FEDM_ISC_EPC_TYPE_4:
00253 if(iBufLen < 23)
00254 return FEDM_ERROR_BUFFER_LENGTH;
00255
00256 sprintf(cEpc, "%02X.%07lX.%04lX.%08lX", GetEpcHeader(), (unsigned long)GetEpcDomainManager(), (unsigned long)GetEpcObjectClass(), (unsigned long)GetEpcSnr());
00257 break;
00258
00259 default:
00260 return FEDM_ERROR_UNKNOWN_EPC_TYPE;
00261 }
00262
00263 return FEDM_OK;
00264 }
00265
00266 int FEDM_BRMTabItem::GetEpcRaw(unsigned char* cEpc, int iBufLen)
00267 {
00268 if(! m_bIsEpc)
00269 return FEDM_ERROR_NOT_AN_EPC;
00270
00271 switch(m_ucEpcType)
00272 {
00273 case FEDM_ISC_EPC_TYPE_1:
00274 if(iBufLen < 12)
00275 return FEDM_ERROR_BUFFER_LENGTH;
00276
00277 memcpy(cEpc, (const char*)m_ucSnr, 12);
00278 break;
00279
00280 case FEDM_ISC_EPC_TYPE_2:
00281 case FEDM_ISC_EPC_TYPE_3:
00282 case FEDM_ISC_EPC_TYPE_4:
00283 if(iBufLen < 8)
00284 return FEDM_ERROR_BUFFER_LENGTH;
00285
00286 memcpy(cEpc, (const char*)m_ucSnr, 8);
00287 break;
00288
00289 default:
00290 return FEDM_ERROR_UNKNOWN_EPC_TYPE;
00291 }
00292
00293 return FEDM_OK;
00294 }
00295
00296 int FEDM_BRMTabItem::GetEpcHeader()
00297 {
00298 if(! m_bIsEpc)
00299 return FEDM_ERROR_NOT_AN_EPC;
00300
00301 switch(m_ucEpcType)
00302 {
00303 case FEDM_ISC_EPC_TYPE_1:
00304 return m_ucSnr[0];
00305 case FEDM_ISC_EPC_TYPE_2:
00306 return ((m_ucSnr[0]&0xC0)>>6);
00307 case FEDM_ISC_EPC_TYPE_3:
00308 return ((m_ucSnr[0]&0xC0)>>6);
00309 case FEDM_ISC_EPC_TYPE_4:
00310 return ((m_ucSnr[0]&0xC0)>>6);
00311 }
00312
00313 return FEDM_ERROR_UNKNOWN_EPC_TYPE;
00314 }
00315
00316 __int64 FEDM_BRMTabItem::GetEpcDomainManager()
00317 {
00318 if(! m_bIsEpc)
00319 return FEDM_ERROR_NOT_AN_EPC;
00320
00321 switch(m_ucEpcType)
00322 {
00323 case FEDM_ISC_EPC_TYPE_1:
00324 return (((__int64)m_ucSnr[1]<<20) + ((__int64)m_ucSnr[2]<<12) + ((__int64)m_ucSnr[3]<<4) + ((__int64)(m_ucSnr[4]&0xF0)>>4));
00325 case FEDM_ISC_EPC_TYPE_2:
00326 return (((__int64)(m_ucSnr[0]&0x3F)<<15) + ((__int64)m_ucSnr[1]<<7) + ((__int64)(m_ucSnr[2]&0xFE)>>1));
00327 case FEDM_ISC_EPC_TYPE_3:
00328 return (((__int64)(m_ucSnr[0]&0x3F)<<9) + ((__int64)m_ucSnr[1]<<1) + ((__int64)(m_ucSnr[2]&0x80)>>7));
00329 case FEDM_ISC_EPC_TYPE_4:
00330 return (((__int64)(m_ucSnr[0]&0x3F)<<20) + ((__int64)m_ucSnr[1]<<12) + ((__int64)m_ucSnr[2]<<4) + ((__int64)(m_ucSnr[3]&0xF0)>>4));
00331 }
00332
00333 return FEDM_ERROR_UNKNOWN_EPC_TYPE;
00334 }
00335
00336 __int64 FEDM_BRMTabItem::GetEpcObjectClass()
00337 {
00338 if(! m_bIsEpc)
00339 return FEDM_ERROR_NOT_AN_EPC;
00340
00341 switch(m_ucEpcType)
00342 {
00343 case FEDM_ISC_EPC_TYPE_1:
00344 return (((m_ucSnr[4]&0x0F)<<20) + (m_ucSnr[5]<<12) + (m_ucSnr[6]<<4) + ((m_ucSnr[7]&0xF0)>>4));
00345 case FEDM_ISC_EPC_TYPE_2:
00346 return (((m_ucSnr[2]&0x01)<<16) + (m_ucSnr[3]<<8) + m_ucSnr[4]);
00347 case FEDM_ISC_EPC_TYPE_3:
00348 return (((m_ucSnr[2]&0x7F)<<6) + ((m_ucSnr[3]&0xFC)>>2));
00349 case FEDM_ISC_EPC_TYPE_4:
00350 return (((m_ucSnr[3]&0x0F)<<9) + (m_ucSnr[4]<<1) + ((m_ucSnr[5]&0x80)>>7));
00351 }
00352
00353 return FEDM_ERROR_UNKNOWN_EPC_TYPE;
00354 }
00355
00356 __int64 FEDM_BRMTabItem::GetEpcSnr()
00357 {
00358 __int64 i64Data = 0;
00359
00360 if(! m_bIsEpc)
00361 return FEDM_ERROR_NOT_AN_EPC;
00362
00363 switch(m_ucEpcType)
00364 {
00365 case FEDM_ISC_EPC_TYPE_1:
00366 i64Data = (((__int64)(m_ucSnr[7]&0x0F))<<32) + (((__int64)(m_ucSnr[8]))<<24) + (m_ucSnr[9]<<16) + (m_ucSnr[10]<<8) + m_ucSnr[11];
00367 break;
00368 case FEDM_ISC_EPC_TYPE_2:
00369 i64Data = (m_ucSnr[5]<<16) + (m_ucSnr[6]<<8) + m_ucSnr[7];
00370 break;
00371 case FEDM_ISC_EPC_TYPE_3:
00372 i64Data = ((__int64)(m_ucSnr[3]&0x03)<<32) + (m_ucSnr[4]<<24) + (m_ucSnr[5]<<16) + (m_ucSnr[6]<<8) + m_ucSnr[7];
00373 break;
00374 case FEDM_ISC_EPC_TYPE_4:
00375 i64Data = ((m_ucSnr[5]&0x7F)<<16) + (m_ucSnr[6]<<8) + m_ucSnr[7];
00376 break;
00377 default:
00378 return FEDM_ERROR_UNKNOWN_EPC_TYPE;
00379 }
00380
00381 return i64Data;
00382 }
00383
00384
00385 const char* FEDM_BRMTabItem::GetISO15693Manufacturer()
00386 {
00387 if(m_ucTrType == FEDM_ISC_TR_TYPE_ISO15693)
00388 {
00389 return FEDM_TabItem::GetISO15693Manufacturer(m_ucSnr[1]);
00390 }
00391
00392 return "";
00393 }
00394
00395
00396
00397
00398
00399
00400
00401
00402
00403
00404
00405
00406
00407
00408
00409
00410
00411
00412
00413
00414
00415
00416
00417
00418
00419
00420
00421
00422 unsigned int FEDM_BRMTabItem::GetEpcC1G2TagModelNumber()
00423 {
00424 if( m_ucTrType == FEDM_ISC_TR_TYPE_ISO18000_3M3 ||
00425 m_ucTrType == FEDM_ISC_TR_TYPE_EPC_CLASS1_GEN2 )
00426 {
00427 switch(m_ucRxDB_TidBank[1])
00428 {
00429 case 0xE0:
00430 case 0xE3:
00431 break;
00432 case 0xE2:
00433 return (((unsigned int)(m_ucRxDB_TidBank[3] & 0x0F)) << 8) + m_ucRxDB_TidBank[2];
00434 }
00435 }
00436
00437 return 0xFFFFFFFF;
00438
00439 }
00440
00441 unsigned int FEDM_BRMTabItem::GetEpcC1G2MaskDesignerID()
00442 {
00443 if( m_ucTrType == FEDM_ISC_TR_TYPE_ISO18000_3M3 ||
00444 m_ucTrType == FEDM_ISC_TR_TYPE_EPC_CLASS1_GEN2 )
00445 {
00446 switch(m_ucRxDB_TidBank[1])
00447 {
00448 case 0xE0:
00449 case 0xE3:
00450 return (unsigned int)m_ucRxDB_TidBank[0];
00451 case 0xE2:
00452 return (((unsigned int)(m_ucRxDB_TidBank[0] & 0x1F)) << 4) + ((m_ucRxDB_TidBank[3] & 0xF0) >> 4);
00453 }
00454 }
00455
00456 return 0xFFFFFFFF;
00457 }
00458
00459 const char* FEDM_BRMTabItem::GetEpcC1G2MaskDesignerName()
00460 {
00461 unsigned int uiMDID = 0;
00462
00463 if( m_ucTrType == FEDM_ISC_TR_TYPE_ISO18000_3M3 ||
00464 m_ucTrType == FEDM_ISC_TR_TYPE_EPC_CLASS1_GEN2 )
00465 {
00466 switch(m_ucRxDB_TidBank[1])
00467 {
00468 case 0xE0:
00469 case 0xE3:
00470 return FEDM_TabItem::GetISO15693Manufacturer(m_ucRxDB_TidBank[0]);
00471 case 0xE2:
00472 uiMDID = ((m_ucRxDB_TidBank[0] & 0x1F) << 4) + ((m_ucRxDB_TidBank[3] & 0xF0) >> 4);
00473 return FEDM_TabItem::GetEpcC1G2MaskDesignerName(uiMDID);
00474 }
00475 }
00476
00477 return "";
00478 }
00479
00480
00481
00482
00483
00484
00485
00486
00487
00488
00489
00490
00491
00492
00493
00494
00495
00496
00497
00498 int FEDM_BRMTabItem::SetData(unsigned char ucCmd, unsigned char* ucData, unsigned char* ucTrData, unsigned int& uiByteCnt)
00499 {
00500 int iCnt;
00501 int iErr = 0;
00502 unsigned int uiRecLen = 0;
00503 unsigned int uiByteCntBegin = uiByteCnt;
00504
00505 if(ucCmd == 0x22)
00506 {
00507 uiRecLen = (ucData[uiByteCnt++] << 8);
00508 uiRecLen += ucData[uiByteCnt++];
00509 }
00510
00511 if(ucCmd == 0x74)
00512 {
00513 if( (ucTrData[0]&0x80) && (ucTrData[1]&0x01) )
00514 {
00515 m_ucInput = ucData[uiByteCnt++];
00516 m_bIsInput = true;
00517 return FEDM_OK;
00518 }
00519 }
00520
00521 if( (ucTrData[0]&0x01) == 0x01 )
00522 {
00523 switch(ucCmd)
00524 {
00525 case 0x21:
00526 FEDM_CHK1(iErr, SetSnr_0x21(ucData, uiByteCnt));
00527 break;
00528 case 0x22:
00529 FEDM_CHK1(iErr, SetSnr_0x22(ucTrData, ucData, uiByteCnt));
00530 break;
00531 }
00532 }
00533
00534 if( (ucTrData[0]&0x02) == 0x02 )
00535 {
00536 if(ucCmd == 0x21)
00537 {
00538 m_ucDBAdr = ucData[uiByteCnt++];
00539 m_uiDBN = ucData[uiByteCnt++];
00540 }
00541 else if(ucCmd == 0x22)
00542 {
00543 m_uiDBN = (ucData[uiByteCnt++] << 8);
00544 m_uiDBN += ucData[uiByteCnt++];
00545 }
00546
00547 if(ucCmd == 0x22)
00548 m_ucBlockSize = ucData[uiByteCnt++];
00549
00550 if( ((int)FEDM_ISC_BRM_TABLE_RxDB_SIZE - (int)(m_ucDBAdr + m_uiDBN)*m_ucBlockSize) < 0)
00551 return FEDM_ERROR_ARRAY_BOUNDARY;
00552
00553 for(unsigned int uiBlockNr=m_ucDBAdr; uiBlockNr<m_ucDBAdr+m_uiDBN; ++uiBlockNr)
00554 {
00555 for(iCnt=0; iCnt<m_ucBlockSize; iCnt++)
00556 m_ucRxDB[uiBlockNr*m_ucBlockSize+iCnt] = ucData[uiByteCnt++];
00557 }
00558
00559 m_bIsDB = true;
00560 }
00561
00562 if( (ucTrData[0]&0x20) == 0x20 )
00563 {
00564 for(iCnt=0; iCnt<4; iCnt++)
00565 m_ucTimer[iCnt] = ucData[uiByteCnt++];
00566
00567 m_bIsTimer = true;
00568 }
00569
00570 if( (ucTrData[0]&0x40) == 0x40 )
00571 {
00572 for(iCnt=0; iCnt<5; iCnt++)
00573 m_ucDate[iCnt] = ucData[uiByteCnt++];
00574
00575 m_bIsDate = true;
00576 }
00577
00578 if( (ucTrData[0]&0x10) == 0x10 )
00579 {
00580 m_ucAntNr = ucData[uiByteCnt++];
00581
00582 m_bIsAntNr = true;
00583 }
00584
00585 if(ucCmd == 0x22)
00586 {
00587 if( (ucTrData[0]&0x80) && (ucTrData[1]&0x01) )
00588 {
00589 m_ucInput = ucData[uiByteCnt++];
00590 m_ucState = ucData[uiByteCnt++];
00591
00592 m_bIsInput = true;
00593 }
00594 }
00595
00596 if(ucCmd == 0x22)
00597 {
00598 if( (ucTrData[0]&0x80) && (ucTrData[1]&0x02) )
00599 {
00600 memcpy(m_ucMacAddress, &ucData[uiByteCnt], 6);
00601 uiByteCnt += 6;
00602
00603 m_bIsMacAddr = true;
00604 }
00605 }
00606
00607 if(ucCmd == 0x22)
00608 {
00609 if( (ucTrData[0]&0x80) && (ucTrData[1]&0x10) )
00610 {
00611 m_ucAntCount = ucData[uiByteCnt++];
00612 if(m_ucAntCount > FEDM_ISC_BRM_TABLE_MAX_ANTENNA)
00613 return FEDM_ERROR_ARRAY_BOUNDARY;
00614
00615 for(iCnt=0; iCnt<m_ucAntCount; iCnt++)
00616 {
00617 m_ucAntNumber[iCnt] = ucData[uiByteCnt++];
00618 m_ucAntRSSI[iCnt] = ucData[uiByteCnt++];
00619 m_ucAntRes1[iCnt] = ucData[uiByteCnt++];
00620 uiByteCnt += 3;
00621 }
00622
00623 m_bIsRSSI = true;
00624 }
00625 }
00626
00627 if(ucCmd == 0x22)
00628 {
00629 if( (ucTrData[0]&0x80) && (ucTrData[1]&0x20) )
00630 {
00631 m_ucDirection = ucData[uiByteCnt++];
00632
00633 m_bIsDirection = true;
00634 }
00635 }
00636
00637 if(ucCmd == 0x22)
00638 {
00639
00640 if(uiByteCnt > uiByteCntBegin && (uiByteCnt - uiByteCntBegin) < uiRecLen)
00641 uiByteCnt += uiRecLen - (uiByteCnt - uiByteCntBegin);
00642 }
00643
00644 return FEDM_OK;
00645 }
00646
00647 int FEDM_BRMTabItem::SetSnr_0x21(unsigned char* ucData, unsigned int& uiByteCnt)
00648 {
00649 int iCnt;
00650 unsigned char ucHeader = 0;
00651
00652 memset(m_ucSnr, 0, FEDM_ISC_MAX_UID_LENGTH);
00653 m_ucTrType = ucData[uiByteCnt++];
00654
00655
00656 switch(m_ucTrType)
00657 {
00658 case FEDM_ISC_TR_TYPE_ICODE1:
00659 case FEDM_ISC_TR_TYPE_TAGIT:
00660 case FEDM_ISC_TR_TYPE_ISO15693:
00661 case FEDM_ISC_TR_TYPE_ISO14443A:
00662 case FEDM_ISC_TR_TYPE_ISO14443B:
00663
00664 case FEDM_ISC_TR_TYPE_ICODE_UID:
00665 case FEDM_ISC_TR_TYPE_JEWEL:
00666 m_ucSnrLen = 8;
00667 for(iCnt=0; iCnt<8; iCnt++)
00668 m_ucSnr[iCnt] = ucData[uiByteCnt++];
00669
00670 break;
00671
00672 case FEDM_ISC_TR_TYPE_EPC:
00673 m_ucIDDT = 0x01;
00674 m_bIsEpc = true;
00675 ucHeader = (ucData[uiByteCnt] & 0xC0) >> 6;
00676 switch(ucHeader)
00677 {
00678 case FEDM_ISC_EPC_TYPE_1:
00679 m_ucSnrLen = 12;
00680 m_ucEpcType = FEDM_ISC_EPC_TYPE_1;
00681 for(iCnt=0; iCnt<12; iCnt++)
00682 m_ucSnr[iCnt] = ucData[uiByteCnt++];
00683 break;
00684
00685 case FEDM_ISC_EPC_TYPE_2:
00686 m_ucSnrLen = 8;
00687 m_ucEpcType = FEDM_ISC_EPC_TYPE_2;
00688 for(iCnt=0; iCnt<8; iCnt++)
00689 m_ucSnr[iCnt] = ucData[uiByteCnt++];
00690 break;
00691
00692 case FEDM_ISC_EPC_TYPE_3:
00693 m_ucSnrLen = 8;
00694 m_ucEpcType = FEDM_ISC_EPC_TYPE_3;
00695 for(iCnt=0; iCnt<8; iCnt++)
00696 m_ucSnr[iCnt] = ucData[uiByteCnt++];
00697 break;
00698
00699 case FEDM_ISC_EPC_TYPE_4:
00700 m_ucSnrLen = 8;
00701 m_ucEpcType = FEDM_ISC_EPC_TYPE_4;
00702 for(iCnt=0; iCnt<8; iCnt++)
00703 m_ucSnr[iCnt] = ucData[uiByteCnt++];
00704 break;
00705 }
00706
00707 break;
00708
00709 default:
00710 m_ucSnrLen = 8;
00711 for(iCnt=0; iCnt<8; iCnt++)
00712 m_ucSnr[iCnt] = ucData[uiByteCnt++];
00713
00714 break;
00715 }
00716
00717 m_bIsSnr = true;
00718 return FEDM_OK;
00719 }
00720
00721 int FEDM_BRMTabItem::SetSnr_0x22(unsigned char* ucTrData, unsigned char* ucData, unsigned int& uiByteCnt)
00722 {
00723 int iCnt;
00724 unsigned char ucHeader = 0;
00725 unsigned char ucEpcLen = 0;
00726
00727 memset(m_ucSnr, 0, FEDM_ISC_MAX_UID_LENGTH);
00728 m_ucTrType = ucData[uiByteCnt++];
00729
00730 if(! (m_ucTrType & 0x80))
00731 {
00732 switch(m_ucTrType)
00733 {
00734 case FEDM_ISC_TR_TYPE_ISO15693:
00735 m_ucIDDT = ucData[uiByteCnt++];
00736 if(ucTrData[1] & 0x04)
00737 m_ucSnrLen = ucData[uiByteCnt++] - 2;
00738 else
00739 m_ucSnrLen = ucData[uiByteCnt++];
00740
00741 if(m_ucSnrLen > FEDM_ISC_MAX_UID_LENGTH)
00742 return FEDM_ERROR_ARRAY_BOUNDARY;
00743
00744 if(ucTrData[1] & 0x04)
00745 {
00746 m_ucAFI = ucData[uiByteCnt++];
00747 m_ucDsfID = ucData[uiByteCnt++];
00748 m_bIsAFI = true;
00749 }
00750
00751 for(iCnt=0; iCnt<(int)m_ucSnrLen; iCnt++)
00752 m_ucSnr[iCnt] = ucData[uiByteCnt++];
00753
00754 if(m_ucSnrLen > 0)
00755 m_bIsSnr = true;
00756
00757 break;
00758
00759 case FEDM_ISC_TR_TYPE_ICODE1:
00760 case FEDM_ISC_TR_TYPE_TAGIT:
00761 case FEDM_ISC_TR_TYPE_ISO14443A:
00762 case FEDM_ISC_TR_TYPE_ISO14443B:
00763
00764 case FEDM_ISC_TR_TYPE_ICODE_UID:
00765 case FEDM_ISC_TR_TYPE_JEWEL:
00766 case FEDM_ISC_TR_TYPE_MCRFxxx:
00767 m_ucIDDT = ucData[uiByteCnt++];
00768 m_ucSnrLen = ucData[uiByteCnt++];
00769
00770 if(m_ucSnrLen > FEDM_ISC_MAX_UID_LENGTH)
00771 return FEDM_ERROR_ARRAY_BOUNDARY;
00772
00773 for(iCnt=0; iCnt<(int)m_ucSnrLen; iCnt++)
00774 m_ucSnr[iCnt] = ucData[uiByteCnt++];
00775
00776 if(m_ucSnrLen > 0)
00777 m_bIsSnr = true;
00778
00779 break;
00780
00781 case FEDM_ISC_TR_TYPE_EPC:
00782 m_ucIDDT = ucData[uiByteCnt++];
00783 m_ucSnrLen = ucData[uiByteCnt++];
00784
00785 if(m_ucSnrLen > FEDM_ISC_MAX_UID_LENGTH)
00786 return FEDM_ERROR_ARRAY_BOUNDARY;
00787
00788 for(iCnt=0; iCnt<(int)m_ucSnrLen; iCnt++)
00789 m_ucSnr[iCnt] = ucData[uiByteCnt++];
00790
00791 m_bIsEpc = true;
00792 ucHeader = (m_ucSnr[0] & 0xC0) >> 6;
00793 switch(ucHeader)
00794 {
00795 case FEDM_ISC_EPC_TYPE_1:
00796 m_ucEpcType = FEDM_ISC_EPC_TYPE_1;
00797 break;
00798
00799 case FEDM_ISC_EPC_TYPE_2:
00800 m_ucEpcType = FEDM_ISC_EPC_TYPE_2;
00801 break;
00802
00803 case FEDM_ISC_EPC_TYPE_3:
00804 m_ucEpcType = FEDM_ISC_EPC_TYPE_3;
00805 break;
00806
00807 case FEDM_ISC_EPC_TYPE_4:
00808 m_ucEpcType = FEDM_ISC_EPC_TYPE_4;
00809 break;
00810 }
00811
00812 if(m_ucSnrLen > 0)
00813 m_bIsSnr = true;
00814
00815 break;
00816
00817 case FEDM_ISC_TR_TYPE_ISO18000_3M3:
00818 m_ucIDDT = ucData[uiByteCnt++];
00819 m_ucSnrLen = ucData[uiByteCnt++] - 2;
00820
00821 if(m_ucSnrLen > FEDM_ISC_MAX_UID_LENGTH)
00822 return FEDM_ERROR_ARRAY_BOUNDARY;
00823
00824 m_ucClass1Gen2_PC[0] = ucData[uiByteCnt++];
00825 m_ucClass1Gen2_PC[1] = ucData[uiByteCnt++];
00826
00827
00828 if(m_ucClass1Gen2_PC[0] & 0x02)
00829 {
00830 m_ucClass1Gen2_XPC_W1[0] = ucData[uiByteCnt++];
00831 m_ucClass1Gen2_XPC_W1[1] = ucData[uiByteCnt++];
00832 m_ucSnrLen -= 2;
00833 }
00834
00835 for(iCnt=0; iCnt<(int)m_ucSnrLen; iCnt++)
00836 m_ucSnr[iCnt] = ucData[uiByteCnt++];
00837
00838 if(m_ucSnrLen > 0)
00839 m_bIsSnr = true;
00840
00841 if(m_ucIDDT == 0x01)
00842 {
00843 ucHeader = (m_ucSnr[0] & 0xC0) >> 6;
00844 switch(ucHeader)
00845 {
00846 case FEDM_ISC_EPC_TYPE_1:
00847 m_ucEpcType = FEDM_ISC_EPC_TYPE_1;
00848 m_bIsEpc = true;
00849 break;
00850
00851 case FEDM_ISC_EPC_TYPE_2:
00852 m_ucEpcType = FEDM_ISC_EPC_TYPE_2;
00853 m_bIsEpc = true;
00854 break;
00855
00856 case FEDM_ISC_EPC_TYPE_3:
00857 m_ucEpcType = FEDM_ISC_EPC_TYPE_3;
00858 m_bIsEpc = true;
00859 break;
00860
00861 case FEDM_ISC_EPC_TYPE_4:
00862 m_ucEpcType = FEDM_ISC_EPC_TYPE_4;
00863 m_bIsEpc = true;
00864 break;
00865 }
00866 }
00867 else if(m_ucIDDT == 0x02)
00868 {
00869
00870 ucEpcLen = ((m_ucClass1Gen2_PC[0] & 0xF8) >> 3) * 2;
00871 if( ucEpcLen < m_ucSnrLen && (m_ucSnrLen - ucEpcLen) >= 4)
00872 {
00873
00874 m_ucRxDB_TidBank[1] = m_ucSnr[ucEpcLen];
00875 m_ucRxDB_TidBank[0] = m_ucSnr[ucEpcLen+1];
00876 m_ucRxDB_TidBank[3] = m_ucSnr[ucEpcLen+2];
00877 m_ucRxDB_TidBank[2] = m_ucSnr[ucEpcLen+3];
00878 }
00879 }
00880 break;
00881
00882 case FEDM_ISC_TR_TYPE_KEYBOARD:
00883 m_ucSnrLen = ucData[uiByteCnt++];
00884
00885 if(m_ucSnrLen > FEDM_ISC_MAX_UID_LENGTH)
00886 return FEDM_ERROR_ARRAY_BOUNDARY;
00887
00888 for(iCnt=0; iCnt<(int)m_ucSnrLen; iCnt++)
00889 m_ucSnr[iCnt] = ucData[uiByteCnt++];
00890
00891 if(m_ucSnrLen > 0)
00892 m_bIsSnr = true;
00893
00894 break;
00895
00896 default:
00897 m_ucIDDT = ucData[uiByteCnt++];
00898 m_ucSnrLen = ucData[uiByteCnt++];
00899
00900 if(m_ucSnrLen > FEDM_ISC_MAX_UID_LENGTH)
00901 return FEDM_ERROR_ARRAY_BOUNDARY;
00902
00903 for(iCnt=0; iCnt<(int)m_ucSnrLen; iCnt++)
00904 m_ucSnr[iCnt] = ucData[uiByteCnt++];
00905
00906 if(m_ucSnrLen > 0)
00907 m_bIsSnr = true;
00908
00909 break;
00910 }
00911 }
00912 else if(m_ucTrType & 0x80)
00913 {
00914 switch(m_ucTrType)
00915 {
00916 case FEDM_ISC_TR_TYPE_ISO18000_6_A:
00917 case FEDM_ISC_TR_TYPE_ISO18000_6_B:
00918 case FEDM_ISC_TR_TYPE_EM4222:
00919 m_ucIDDT = ucData[uiByteCnt++];
00920 m_ucSnrLen = ucData[uiByteCnt++];
00921
00922 if(m_ucSnrLen > FEDM_ISC_MAX_UID_LENGTH)
00923 return FEDM_ERROR_ARRAY_BOUNDARY;
00924
00925 for(iCnt=0; iCnt<(int)m_ucSnrLen; iCnt++)
00926 m_ucSnr[iCnt] = ucData[uiByteCnt++];
00927
00928 if(m_ucSnrLen > 0)
00929 m_bIsSnr = true;
00930
00931 break;
00932
00933 case FEDM_ISC_TR_TYPE_EPC_CLASS0:
00934 case FEDM_ISC_TR_TYPE_EPC_CLASS1_GEN1:
00935 m_ucIDDT = ucData[uiByteCnt++];
00936 m_ucSnrLen = ucData[uiByteCnt++];
00937
00938 if(m_ucSnrLen > FEDM_ISC_MAX_UID_LENGTH)
00939 return FEDM_ERROR_ARRAY_BOUNDARY;
00940
00941 for(iCnt=0; iCnt<(int)m_ucSnrLen; iCnt++)
00942 m_ucSnr[iCnt] = ucData[uiByteCnt++];
00943
00944 if(m_ucSnrLen > 0)
00945 m_bIsSnr = true;
00946
00947 if(m_ucIDDT == 0x01)
00948 {
00949 ucHeader = (m_ucSnr[0] & 0xC0) >> 6;
00950 switch(ucHeader)
00951 {
00952 case FEDM_ISC_EPC_TYPE_1:
00953 m_ucEpcType = FEDM_ISC_EPC_TYPE_1;
00954 m_bIsEpc = true;
00955 break;
00956
00957 case FEDM_ISC_EPC_TYPE_2:
00958 m_ucEpcType = FEDM_ISC_EPC_TYPE_2;
00959 m_bIsEpc = true;
00960 break;
00961
00962 case FEDM_ISC_EPC_TYPE_3:
00963 m_ucEpcType = FEDM_ISC_EPC_TYPE_3;
00964 m_bIsEpc = true;
00965 break;
00966
00967 case FEDM_ISC_EPC_TYPE_4:
00968 m_ucEpcType = FEDM_ISC_EPC_TYPE_4;
00969 m_bIsEpc = true;
00970 break;
00971 }
00972 }
00973 break;
00974
00975 case FEDM_ISC_TR_TYPE_EPC_CLASS1_GEN2:
00976 m_ucIDDT = ucData[uiByteCnt++];
00977 m_ucSnrLen = ucData[uiByteCnt++] - 2;
00978
00979 if(m_ucSnrLen > FEDM_ISC_MAX_UID_LENGTH)
00980 return FEDM_ERROR_ARRAY_BOUNDARY;
00981
00982 m_ucClass1Gen2_PC[0] = ucData[uiByteCnt++];
00983 m_ucClass1Gen2_PC[1] = ucData[uiByteCnt++];
00984
00985
00986 if(m_ucClass1Gen2_PC[0] & 0x02)
00987 {
00988 m_ucClass1Gen2_XPC_W1[0] = ucData[uiByteCnt++];
00989 m_ucClass1Gen2_XPC_W1[1] = ucData[uiByteCnt++];
00990 m_ucSnrLen -= 2;
00991 }
00992
00993 for(iCnt=0; iCnt<(int)m_ucSnrLen; iCnt++)
00994 m_ucSnr[iCnt] = ucData[uiByteCnt++];
00995
00996 if(m_ucSnrLen > 0)
00997 m_bIsSnr = true;
00998
00999
01000 if(m_ucIDDT == 0x01)
01001 {
01002 ucHeader = (m_ucSnr[0] & 0xC0) >> 6;
01003 switch(ucHeader)
01004 {
01005 case FEDM_ISC_EPC_TYPE_1:
01006 m_ucEpcType = FEDM_ISC_EPC_TYPE_1;
01007 m_bIsEpc = true;
01008 break;
01009
01010 case FEDM_ISC_EPC_TYPE_2:
01011 m_ucEpcType = FEDM_ISC_EPC_TYPE_2;
01012 m_bIsEpc = true;
01013 break;
01014
01015 case FEDM_ISC_EPC_TYPE_3:
01016 m_ucEpcType = FEDM_ISC_EPC_TYPE_3;
01017 m_bIsEpc = true;
01018 break;
01019
01020 case FEDM_ISC_EPC_TYPE_4:
01021 m_ucEpcType = FEDM_ISC_EPC_TYPE_4;
01022 m_bIsEpc = true;
01023 break;
01024 }
01025 }
01026 else if(m_ucIDDT == 0x02)
01027 {
01028
01029 ucEpcLen = ((m_ucClass1Gen2_PC[0] & 0xF8) >> 3) * 2;
01030 if( ucEpcLen < m_ucSnrLen && (m_ucSnrLen - ucEpcLen) >= 4)
01031 {
01032
01033 m_ucRxDB_TidBank[1] = m_ucSnr[ucEpcLen];
01034 m_ucRxDB_TidBank[0] = m_ucSnr[ucEpcLen+1];
01035 m_ucRxDB_TidBank[3] = m_ucSnr[ucEpcLen+2];
01036 m_ucRxDB_TidBank[2] = m_ucSnr[ucEpcLen+3];
01037 }
01038 }
01039 break;
01040 }
01041 }
01042
01043 return FEDM_OK;
01044 }