void
callback(TMR_Reader *reader, const TMR_TagReadData *t, void *cookie)
{
  char epcStr[128]; 
  TMR_bytesToHex(t->tag.epc, t->tag.epcByteCount, epcStr);
  printf("Background read: %s, antenna :%d\n", epcStr, t->antenna);
}
Exemplo n.º 2
0
static PyObject *
TagData_getepc(TagData *self, void *closure)
{
    char epcStr[128];

    TMR_bytesToHex(self->tag.epc, self->tag.epcByteCount, epcStr);
    return PyBytes_FromString(epcStr);
}
Exemplo n.º 3
0
void
callback(TMR_Reader *reader, const TMR_TagReadData *t, void *cookie)
{
  char epcStr[128];

  TMR_bytesToHex(t->tag.epc, t->tag.epcByteCount, epcStr);
  printf("Background read: %s Protocol:%0x \n", epcStr, t->tag.protocol);
  tmr_sleep(100);
}
Exemplo n.º 4
0
void callback(TMR_Reader *reader, const TMR_TagReadData *t, void *cookie)
{
  char epcStr[128];
  char uri1[256]= "GET http://"; 
  char uri2[256] = "\0";
  char temp[90];
  char temp2[10];
  int RSSI = 0;
  strcpy(temp, uri1);
  strcat(temp, uri2);
  TMR_bytesToHex(t->tag.epc, t->tag.epcByteCount, epcStr);
  RSSI = t->rssi;
  int antenna = t->antenna - 1;
  sprintf(temp2, "%d", RSSI);
  strcat(temp, "&antenna=");
  sprintf(temp2, "%d", antenna);
  strcat(temp, temp2);
  strcat(temp, "&TagNumber=");
  strcat(temp, epcStr);
  strcat(temp, "\r\n");
  printf("%s\n", temp);
}
Exemplo n.º 5
0
void tagCallback(TMR_Reader *readerr, const TMR_TagReadData *t, void *cookie)
{
	int i;
	int readerLocation;

	for(i = 0; i < uniqueReaderInstance; i++)
	{
		if(readers[i] == readerr)
		{
			readerLocation = i;
		}
	}

	char tagID[128];
	TMR_bytesToHex(t->tag.epc, t->tag.epcByteCount, tagID);

	char msg[256];
	sprintf(msg, "%i:%s:%d:%i:%i:%u:%u", readerLocation, tagID, t->rssi, t->phase, t->frequency, t->timestampHigh, t->timestampLow);
	printf("%s", msg);

	//uint64_t timestamp = ((uint64_t) t->timestampHigh<< 32 ) | t->timestampLow;

	Enqueue(communicatorQueue, msg);
}
Exemplo n.º 6
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, &region);
  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, &regions);
    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, &region);
    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;
}
Exemplo n.º 7
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;
#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, &region);
  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, &regions);
    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, &region);
    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 */
}