# tm_reader.c File Reference

Mercury API - top level implementation. More...

`#include <stddef.h>`
`#include <stdio.h>`
`#include <stdlib.h>`
`#include <string.h>`
`#include "tm_reader.h"`
`#include "serial_reader_imp.h"`
`#include "tmr_utils.h"`

## Functions

TMR_Status | TMR_create_alloc (TMR_Reader **reader, const char *deviceUri)
TMR_Status | TMR_create (TMR_Reader *reader, const char *deviceUri)
TMR_Status | TMR_setSerialTransport (char *scheme, TMR_TransportNativeInit nativeInit)
TMR_Status | TMR_readIntoArray (struct TMR_Reader *reader, uint32_t timeoutMs, int32_t *tagCount, TMR_TagReadData *result[])
TMR_Status | TMR_paramSet (struct TMR_Reader *reader, TMR_Param key, const void *value)
TMR_Status | TMR_paramGet (struct TMR_Reader *reader, TMR_Param key, void *value)
TMR_Status | TMR_addTransportListener (TMR_Reader *reader, TMR_TransportListenerBlock *b)
TMR_Status | TMR_removeTransportListener (TMR_Reader *reader, TMR_TransportListenerBlock *b)
bool | TMR_memoryProvider (void *cookie, uint16_t *size, uint8_t *data)
TMR_Status | TMR_TRD_init (TMR_TagReadData *trd)
TMR_Status | TMR_TRD_init_data (TMR_TagReadData *trd, uint16_t size, uint8_t *buf)
TMR_Status | TMR_TRD_MEMBANK_init_data (TMR_uint8List *data, uint16_t size, uint8_t *buf)
TMR_Status | TMR_GEN2_init_BapParams (TMR_GEN2_Bap *bapVal, int32_t powerUpDelayUs, int32_t freqHopOfftimeUs)
TMR_Status | TMR_TF_init_tag (TMR_TagFilter *filter, TMR_TagData *tag)
TMR_Status | TMR_TF_init_gen2_select (TMR_TagFilter *filter, bool invert, TMR_GEN2_Bank bank, uint32_t bitPointer, uint16_t maskBitLength, uint8_t *mask)
bool | TMR_TF_match (TMR_TagFilter *filter, TMR_TagData *tag)
TMR_Status | TMR_TA_init_gen2 (TMR_TagAuthentication *auth, TMR_GEN2_Password password)
TMR_Status | TMR_TA_init_gen2_Denatran_IAV_writeCredentials (TMR_TagAuthentication *auth, uint8_t idLength, uint8_t *tagId, uint8_t len, uint8_t *data)
TMR_Status | TMR_TA_init_gen2_Denatran_IAV_writeSecCredentials (TMR_TagAuthentication *auth, uint8_t length, uint8_t *data, uint8_t len, uint8_t *credentials)
TMR_Status | TMR_STATS_init (TMR_Reader_StatsValues *stats)
TMR_Status | TMR_GPITR_init_enable (TMR_GPITriggerRead *triggerRead, bool enable)
TMR_Status | TMR_RP_init_simple (TMR_ReadPlan *plan, uint8_t antennaCount, uint8_t *antennaList, TMR_TagProtocol protocol, uint32_t weight)
TMR_Status | TMR_RP_set_stopTrigger (TMR_ReadPlan *plan, uint32_t nCount)
TMR_Status | TMR_RP_set_filter (TMR_ReadPlan *plan, TMR_TagFilter *filter)
TMR_Status | TMR_RP_set_useFastSearch (TMR_ReadPlan *plan, bool useFastSearch)
TMR_Status | TMR_RP_set_enableAutonomousRead (TMR_ReadPlan *plan, bool autonomousRead)
TMR_Status | TMR_RP_set_enableTriggerRead (TMR_ReadPlan *plan, TMR_GPITriggerRead *triggerRead)
TMR_Status | TMR_RP_set_tagop (TMR_ReadPlan *plan, TMR_TagOp *tagop)
TMR_Status | TMR_RP_init_multi (TMR_ReadPlan *plan, TMR_ReadPlan **plans, uint8_t planCount, uint32_t weight)
TMR_Status | TMR_TLA_init_gen2 (TMR_TagLockAction *lockAction, uint16_t mask, uint16_t action)
TMR_Status | TMR_TagOp_init_GEN2_WriteTag (TMR_TagOp *tagop, TMR_TagData *epc)
TMR_Status | TMR_TagOp_init_GEN2_ReadData (TMR_TagOp *tagop, TMR_GEN2_Bank bank, uint32_t wordAddress, uint8_t len)
TMR_Status | TMR_TagOp_init_GEN2_SecureReadData (TMR_TagOp *tagop, TMR_GEN2_Bank bank, uint32_t wordAddress, uint8_t len, uint8_t tagtype, uint8_t passwordType)
TMR_Status | TMR_TagOp_init_GEN2_SecurePassWord (TMR_TagOp *tagop, uint8_t passwordType, uint32_t gen2PassWord, uint8_t addressLength, uint8_t addressOffset, uint16_t flashOffset)
TMR_Status | TMR_TagOp_init_ISO180006B_ReadData (TMR_TagOp *tagop, uint8_t byteAddress, uint8_t len)
TMR_Status | TMR_TagOp_init_GEN2_WriteData (TMR_TagOp *tagop, TMR_GEN2_Bank bank, uint32_t wordAddress, TMR_uint16List *data)
TMR_Status | TMR_TagOp_init_ISO180006B_WriteData (TMR_TagOp *tagop, uint8_t byteAddress, TMR_uint8List *data)
TMR_Status | TMR_TagOp_init_GEN2_Lock (TMR_TagOp *tagop, uint16_t mask, uint16_t action, TMR_GEN2_Password accessPassword)
TMR_Status | TMR_TagOp_init_ISO180006B_Lock (TMR_TagOp *tagop, uint8_t address)
TMR_Status | TMR_TagOp_init_GEN2_Kill (TMR_TagOp *tagop, TMR_GEN2_Password killPassword)
TMR_Status | TMR_TagOp_init_GEN2_BlockWrite (TMR_TagOp *tagop, TMR_GEN2_Bank bank, uint32_t wordPtr, TMR_uint16List *data)
TMR_Status | TMR_TagOp_init_GEN2_BlockPermaLock (TMR_TagOp *tagop, uint8_t readLock, TMR_GEN2_Bank bank, uint32_t blockPtr, TMR_uint16List *mask)
TMR_Status | TMR_TagOp_init_GEN2_BlockErase (TMR_TagOp *tagop, TMR_GEN2_Bank bank, uint32_t wordPtr, uint8_t wordCount)
void | TMR_paramProbe (struct TMR_Reader *reader, TMR_Param key)
TMR_Status | TMR_paramList (struct TMR_Reader *reader, TMR_Param *keys, uint32_t *len)

