int RFIDclose() { Enqueue(communicatorQueue, "exit"); int i; for(i = 0; i < readerCount; i++) { TMR_stopReading(readers[i]); TMR_destroy(readers[i]); free(readers[i]); free(plan[i]); free(rlb[i]); free(reb[i]); free(region[i]); free(status[i]); free(model[i]); } free(readers); free(plan); free(rlb); free(reb); free(region); free(status); free(model); pthread_join(communicatorThread, NULL); return 0; }
int main(int argc, char *argv[]) { #ifndef TMR_ENABLE_BACKGROUND_READS errx(1, "This sample requires background read functionality.\n" "Please enable TMR_ENABLE_BACKGROUND_READS in tm_config.h\n" "to run this code.\n"); return -1; #else /* if (argc < 2) { errx(1, "Please provide reader URL, such as:\n" "tmr:///com4\n" "tmr://my-reader.example.com\n"); }*/ initVars(); // printReaderConfig(); setupReader("tmr:///dev/ttyACM0"); getReaderConfig(); // printReaderConfig(); exportReaderConfig(); printReaderConfig(); TMR_destroy(rp); return 0; #endif /* TMR_ENABLE_BACKGROUND_READS */ }
static void Reader_dealloc(Reader* self) { TMR_destroy(&self->reader); Py_TYPE(self)->tp_free((PyObject*)self); }
int main(int argc, char *argv[]) { #ifndef TMR_ENABLE_BACKGROUND_READS errx(1, "This sample requires background read functionality.\n" "Please enable TMR_ENABLE_BACKGROUND_READS in tm_config.h\n" "to run this codelet\n"); return -1; #else TMR_Reader r, *rp; TMR_Status ret; TMR_Region region; #if USE_TRANSPORT_LISTENER TMR_TransportListenerBlock tb; #endif TMR_ReadListenerBlock rlb; TMR_ReadExceptionListenerBlock reb; TMR_StatsListenerBlock slb; if (argc < 2) { errx(1, "Please provide reader URL, such as:\n" "tmr:///com4\n" "tmr://my-reader.example.com\n"); } rp = &r; ret = TMR_create(rp, argv[1]); checkerr(rp, ret, 1, "creating reader"); #if USE_TRANSPORT_LISTENER if (TMR_READER_TYPE_SERIAL == rp->readerType) { tb.listener = serialPrinter; } else { tb.listener = stringPrinter; } tb.cookie = stdout; TMR_addTransportListener(rp, &tb); #endif ret = TMR_connect(rp); checkerr(rp, ret, 1, "connecting reader"); region = TMR_REGION_NONE; ret = TMR_paramGet(rp, TMR_PARAM_REGION_ID, ®ion); checkerr(rp, ret, 1, "getting region"); if (TMR_REGION_NONE == region) { TMR_RegionList regions; TMR_Region _regionStore[32]; regions.list = _regionStore; regions.max = sizeof(_regionStore)/sizeof(_regionStore[0]); regions.len = 0; ret = TMR_paramGet(rp, TMR_PARAM_REGION_SUPPORTEDREGIONS, ®ions); checkerr(rp, ret, __LINE__, "getting supported regions"); if (regions.len < 1) { checkerr(rp, TMR_ERROR_INVALID_REGION, __LINE__, "Reader doesn't supportany regions"); } region = regions.list[0]; ret = TMR_paramSet(rp, TMR_PARAM_REGION_ID, ®ion); checkerr(rp, ret, 1, "setting region"); } { /* Code to get the reader stats after the sync read */ TMR_Reader_StatsValues stats; TMR_Reader_StatsFlag setFlag; TMR_PortValueList value; TMR_PortValue valueList[64]; int i, j; printf("\nReader stats after the sync read\n"); /** request for the statics fields of your interest, before search */ setFlag = TMR_READER_STATS_FLAG_ALL; value.max = sizeof(valueList)/sizeof(valueList[0]); value.list = valueList; ret = TMR_paramSet(rp, TMR_PARAM_READER_STATS_ENABLE, &setFlag); checkerr(rp, ret, 1, "setting the fields"); for (j = 1; j < 4; j++) { /** * perform three iterations to see that reader stats are * resetting after each search operation. **/ printf("\nIteration:%d\n", j); /** * performing the search operation. for 1 sec, * Individual search will reset the reader stats, before doing the search */ printf("Performing the search operation. for 1 sec\n"); ret = TMR_read(rp, 1000, NULL); checkerr(rp, ret, 1, "reading tags"); /** Initialize the reader statics variable to default values */ TMR_STATS_init(&stats); /* Search is completed. Get the reader stats */ printf("Search is completed. Get the reader stats\n"); ret = TMR_paramGet(rp, TMR_PARAM_READER_STATS, &stats); checkerr(rp, ret, 1, "getting the reader statistics"); /** Each field should be validated before extracting the value */ if (TMR_READER_STATS_FLAG_CONNECTED_ANTENNAS & stats.valid) { printf("Antenna Connection Status\n"); for (i = 0; i < stats.connectedAntennas.len; i += 2) { printf("Antenna %d |%s\n", stats.connectedAntennas.list[i], stats.connectedAntennas.list[i + 1] ? "connected":"Disconnected"); } } /* Get the antenna return loss value, this parameter is not the part of reader stats */ ret = TMR_paramGet(rp, TMR_PARAM_ANTENNA_RETURNLOSS, &value); checkerr(rp, ret, 1, "getting the antenna return loss"); printf("Antenna Return Loss\n"); for (i = 0; i < value.len && i < value.max; i++) { printf("Antenna %d | %d \n", value.list[i].port, value.list[i].value); } if (TMR_READER_STATS_FLAG_NOISE_FLOOR_SEARCH_RX_TX_WITH_TX_ON & stats.valid) { printf("Noise Floor With Tx On\n"); for (i = 0; i < stats.perAntenna.len; i++) { printf("Antenna %d | %d db\n", stats.perAntenna.list[i].antenna, stats.perAntenna.list[i].noiseFloor); } } if (TMR_READER_STATS_FLAG_RF_ON_TIME & stats.valid) { printf("RF On Time\n"); for (i = 0; i < stats.perAntenna.len; i++) { printf("Antenna %d | %d ms\n", stats.perAntenna.list[i].antenna, stats.perAntenna.list[i].rfOnTime); } } if (TMR_READER_STATS_FLAG_FREQUENCY & stats.valid) { printf("Frequency %d(khz)\n", stats.frequency); } if (TMR_READER_STATS_FLAG_TEMPERATURE & stats.valid) { printf("Temperature %d(C)\n", stats.temperature); } if (TMR_READER_STATS_FLAG_PROTOCOL & stats.valid) { printf("Protocol %s\n", protocolName(stats.protocol)); } if (TMR_READER_STATS_FLAG_ANTENNA_PORTS & stats.valid) { printf("currentAntenna %d\n", stats.antenna); } } } { /* Code to get the reader stats after the async read */ TMR_Reader_StatsFlag setFlag = TMR_READER_STATS_FLAG_ALL; rlb.listener = callback; rlb.cookie = NULL; reb.listener = exceptionCallback; reb.cookie = NULL; slb.listener = statsCallback; slb.cookie = NULL; ret = TMR_addReadListener(rp, &rlb); checkerr(rp, ret, 1, "adding read listener"); ret = TMR_addReadExceptionListener(rp, &reb); checkerr(rp, ret, 1, "adding exception listener"); ret = TMR_addStatsListener(rp, &slb); checkerr(rp, ret, 1, "adding the stats listener"); printf("\nReader stats after the async read \n"); /** request for the statics fields of your interest, before search */ ret = TMR_paramSet(rp, TMR_PARAM_READER_STATS_ENABLE, &setFlag); checkerr(rp, ret, 1, "setting the fields"); printf("Initiating the search operation. for 1 sec and the listener will provide the reader stats\n"); ret = TMR_startReading(rp); checkerr(rp, ret, 1, "starting reading"); #ifndef WIN32 sleep(1); #else Sleep(1000); #endif ret = TMR_stopReading(rp); checkerr(rp, ret, 1, "stopping reading"); } TMR_destroy(rp); return 0; #endif /* TMR_ENABLE_BACKGROUND_READS */ }
int main(int argc, char *argv[]) { TMR_Reader r, *rp; TMR_Status ret; TMR_Region region; #if USE_TRANSPORT_LISTENER TMR_TransportListenerBlock tb; #endif if (argc < 2) { errx(1, "Please provide reader URL, such as:\n" "tmr:///com4\n" "tmr://my-reader.example.com\n"); } rp = &r; ret = TMR_create(rp, argv[1]); checkerr(rp, ret, 1, "creating reader"); #if USE_TRANSPORT_LISTENER if (TMR_READER_TYPE_SERIAL == rp->readerType) { tb.listener = serialPrinter; } else { tb.listener = stringPrinter; } tb.cookie = stdout; TMR_addTransportListener(rp, &tb); #endif ret = TMR_connect(rp); checkerr(rp, ret, 1, "connecting reader"); region = TMR_REGION_NONE; ret = TMR_paramGet(rp, TMR_PARAM_REGION_ID, ®ion); checkerr(rp, ret, 1, "getting region"); if (TMR_REGION_NONE == region) { TMR_RegionList regions; TMR_Region _regionStore[32]; regions.list = _regionStore; regions.max = sizeof(_regionStore)/sizeof(_regionStore[0]); regions.len = 0; ret = TMR_paramGet(rp, TMR_PARAM_REGION_SUPPORTEDREGIONS, ®ions); checkerr(rp, ret, __LINE__, "getting supported regions"); if (regions.len < 1) { checkerr(rp, TMR_ERROR_INVALID_REGION, __LINE__, "Reader doesn't supportany regions"); } region = regions.list[0]; ret = TMR_paramSet(rp, TMR_PARAM_REGION_ID, ®ion); checkerr(rp, ret, 1, "setting region"); } { uint16_t retryCount = 1; /** * Power cycle the reader. Calling TMR_reboot() will do that. **/ ret = TMR_reboot(rp); checkerr(rp, ret, 1, "power cycling reader"); /** * power cycle will take some time to complete. * 1. Fixed reader : approximately 90sec. * 2. Serial reader : approximately 250ms. * * till then try to reconnect the reader. **/ printf("The reader is being rebooted. Once it has finished, it will reconnect ....\n"); //reconnect to the reader TMR_destroy(rp); ret = TMR_create(rp, argv[1]); do { printf("Trying to reconnect.... Attempt:%d\n", retryCount); ret = TMR_connect(rp); if (TMR_SUCCESS == ret) { /* reader reconnected */ break; } retryCount++; }while(true); printf("Reader is reconnected successfully\n"); } TMR_destroy(rp); return 0; }
int main(int argc, char *argv[]) { TMR_Reader r, *rp; TMR_Status ret; TMR_Region region; #if USE_TRANSPORT_LISTENER TMR_TransportListenerBlock tb; #endif if (argc < 2) { errx(1, "Please provide reader URL, such as:\n" "tmr:///com4\n" "tmr://my-reader.example.com\n"); } rp = &r; ret = TMR_create(rp, argv[1]); checkerr(rp, ret, 1, "creating reader"); #if USE_TRANSPORT_LISTENER if (TMR_READER_TYPE_SERIAL == rp->readerType) { tb.listener = serialPrinter; } else { tb.listener = stringPrinter; } tb.cookie = stdout; TMR_addTransportListener(rp, &tb); #endif ret = TMR_connect(rp); checkerr(rp, ret, 1, "connecting reader"); region = TMR_REGION_NONE; ret = TMR_paramGet(rp, TMR_PARAM_REGION_ID, ®ion); checkerr(rp, ret, 1, "getting region"); if (TMR_REGION_NONE == region) { TMR_RegionList regions; TMR_Region _regionStore[32]; regions.list = _regionStore; regions.max = sizeof(_regionStore)/sizeof(_regionStore[0]); regions.len = 0; ret = TMR_paramGet(rp, TMR_PARAM_REGION_SUPPORTEDREGIONS, ®ions); checkerr(rp, ret, __LINE__, "getting supported regions"); if (regions.len < 1) { checkerr(rp, TMR_ERROR_INVALID_REGION, __LINE__, "Reader doesn't supportany regions"); } region = regions.list[0]; ret = TMR_paramSet(rp, TMR_PARAM_REGION_ID, ®ion); checkerr(rp, ret, 1, "setting region"); } { TMR_ReadPlan simpleReadPlan, multiReadPlan; TMR_ReadPlan subplans[5]; TMR_ReadPlan* subplanPtrs[5]; TMR_TagProtocolList value; TMR_TagProtocol valueList[32]; int subplanCount = 0; int j; TMR_SR_GEN2_Q qValue; uint8_t antenna[] = {1}; uint32_t tagCount = 1; /* Initial test setup */ /* Set the Q value as per the tag population */ qValue.type = TMR_SR_GEN2_Q_STATIC; qValue.u.staticQ.initialQ = 0; ret = TMR_paramSet(rp, TMR_PARAM_GEN2_Q, &qValue); checkerr(rp, ret, 1, "setting the Q Value"); /* The simple read plan */ TMR_RP_init_simple (&simpleReadPlan, 1, antenna, TMR_TAG_PROTOCOL_GEN2, 1000); /* Stop N trigger */ TMR_RP_set_stopTrigger (&simpleReadPlan, tagCount); /* The multi read plan */ { value.max = 32; value.list = valueList; /* Berfore setting the readplen, we must get list of supported protocols */ ret = TMR_paramGet(rp, TMR_PARAM_VERSION_SUPPORTEDPROTOCOLS, &value); checkerr(rp, ret, 1, "Getting the supported protocols"); { ret = TMR_RP_init_simple(&subplans[subplanCount], 1, antenna,TMR_TAG_PROTOCOL_GEN2 , 1000); TMR_RP_set_stopTrigger (&subplans[subplanCount], tagCount); subplanCount++; ret = TMR_RP_init_simple(&subplans[subplanCount], 1, antenna, TMR_TAG_PROTOCOL_ISO180006B, 1000); TMR_RP_set_stopTrigger (&subplans[subplanCount], tagCount); subplanCount++; } for (j = 0; j < subplanCount; j++) { subplanPtrs[j] = &subplans[j]; } TMR_RP_init_multi(&multiReadPlan, subplanPtrs, subplanCount, 0); } /* Set the read plan */ ret = TMR_paramSet(rp, TMR_PARAM_READ_PLAN, &simpleReadPlan); //enable this for multi read plan //ret = TMR_paramSet(rp, TMR_PARAM_READ_PLAN, &multiReadPlan); checkerr(rp, ret, 1, "setting read plan"); /* The sync read */ { ret = TMR_read(rp, 1000, NULL); checkerr(rp, ret, 1, "reading tags"); while (TMR_SUCCESS == TMR_hasMoreTags(rp)) { TMR_TagReadData trd; char epcStr[128]; ret = TMR_getNextTag(rp, &trd); checkerr(rp, ret, 1, "fetching tag"); TMR_bytesToHex(trd.tag.epc, trd.tag.epcByteCount, epcStr); printf("EPC:%s\n", epcStr); } } } TMR_destroy(rp); return 0; }
int main(int argc, char *argv[]) { #ifndef TMR_ENABLE_BACKGROUND_READS errx(1, "This sample requires background read functionality.\n" "Please enable TMR_ENABLE_BACKGROUND_READS in tm_config.h\n" "to run this codelet\n"); return -1; #else TMR_Reader r, *rp; TMR_Status ret; TMR_Region region; TMR_ReadListenerBlock rlb; TMR_ReadExceptionListenerBlock reb; #if USE_TRANSPORT_LISTENER TMR_TransportListenerBlock tb; #endif if (argc < 2) { errx(1, "Please provide reader URL, such as:\n" "tmr:///com4\n" "tmr://my-reader.example.com\n"); } rp = &r; ret = TMR_create(rp, argv[1]); checkerr(rp, ret, 1, "creating reader"); #if USE_TRANSPORT_LISTENER if (TMR_READER_TYPE_SERIAL == rp->readerType) { tb.listener = serialPrinter; } else { tb.listener = stringPrinter; } tb.cookie = stdout; TMR_addTransportListener(rp, &tb); #endif ret = TMR_connect(rp); checkerr(rp, ret, 1, "connecting reader"); region = TMR_REGION_NONE; ret = TMR_paramGet(rp, TMR_PARAM_REGION_ID, ®ion); checkerr(rp, ret, 1, "getting region"); if (TMR_REGION_NONE == region) { TMR_RegionList regions; TMR_Region _regionStore[32]; regions.list = _regionStore; regions.max = sizeof(_regionStore)/sizeof(_regionStore[0]); regions.len = 0; ret = TMR_paramGet(rp, TMR_PARAM_REGION_SUPPORTEDREGIONS, ®ions); checkerr(rp, ret, __LINE__, "getting supported regions"); if (regions.len < 1) { checkerr(rp, TMR_ERROR_INVALID_REGION, __LINE__, "Reader doesn't supportany regions"); } region = regions.list[0]; ret = TMR_paramSet(rp, TMR_PARAM_REGION_ID, ®ion); checkerr(rp, ret, 1, "setting region"); } rlb.listener = callback; rlb.cookie = NULL; reb.listener = exceptionCallback; reb.cookie = NULL; ret = TMR_addReadListener(rp, &rlb); checkerr(rp, ret, 1, "adding read listener"); ret = TMR_addReadExceptionListener(rp, &reb); checkerr(rp, ret, 1, "adding exception listener"); { TMR_ReadPlan plan; TMR_TagFilter filter; TMR_ISO180006B_Delimiter delimiter; uint8_t wordData[8] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }; /* Set the Delimiter to 1 */ delimiter = TMR_ISO180006B_Delimiter1; ret = TMR_paramSet(rp, TMR_PARAM_ISO180006B_DELIMITER, &delimiter); checkerr(rp, ret, 1, "setting the delimiter"); /* Read Plan */ TMR_RP_init_simple(&plan, 0, NULL, TMR_TAG_PROTOCOL_ISO180006B, 1000); TMR_TF_init_ISO180006B_select(&filter, false, TMR_ISO180006B_SELECT_OP_NOT_EQUALS, 0, 0xff, wordData); /* Commit read plan */ ret = TMR_RP_set_filter(&plan, &filter); checkerr(rp, ret, 1, "setting filter to the read plan"); ret = TMR_paramSet(rp, TMR_PARAM_READ_PLAN, &plan); checkerr(rp, ret, 1, "setting read plan"); } ret = TMR_startReading(rp); checkerr(rp, ret, 1, "starting reading"); #ifndef WIN32 sleep(5); #else Sleep(5000); #endif ret = TMR_stopReading(rp); checkerr(rp, ret, 1, "stopping reading"); TMR_destroy(rp); return 0; #endif /* TMR_ENABLE_BACKGROUND_READS */ }
int main(int argc, char *argv[]) { #ifndef TMR_ENABLE_BACKGROUND_READS errx(1, "This sample requires background read functionality.\n" "Please enable TMR_ENABLE_BACKGROUND_READS in tm_config.h\n" "to run this codelet\n"); return -1; #else TMR_Reader r, *rp; TMR_Status ret; TMR_Region region; #if USE_TRANSPORT_LISTENER TMR_TransportListenerBlock tb; #endif TMR_ReadListenerBlock rlb; TMR_ReadExceptionListenerBlock reb; if (argc < 2) { errx(1, "Please provide reader URL, such as:\n" "customschemename://readerIP:portname\n"); } rp = &r; /** * Add the custom transport scheme before calling TMR_create(). * This can be done by using C API helper function TMR_setSerialTransport(). * It accepts two arguments. scheme and nativeInit. * scheme: the custom transport scheme name. For demonstration using scheme as "tcp". * nativeInit: reference to the transport factory init function. */ ret = TMR_setSerialTransport("tcp", &TMR_SR_SerialTransportTcpNativeInit); checkerr(rp, ret, 1, "adding the custom transport scheme"); ret = TMR_create(rp, argv[1]); checkerr(rp, ret, 1, "creating reader"); #if USE_TRANSPORT_LISTENER if (TMR_READER_TYPE_SERIAL == rp->readerType) { tb.listener = serialPrinter; } else { tb.listener = stringPrinter; } tb.cookie = stdout; TMR_addTransportListener(rp, &tb); #endif ret = TMR_connect(rp); checkerr(rp, ret, 1, "connecting reader"); region = TMR_REGION_NONE; ret = TMR_paramGet(rp, TMR_PARAM_REGION_ID, ®ion); checkerr(rp, ret, 1, "getting region"); if (TMR_REGION_NONE == region) { TMR_RegionList regions; TMR_Region _regionStore[32]; regions.list = _regionStore; regions.max = sizeof(_regionStore)/sizeof(_regionStore[0]); regions.len = 0; ret = TMR_paramGet(rp, TMR_PARAM_REGION_SUPPORTEDREGIONS, ®ions); checkerr(rp, ret, __LINE__, "getting supported regions"); if (regions.len < 1) { checkerr(rp, TMR_ERROR_INVALID_REGION, __LINE__, "Reader doesn't supportany regions"); } region = regions.list[0]; ret = TMR_paramSet(rp, TMR_PARAM_REGION_ID, ®ion); checkerr(rp, ret, 1, "setting region"); } { /* Initiate a sync read */ printf("\nDoing a sync read for 1sec duration\n"); ret = TMR_read(rp, 1000, NULL); if (TMR_SUCCESS != ret) { fprintf(stderr, "Error reading tags: %s\n", TMR_strerr(rp, ret)); /* Don't exit, tags might still have been read before the error occurred. */ } while (TMR_SUCCESS == TMR_hasMoreTags(rp)) { TMR_TagReadData trd; char epcStr[128]; ret = TMR_getNextTag(rp, &trd); checkerr(rp, ret, 1, "fetching tag"); TMR_bytesToHex(trd.tag.epc, trd.tag.epcByteCount, epcStr); printf("Background read: %s Protocol:%0x \n", epcStr, trd.tag.protocol); } } { /* Initiate an async read */ printf("\nDoing an async read for 1sec duration\n"); rlb.listener = callback; rlb.cookie = NULL; reb.listener = exceptionCallback; reb.cookie = NULL; ret = TMR_addReadListener(rp, &rlb); checkerr(rp, ret, 1, "adding read listener"); ret = TMR_addReadExceptionListener(rp, &reb); checkerr(rp, ret, 1, "adding exception listener"); ret = TMR_startReading(rp); checkerr(rp, ret, 1, "starting reading"); tmr_sleep(1000); ret = TMR_stopReading(rp); checkerr(rp, ret, 1, "stopping reading"); } TMR_destroy(rp); return 0; #endif /* TMR_ENABLE_BACKGROUND_READS */ }