|
M5Unit-RFID 0.2.0 git rev:79c1939
|
EPC Gen2 semantics layer for UHF-RFID reader units. More...
#include <uhf_layer.hpp>
Public Member Functions | |
| UHFLayer (m5::unit::UHFRFIDComponent &u) | |
| UHFLayer (const UHFLayer &)=delete | |
| UHFLayer & | operator= (const UHFLayer &)=delete |
Detection | |
| bool | detect (std::vector< Tag > &tags, const uint32_t timeout_ms=1000U) |
| Detect tags. | |
| bool | detect (Tag &tag, const uint32_t timeout_ms=500U) |
| Detect one tag. | |
Target tag | |
| bool | select (const Tag &tag, const uint32_t access_password=0, const bool verify=true) |
| Point subsequent tag operations at one tag. | |
| bool | select (const Epc &epc, const uint32_t access_password=0, const bool verify=true) |
| Select by EPC, for a tag the caller holds nothing else of. | |
| bool | select (const Tid &tid, const uint32_t access_password=0, const bool verify=true) |
| Select by TID. | |
| bool | deselect () |
| Stop addressing a single tag, and put polling back the way select() found it. | |
| bool | isSelected () const |
| Is a tag being addressed? | |
| const Tag & | selectedTag () const |
| The tag currently being addressed. | |
| bool | identify (Tag &tag) |
| Read the selected tag's TID and fill in what it says about the tag. | |
Dump | |
| bool | dump () |
| Dump every memory bank of the selected tag. | |
| bool | dump (const Bank bank) |
| Dump one memory bank. | |
| bool | dump (const Bank bank, const uint16_t word_address, const uint16_t words) |
| Dump part of one memory bank. | |
Tag memory, addressed to the selected tag | |
| Result | readBank (std::vector< uint8_t > &out, const Bank bank, const uint16_t word_address, const uint16_t word_count) |
| Read a memory bank. | |
| Result | readBank (uint8_t *out, uint16_t &out_len, const Bank bank, const uint16_t word_address, const uint16_t word_count) |
| Read a memory bank into a buffer of the caller's own. | |
| Result | writeBank (const Bank bank, const uint16_t word_address, const uint8_t *data, const uint16_t data_len) |
| Write a memory bank. | |
| Result | lock (const std::vector< LockSetting > &settings, const bool allow_permanent=false) |
| Change the lock state of memory banks and passwords. | |
| Result | kill (const Tag &tag, const uint32_t kill_password) |
| Kill a tag permanently. | |
| Result | readBlockPermalock (std::vector< uint8_t > &mask, const Bank bank, const uint16_t block_pointer=0, const uint8_t block_range=1) |
| Read which blocks of a bank the selected tag has permanently locked. | |
| Result | blockPermalock (const Bank bank, const uint8_t *mask, const size_t mask_len, const bool allow_permanent, const uint16_t block_pointer=0, const uint8_t block_range=1) |
| Permanently lock blocks of a bank on the selected tag. | |
| Result | readQTParameters (QTParameters &qt) |
| Read the QT control word of the selected tag. | |
| Result | writeQTParameters (const QTParameters &qt, const bool persistent=false) |
| Write the QT control word of the selected tag. | |
| Result | readNxpConfigWord (uint16_t &config) |
| Read the Config-Word of an NXP UCODE G2X. | |
| Result | toggleNxpConfigWord (uint16_t &config, const uint16_t toggle) |
| Invert bits of the Config-Word of an NXP UCODE G2X. | |
| Result | writeNxpEAS (const bool enable) |
| Set or clear the Product Status Flag of an NXP UCODE G2X. | |
| bool | nxpEASAlarm (std::vector< uint8_t > &alarm) |
| Ask the field whether any tag has its Product Status Flag asserted. | |
| Result | nxpReadProtect (const bool protect) |
| Turn the read protection of an NXP UCODE G2X on or off. | |
EPC Gen2 semantics layer for UHF-RFID reader units.
Holds semantics defined by the EPC Gen2 standard, which stay the same across reader chips. The frame level belongs to the unit class.
| Result m5::uhf::UHFLayer::blockPermalock | ( | const Bank | bank, |
| const uint8_t * | mask, | ||
| const size_t | mask_len, | ||
| const bool | allow_permanent, | ||
| const uint16_t | block_pointer = 0, | ||
| const uint8_t | block_range = 1 ) |
Permanently lock blocks of a bank on the selected tag.
| bank | Bank the blocks are in |
| mask | One bit per block, the first block in the most significant bit. A bit set locks that block; a bit clear leaves it as it is |
| mask_len | Its length in bytes, which is twice block_range |
| allow_permanent | Permit the operation, which cannot be undone |
| block_pointer | First block the mask covers, in units of sixteen |
| block_range | Words of mask, each covering sixteen blocks |
| bool m5::uhf::UHFLayer::detect | ( | std::vector< Tag > & | tags, |
| const uint32_t | timeout_ms = 1000U ) |
Detect tags.
| [out] | tags | Detected tags, deduplicated by EPC |
| timeout_ms | How long to keep looking, in milliseconds |
The timeout is how long the field is watched, not a deadline: this always looks for the whole of it, because a tag that answers rarely is only found by looking again. Shortening it returns sooner and finds fewer tags
| bool m5::uhf::UHFLayer::detect | ( | Tag & | tag, |
| const uint32_t | timeout_ms = 500U ) |
Detect one tag.
| [out] | tag | The first tag that answers |
| timeout_ms | How long to wait before giving up, in milliseconds |
Returns as soon as any tag answers rather than waiting the timeout out, so it costs one inventory round instead of the whole window. Unlike the form taking a vector the timeout is a deadline rather than a duration, and the default covers the longest a tag was measured to take to answer
| bool m5::uhf::UHFLayer::dump | ( | ) |
Dump every memory bank of the selected tag.
Prints the Reserved, EPC, TID and User banks. How much of each there is comes from the tag where it says so and from what its chip is known to hold where it does not; a bank whose size is not known either way is skipped and said to be so
| bool m5::uhf::UHFLayer::dump | ( | const Bank | bank | ) |
Dump one memory bank.
| bank | Memory bank |
| bool m5::uhf::UHFLayer::dump | ( | const Bank | bank, |
| const uint16_t | word_address, | ||
| const uint16_t | words ) |
Dump part of one memory bank.
| bank | Memory bank |
| word_address | Start address in 16-bit words |
| words | Number of 16-bit words |
| bool m5::uhf::UHFLayer::identify | ( | Tag & | tag | ) |
Read the selected tag's TID and fill in what it says about the tag.
| [out] | tag | The selected tag, with the identification half filled in |
Reads the two fixed TID words first, then the XTID if the tag carries one, since the header is what says how long the rest is. Chip, vendor, serial length and memory sizes all come out of that (TDS 16.1 and 16.2)
Kill a tag permanently.
| tag | Tag to kill, which must be the one selected |
| kill_password | Kill password; a tag whose kill password is zero refuses to be killed |
| Result m5::uhf::UHFLayer::lock | ( | const std::vector< LockSetting > & | settings, |
| const bool | allow_permanent = false ) |
Change the lock state of memory banks and passwords.
| settings | What to change; anything left out keeps the state it has |
| allow_permanent | Permit PermanentOpen and PermanentLock, neither of which can be undone |
| bool m5::uhf::UHFLayer::nxpEASAlarm | ( | std::vector< uint8_t > & | alarm | ) |
Ask the field whether any tag has its Product Status Flag asserted.
| [out] | alarm | Code the tag backscattered, or empty when nothing answered |
| Result m5::uhf::UHFLayer::nxpReadProtect | ( | const bool | protect | ) |
Turn the read protection of an NXP UCODE G2X on or off.
| protect | True to protect, false to put it back |
Protected memory reads back as zeroes rather than falling silent, so the tag goes on answering an inventory round and can be addressed again to undo this
| Result m5::uhf::UHFLayer::readBank | ( | std::vector< uint8_t > & | out, |
| const Bank | bank, | ||
| const uint16_t | word_address, | ||
| const uint16_t | word_count ) |
Read a memory bank.
| [out] | out | Bytes read |
| bank | Memory bank | |
| word_address | Start address in 16-bit words | |
| word_count | Number of 16-bit words to read |
| Result m5::uhf::UHFLayer::readBank | ( | uint8_t * | out, |
| uint16_t & | out_len, | ||
| const Bank | bank, | ||
| const uint16_t | word_address, | ||
| const uint16_t | word_count ) |
Read a memory bank into a buffer of the caller's own.
| [out] | out | Buffer, which has to hold word_count words |
| [in,out] | out_len | Its size in bytes going in, and how many bytes arrived coming out |
| bank | Memory bank | |
| word_address | Start address in 16-bit words | |
| word_count | Number of 16-bit words to read |
| Result m5::uhf::UHFLayer::readBlockPermalock | ( | std::vector< uint8_t > & | mask, |
| const Bank | bank, | ||
| const uint16_t | block_pointer = 0, | ||
| const uint8_t | block_range = 1 ) |
Read which blocks of a bank the selected tag has permanently locked.
| [out] | mask | One bit per block, the first block in the most significant bit |
| bank | Bank the blocks are in | |
| block_pointer | First block the mask covers, in units of sixteen | |
| block_range | Words of mask to ask for, each covering sixteen blocks |
| Result m5::uhf::UHFLayer::readNxpConfigWord | ( | uint16_t & | config | ) |
Read the Config-Word of an NXP UCODE G2X.
| [out] | config | Word the tag holds |
The word carries the read protection, the Product Status Flag and the range reduction among other things. Which bit is which is in the chip's own datasheet
| Result m5::uhf::UHFLayer::readQTParameters | ( | QTParameters & | qt | ) |
Read the QT control word of the selected tag.
| [out] | qt | What the tag answered |
| bool m5::uhf::UHFLayer::select | ( | const Tag & | tag, |
| const uint32_t | access_password = 0, | ||
| const bool | verify = true ) |
Point subsequent tag operations at one tag.
| tag | Target tag, whose EPC becomes the mask |
| access_password | Access password of the tag, 0 when it has none |
| verify | Read one word back to confirm that the tag answers |
| bool m5::uhf::UHFLayer::select | ( | const Tid & | tid, |
| const uint32_t | access_password = 0, | ||
| const bool | verify = true ) |
Select by TID.
| tid | TID of the target tag |
| access_password | Access password of the tag, 0 when it has none |
| verify | Read one word back to confirm that the tag answers |
The TID is locked at manufacture, so a mask built from it keeps working across an EPC rewrite. The tag has to have been identified first, since detection alone only ever reveals an EPC
| Result m5::uhf::UHFLayer::toggleNxpConfigWord | ( | uint16_t & | config, |
| const uint16_t | toggle ) |
Invert bits of the Config-Word of an NXP UCODE G2X.
| [out] | config | Word the tag holds afterwards |
| toggle | Bits to invert |
The word is toggled rather than assigned: a one inverts the bit it stands over and a zero leaves it alone, so sending the same bits twice puts the word back. That is the command the chip offers, and calling it a write would say something else
| Result m5::uhf::UHFLayer::writeBank | ( | const Bank | bank, |
| const uint16_t | word_address, | ||
| const uint8_t * | data, | ||
| const uint16_t | data_len ) |
Write a memory bank.
| bank | Memory bank |
| word_address | Start address in 16-bit words |
| data | Bytes to write |
| data_len | Their length, which has to be a whole number of 16-bit words |
| Result m5::uhf::UHFLayer::writeNxpEAS | ( | const bool | enable | ) |
Set or clear the Product Status Flag of an NXP UCODE G2X.
| enable | True to assert the flag, false to clear it |
A tag whose flag is asserted answers nxpEASAlarm()
| Result m5::uhf::UHFLayer::writeQTParameters | ( | const QTParameters & | qt, |
| const bool | persistent = false ) |
Write the QT control word of the selected tag.
| qt | What to write |
| persistent | True to write it where a loss of power does not undo it |
Switching to the public map hides the tag's user memory, the longer half of its EPC, and all of its TID but the first two words. The tag answers with an EPC of its own kept for that purpose, so afterwards it looks like a different tag