## Detailed Description

Mercury API - top level implementation.

Author:
  Nathan Williams

Date:
  10/28/2009

## Function Documentation

TMR_Status TMR_GEN2_init_BapParams | ( | TMR_GEN2_Bap * | bapVal,
|  | int32_t | powerUpDelayUs,
|  | int32_t | freqHopOfftimeUs |
| ) |  |  |

Initialize a TMR_GEN2_Bap with the provided parameters

Parameters:

  | bapVal | pointer to the TMR_GEN2_Bap structure
  | powerUpDelayUs | the power up delay time
  | freqHopOfftimeUs | the offtime for frequencyHop

bool TMR_memoryProvider | ( | void * | cookie,
|  | uint16_t * | size,
|  | uint8_t * | data |
| ) |  |  |

This function can be used as a callback to TMR_firmwareLoad when the firmware image exists in system memory. The cookie is a pointer to a TMR_memoryCookie that is initialized with the start of the firmware image in memory and its size.

Parameters:

  | cookie | TMR_memoryCookie value.
  `[in]` | size | The number of bytes requested.
  `[out]` | size | The number of bytes returned.
  | data | Pointer to buffer to fill.

Returns:
  true if there is more firmware data to return.

void TMR_paramProbe | ( | struct TMR_Reader * | reader,
|  | TMR_Param | key |
| ) |  |  |

Initialize a TMR_TagOp as a Higgs2 Partial Load Image operation with the provided parameters.

Parameters:

  | tagop | Pointer to the tagop structure to initialize.
  | killPassword | kill password
  | accessPassword | access password
  | epc | EPC to write

TMR_Status TMR_TA_init_gen2 | ( | TMR_TagAuthentication * | auth,
|  | TMR_GEN2_Password | password |
| ) |  |  |

Initialize a TMR_TagAuthentication structure as a Gen2 password.

Parameters:

  | auth | Pointer to the structure to initialize.
  | password | The password 32-bit Gen2 password value.

TMR_Status TMR_TA_init_gen2_Denatran_IAV_writeCredentials | ( | TMR_TagAuthentication * | auth,
|  | uint8_t | idLength,
|  | uint8_t * | tagId,
|  | uint8_t | len,
|  | uint8_t * | data |
| ) |  |  |

Initialize a TMR_TagAuthentication structure as Denatran IAV write credential

Parameters:

  | auth | Pointer to the structure to initialize.
  | data | Gen2 Denatran IAV write credential

TMR_Status TMR_TA_init_gen2_Denatran_IAV_writeSecCredentials | ( | TMR_TagAuthentication * | auth,
|  | uint8_t | length,
|  | uint8_t * | data,
|  | uint8_t | len,
|  | uint8_t * | credentials |
| ) |  |  |

Initialize a TMR_TagAuthentication structure as Denatran IAV write credential

Parameters:

  | auth | Pointer to the structure to initialize.
  | data | Gen2 Denatran IAV write credential

TMR_Status TMR_TagOp_init_GEN2_BlockErase | ( | TMR_TagOp * | tagop,
|  | TMR_GEN2_Bank | bank,
|  | uint32_t | wordPtr,
|  | uint8_t | wordCount |
| ) |  |  |

Initialize a TMR_TagOp as a GEN2 BlockErase operation with the provided parameters.

Parameters:

  | tagop | Pointer to the tagop structure to initialize.
  | bank | bank
  | wordPtr | The starting word address to erase
  | wordCount | Number of words to erase

TMR_Status TMR_TagOp_init_GEN2_BlockPermaLock | ( | TMR_TagOp * | tagop,
|  | uint8_t | readLock,
|  | TMR_GEN2_Bank | bank,
|  | uint32_t | blockPtr,
|  | TMR_uint16List * | mask |
| ) |  |  |

Initialize a TMR_TagOp as a GEN2 BlockPermaLock operation with the provided parameters.

Parameters:

  | tagop | Pointer to the tagop structure to initialize.
  | readLock | readLock
  | bank | bank
  | blockPtr | block pointer
  | mask | mask (The length of the mask specifies the block range)

TMR_Status TMR_TagOp_init_GEN2_BlockWrite | ( | TMR_TagOp * | tagop,
|  | TMR_GEN2_Bank | bank,
|  | uint32_t | wordPtr,
|  | TMR_uint16List * | data |
| ) |  |  |

Initialize a TMR_TagOp as a GEN2 BlockWrite operation with the provided parameters.

Parameters:

  | tagop | Pointer to the tagop structure to initialize.
  | bank | bank
  | wordPtr | word pointer
  | data | data (The length of the data specifies the word count)

TMR_Status TMR_TagOp_init_GEN2_Kill | ( | TMR_TagOp * | tagop,
|  | TMR_GEN2_Password | killPassword |
| ) |  |  |

Initialize a TMR_TagOp as a GEN2 kill operation with the provided parameters.

Parameters:

  | tagop | Pointer to the tagop structure to initialize.
  | killPassword | tag kill password

TMR_Status TMR_TagOp_init_GEN2_Lock | ( | TMR_TagOp * | tagop,
|  | uint16_t | mask,
|  | uint16_t | action,
|  | TMR_GEN2_Password | accessPassword |
| ) |  |  |

Initialize a TMR_TagOp as a GEN2 lock operation with the provided parameters.

Parameters:

  | tagop | Pointer to the tagop structure to initialize.
  | mask | mask
  | action | action
  | accessPassword | The password to use to lock the tag.

TMR_Status TMR_TagOp_init_GEN2_ReadData | ( | TMR_TagOp * | tagop,
|  | TMR_GEN2_Bank | bank,
|  | uint32_t | wordAddress,
|  | uint8_t | len |
| ) |  |  |

Initialize a TMR_TagOp as a GEN2 data read operation with the provided parameters.

Parameters:

  | tagop | Pointer to the tagop structure to initialize.
  | bank | Memory bank from which to read
  | wordAddress | Word address of location in bank from which to read
  | len | Number of words to read

TMR_Status TMR_TagOp_init_GEN2_SecurePassWord | ( | TMR_TagOp * | tagop,
|  | uint8_t | passwordType,
|  | uint32_t | gen2PassWord,
|  | uint8_t | addressLength,
|  | uint8_t | addressOffset,
|  | uint16_t | flashOffset |
| ) |  |  |

Initialize a TMR_TagOp as a Gen2 Secure Password with the provided parameters.

Parameters:

  | tagop | Pointer to the tagop structure to initialize
  | passwordType | specifying the mode of password
  | gen2PassWord | Gen2 access password
  | addressLength | Number of bits used to address the AP list
  | addressOffset | EPC word offset
  | flashOffset | User flash offset

TMR_Status TMR_TagOp_init_GEN2_SecureReadData | ( | TMR_TagOp * | tagop,
|  | TMR_GEN2_Bank | bank,
|  | uint32_t | wordAddress,
|  | uint8_t | len,
|  | uint8_t | tagtype,
|  | uint8_t | passwordType |
| ) |  |  |

Initialize a TMR_TagOp as a GEN2 Secure data read operation with the provided parameters.

Parameters:

  | tagop | Pointer to the tagop structure to initialize.
  | bank | Memory bank from which to read
  | wordAddress | Word address of location in bank from which to read
  | len | Number of words to read
  | tagtype | to select Alien Higgs 3 secure access and Monza 4 secure access
  | passwordType | specifying the mode of password

TMR_Status TMR_TagOp_init_GEN2_WriteData | ( | TMR_TagOp * | tagop,
|  | TMR_GEN2_Bank | bank,
|  | uint32_t | wordAddress,
|  | TMR_uint16List * | data |
| ) |  |  |

Initialize a TMR_TagOp as a GEN2 data write operation with the provided parameters.

Parameters:

  | tagop | Pointer to the tagop structure to initialize.
  | bank | Memory bank to write into
  | wordAddress | Word address of location to begin write
  | data | Data to write

TMR_Status TMR_TagOp_init_GEN2_WriteTag | ( | TMR_TagOp * | tagop,
|  | TMR_TagData * | epc |
| ) |  |  |

Initialize a TMR_TagOp as a GEN2 EPC write operation with the provided parameters.

Parameters:

  | tagop | Pointer to the tagop structure to initialize.
  | epc | EPC to write

TMR_Status TMR_TagOp_init_ISO180006B_Lock | ( | TMR_TagOp * | tagop,
|  | uint8_t | address |
| ) |  |  |

Initialize a TMR_TagOp as a ISO180006B lock operation with the provided parameters.

Parameters:

  | tagop | Pointer to the tagop structure to initialize.
  | address | The memory address of the byte to lock.

TMR_Status TMR_TagOp_init_ISO180006B_ReadData | ( | TMR_TagOp * | tagop,
|  | uint8_t | byteAddress,
|  | uint8_t | len |
| ) |  |  |

Initialize a TMR_TagOp as a ISO18000B data read operation with the provided parameters.

Parameters:

  | tagop | Pointer to the tagop structure to initialize.
  | byteAddress | Address of location in bank from which to read
  | len | Number of bytes to read

TMR_Status TMR_TagOp_init_ISO180006B_WriteData | ( | TMR_TagOp * | tagop,
|  | uint8_t | byteAddress,
|  | TMR_uint8List * | data |
| ) |  |  |

Initialize a TMR_TagOp as a ISO180006B data write operation with the provided parameters.

Parameters:

  | tagop | Pointer to the tagop structure to initialize.
  | byteAddress | address of location to begin write
  | data | Data to write

TMR_Status TMR_TF_init_gen2_select | ( | TMR_TagFilter * | filter,
|  | bool | invert,
|  | TMR_GEN2_Bank | bank,
|  | uint32_t | bitPointer,
|  | uint16_t | maskBitLength,
|  | uint8_t * | mask |
| ) |  |  |

Initialize a TMR_Filter structure as a Gen2 select filter with the provided parameters.

Parameters:

  | filter | Pointer to the filter structure to initialize
  | invert | Whether to invert the result of the select
  | bank | The memory bank on the tag to compare with the data
  | bitPointer | The bit address of the tag data to compare
  | maskBitLength | The length of the data to compare
  | mask | The data to compare

TMR_Status TMR_TF_init_tag | ( | TMR_TagFilter * | filter,
|  | TMR_TagData * | tag |
| ) |  |  |

Initialize a TMR_Filter structure as tag data (EPC) filter with the provided tag (which is copied).

Parameters:

  | filter | Pointer to the filter structure to initialize
  | tag | TMR_TagData to use as the filter value

bool TMR_TF_match | ( | TMR_TagFilter * | filter,
|  | TMR_TagData * | tag |
| ) |  |  |

Test if a tag matches this filter. Only applies to selects based on the EPC.

Parameters:

  | filter | The filter to test with.
  | tag | The tag to test.

Returns:
  true if the tag matches the filter.

TMR_Status TMR_TLA_init_gen2 | ( | TMR_TagLockAction * | lockAction,
|  | uint16_t | mask,
|  | uint16_t | action |
| ) |  |  |

Initialize a TMR_TagLockAction as a Gen2 lock action with the provided parameters.

Parameters:

  | lockAction | Pointer to the structure to initialize.
  | mask | mask
  | action | action

TMR_Status TMR_TRD_init | ( | TMR_TagReadData * | trd | ) |

Initialize TMR_TagReadData with default values. The tagData buffer will be initialized to TMR_MAX_EMBEDDED_DATA_LENGTH which can be found in tm_config.h. If this value is zero, then the buffer is pointed to NULL.

Parameters:

  | trd | Pointer to the TMR_TagReadData structure to initialize

TMR_Status TMR_TRD_init_data | ( | TMR_TagReadData * | trd,
|  | uint16_t | size,
|  | uint8_t * | buf |
| ) |  |  |

Initialize a TMR_TagReadData with the provided data storage area.

Parameters:

  | trd | Pointer to the TMR_TagReadData structure to initialize
  | size | The number of bytes pointed to
  | buf | Pointer to the uint8_t storage area

TMR_Status TMR_TRD_MEMBANK_init_data | ( | TMR_uint8List * | data,
|  | uint16_t | size,
|  | uint8_t * | buf |
| ) |  |  |

Initialize a TMR_TagReadDataMemBank with provided data storage area

Parameters:

  | data | to the TMR_uint8List structure to initialize
  | size | The nuber of bytes pointed to
  | buf | pointer to the uint8_t storage area