API Reference
PN5180-tagomatic: USB connected RFID reader with Python interface.
Card
Bases: Protocol
Protocol for Cards
Source code in src/pn5180_tagomatic/cards.py
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 | |
id
property
Returns the card's unique id
memory_block_size
property
How big the memory blocks are. This is the smallest unit that can be written and read from the card.
Raises:
| Type | Description |
|---|---|
PN5180Error
|
If communication with the card fails. |
TimeoutError
|
If card does not respond. |
get_ndef(memory)
Find the NDEF memory.
If found, the start index in the input memory and its bytes are returned.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
memory
|
bytes
|
The card's memory, starting from 0 |
required |
Returns:
| Type | Description |
|---|---|
tuple[int, bytes] | None
|
(start, ndef_bytes), |
tuple[int, bytes] | None
|
or None if it wasn't found. |
Source code in src/pn5180_tagomatic/cards.py
125 126 127 128 129 130 131 132 133 134 135 136 137 | |
read_memory(offset=0, length=128)
Read memory from the card.
Cards normally can only read blocks of fixed sizes so the returned memory region may be larger than the requested length. At the end of the cards memory, some cards wrap around, others stop responding. So the returned memory may be shorter as well.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
offset
|
int
|
Starting offset (default: 0). |
0
|
length
|
int
|
Number of bytes to read (default: 128). |
128
|
Returns:
| Type | Description |
|---|---|
bytes
|
All read memory as a single bytes object. |
Raises:
| Type | Description |
|---|---|
PN5180Error
|
If communication with the card fails. |
TimeoutError
|
If card does not respond. |
Source code in src/pn5180_tagomatic/cards.py
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 | |
write_memory(offset, data)
Write memory to a card.
Cards can only write blocks of a fixed size. The offset needs to start at an even such multiple and the data needs to be of the right length as well.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
offset
|
int
|
Starting page number (default: 0). |
required |
data
|
bytes
|
32-bit data to write to that page |
required |
Raises:
| Type | Description |
|---|---|
PN5180Error
|
If communication with the card fails. |
TimeoutError
|
If card does not respond. |
MemoryWriteError
|
Other memory write failures. |
Source code in src/pn5180_tagomatic/cards.py
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 | |
ISO14443ACard
Bases: Card
Represents a connected ISO 14443-A card.
This class provides methods to interact with a card that has been successfully connected via the ISO 14443-A anticollision protocol.
Source code in src/pn5180_tagomatic/iso14443a.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 | |
id
property
Get the card's UniqueId.
memory_block_size
property
How big the memory blocks are
sak
property
Get the card's SAK response.
__init__(reader, card_id)
Initialize ISO14443ACard.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
reader
|
PN5180Helper
|
The PN5180 reader instance. |
required |
card_id
|
Iso14443AUniqueId
|
The card's UID + SAK |
required |
Source code in src/pn5180_tagomatic/iso14443a.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | |
authenticate_for_page(page_num, key_a, key_b)
Set authenticate keys for page.
For mifare cards, an authentication key is needed to read their pages. It can be different per page. When reading a page and they key is missing, the -1 page's keys are used.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
page_num
|
int
|
what page this key should be used for, -1 for setting default key |
required |
key_a
|
bytes | None
|
The new key, or None to remove the old one. |
required |
key_b
|
bytes | None
|
The new key, or None to remove the old one. |
required |
Source code in src/pn5180_tagomatic/iso14443a.py
238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 | |
decode_cc(cc)
Decode the CC memory block (block 0)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cc
|
bytes
|
The memory from block 0. |
required |
Returns:
| Type | Description |
|---|---|
tuple[int, int, int, bool] | None
|
(major_version, minor_version, memory size, is readonly) |
tuple[int, int, int, bool] | None
|
or None if CC isn't valid. |
Raises:
| Type | Description |
|---|---|
PN5180Error
|
If communication with the card fails. |
ValueError
|
If cc is less than 4 bytes. |
Source code in src/pn5180_tagomatic/iso14443a.py
266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 | |
get_ndef(memory)
Find the NDEF memory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
memory
|
bytes
|
The card's memory, starting from offset 0 |
required |
Returns:
| Type | Description |
|---|---|
tuple[int, bytes] | None
|
(start, ndef_bytes), |
tuple[int, bytes] | None
|
or None if NDEF couldn't be found. |
Source code in src/pn5180_tagomatic/iso14443a.py
295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 | |
write_memory(offset, data)
Write memory to a non-MIFARE Classic ISO 14443-A card.
This method writes memory pages from ISO 14443-A cards like NTAG that don't require authentication.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
offset
|
int
|
Starting page number (default: 0). |
required |
data
|
bytes
|
data to write to the page(s). |
required |
Raises:
| Type | Description |
|---|---|
PN5180Error
|
If communication with the card fails. |
TimeoutError
|
If card does not respond. |
MemoryWriteError
|
If memory write fails. |
ValueError
|
The bytes are not of an even page length or offset not aligned. |
Source code in src/pn5180_tagomatic/iso14443a.py
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 | |
ISO14443ACommand
Bases: IntEnum
ISO 14443-A protocol command bytes.
Source code in src/pn5180_tagomatic/constants.py
238 239 240 241 242 243 244 245 246 247 248 249 250 | |
ISO15693Card
Bases: Card
Represents a connected ISO 15693 card.
This class provides methods to interact with a card that has been successfully connected via the SELECT command.
Source code in src/pn5180_tagomatic/iso15693.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 | |
afi
property
Gets the AFI value, if supported by card
dsfid
property
Gets the DSFID value, if supported by card
ic_reference
property
Gets the IC reference value, if supported by card
id
property
Get the card's UID.
memory_number_of_blocks
property
Gets the number of blocks the card contains
__init__(reader, card_id)
Initialize ISO15693.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
reader
|
PN5180Helper
|
The PN5180 reader instance. |
required |
card_id
|
Iso15693UniqueId
|
The card's UID |
required |
Source code in src/pn5180_tagomatic/iso15693.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | |
decode_cc(cc)
Decode the CC memory block (block 0)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cc
|
bytes
|
The memory from block 0. |
required |
Returns:
| Type | Description |
|---|---|
tuple[int, int, int, bool] | None
|
(major_version, minor_version, memory size, is readonly) |
tuple[int, int, int, bool] | None
|
or None if CC isn't valid. |
Raises:
| Type | Description |
|---|---|
PN5180Error
|
If communication with the card fails. |
ValueError
|
If cc is less than 4 bytes. |
Source code in src/pn5180_tagomatic/iso15693.py
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 | |
get_ndef(memory)
Find the NDEF memory.
If found, the start index in the input memory and its bytes are returned.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
memory
|
bytes
|
The card's memory, starting from 0 |
required |
Returns:
| Type | Description |
|---|---|
tuple[int, bytes] | None
|
(start, ndef_bytes), |
tuple[int, bytes] | None
|
or None if it wasn't found. |
Source code in src/pn5180_tagomatic/iso15693.py
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 | |
get_system_information()
Get System information from card.
Returns:
| Type | Description |
|---|---|
dict[str, int]
|
The system info as a single bytes object. |
Raises:
| Type | Description |
|---|---|
PN5180Error
|
If communication with the card fails. |
Source code in src/pn5180_tagomatic/iso15693.py
209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 | |
read_memory(offset=0, length=None)
Read memory from card.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
offset
|
int
|
Starting offset, in bytes (default: 0) |
0
|
length
|
int | None
|
Number of bytes to read read (default: 128) |
None
|
Returns:
| Type | Description |
|---|---|
bytes
|
All read memory as a single bytes object. |
Raises:
| Type | Description |
|---|---|
PN5180Error
|
If communication with the card fails. |
Source code in src/pn5180_tagomatic/iso15693.py
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 | |
write_memory(offset, data)
Write to a card's memory
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
offset
|
int
|
Starting byte (default: 0). |
required |
data
|
bytes
|
|
required |
Raises:
| Type | Description |
|---|---|
PN5180Error
|
If communication with the card fails. |
Source code in src/pn5180_tagomatic/iso15693.py
260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 | |
ISO15693Command
Bases: IntEnum
ISO 15693 protocol command bytes.
Source code in src/pn5180_tagomatic/constants.py
253 254 255 256 257 258 259 260 261 262 263 264 265 266 | |
ISO15693Error
Bases: Exception
Exception raised when an ISO 15693 command returns an error response.
Source code in src/pn5180_tagomatic/constants.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | |
__init__(command, error_code, response_data)
Initialize ISO15693Error.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
command
|
int
|
The ISO 15693 command that triggered the error (8-bit value). |
required |
error_code
|
int
|
The error code from the tag's error response. |
required |
response_data
|
bytes
|
The full error response data from the tag. |
required |
Source code in src/pn5180_tagomatic/constants.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | |
Iso14443AUniqueId
Bases: UniqueId
ISO/IEC 14443A card identifiers. It also includes the SAK response.
Source code in src/pn5180_tagomatic/cards.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | |
sak_as_bytes()
The SAK response as bytes
Source code in src/pn5180_tagomatic/cards.py
39 40 41 | |
sak_as_string()
The SAK response as a string
Source code in src/pn5180_tagomatic/cards.py
43 44 45 | |
Iso15693UniqueId
Bases: UniqueId
ISO/IEC 15693 card identifiers.
Source code in src/pn5180_tagomatic/cards.py
54 55 56 57 58 59 60 61 62 63 64 65 66 67 | |
MemoryWriteError
Bases: Exception
Exception raised when memory_write returns an error response from card.
Source code in src/pn5180_tagomatic/constants.py
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | |
__init__(offset, error_code, response_data)
Initialize MemoryWriteError.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
offset
|
int
|
The offset that was written to. |
required |
error_code
|
int
|
The error code from the tag's error response. |
required |
response_data
|
bytes
|
The full error response data from the tag. |
required |
Source code in src/pn5180_tagomatic/constants.py
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | |
MifareKeyType
Bases: IntEnum
Mifare authentication key types.
Source code in src/pn5180_tagomatic/constants.py
68 69 70 71 72 | |
PN5180
High-level PN5180 RFID reader interface.
This class provides a convenient, high-level API for common RFID operations.
For direct hardware access, use the ll (low-level) attribute.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tty
|
str
|
The tty device path to communicate via. |
required |
Attributes:
| Name | Type | Description |
|---|---|---|
ll |
Low-level PN5180 interface for direct hardware access. |
Examples:
>>> from pn5180_tagomatic import *
>>> with PN5180("/dev/ttyACM0") as reader:
... # High-level API
... with reader.start_session(
... TxProtocol.ISO_14443_A_106, RxProtocol.ISO_14443_A_106
... ) as comm:
... card: Card = comm.connect_one_iso14443a()
... print(f"Found card: {card.id}")
... memory: bytes = card.read_memory()
...
... # Low-level access, when needed
... data: bytes = reader.ll.read_eeprom(0x12, 2)
... print("Read from EEPROM")
... print(f"Firmware version: {data[1]}.{data[0]}")
Source code in src/pn5180_tagomatic/pn5180.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | |
__enter__()
Context manager entry.
Source code in src/pn5180_tagomatic/pn5180.py
89 90 91 | |
__exit__(exc_type, exc_val, exc_tb)
Context manager exit.
Source code in src/pn5180_tagomatic/pn5180.py
93 94 95 | |
__init__(tty)
Initialize the PN5180 reader.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tty
|
str
|
The tty device path to communicate via. |
required |
Source code in src/pn5180_tagomatic/pn5180.py
47 48 49 50 51 52 53 | |
close()
Close the serial connection.
Source code in src/pn5180_tagomatic/pn5180.py
85 86 87 | |
start_session(tx_config, rx_config)
Start an RF communication session.
This method loads the RF configuration and turns on the RF field, then returns a PN5180RFSession object that manages the session. The RF field will be automatically turned off when the session ends.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tx_config
|
TxProtocol
|
TX configuration index (byte: 0-255, see table 32). |
required |
rx_config
|
RxProtocol
|
RX configuration index (byte: 0-255, see table 32). |
required |
Returns:
| Type | Description |
|---|---|
PN5180RFSession
|
PN5180RFSession object for managing the session. |
Raises:
| Type | Description |
|---|---|
PN5180Error
|
If the operation fails. |
Examples:
>>> reader = PN5180("/dev/ttyACM0")
>>> with reader.start_session(0x00, 0x80) as comm:
... card = comm.connect_one_iso14443a()
... uid = card.id.uid_as_bytes()
... memory = card.read_memory()
Source code in src/pn5180_tagomatic/pn5180.py
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | |
PN5180Error
Bases: Exception
Exception raised when a PN5180 operation fails.
Source code in src/pn5180_tagomatic/constants.py
9 10 11 12 13 14 15 16 17 18 19 20 21 | |
__init__(operation, error_code)
Initialize PN5180Error.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
operation
|
str
|
Name of the operation that failed. |
required |
error_code
|
int
|
The error code returned by the operation. |
required |
Source code in src/pn5180_tagomatic/constants.py
12 13 14 15 16 17 18 19 20 21 | |
PN5180Helper
Bases: PN5180Proxy
Helper methods for PN5180.
This class extends PN5180Proxy with convenience methods that build on the low-level RPC methods but are not direct RPC wrappers.
Source code in src/pn5180_tagomatic/proxy.py
554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 | |
change_mode_to_transceiver()
Change PN5180 mode to transceiver.
Sets the device to Idle state first, then initiates Transceiver state.
Source code in src/pn5180_tagomatic/proxy.py
622 623 624 625 626 627 628 629 630 | |
clear_rx_irq()
Clear RX IRQ in IRQ_STATUS register.
Source code in src/pn5180_tagomatic/proxy.py
632 633 634 | |
disable_all_irqs()
Disable all IRQs in IRQ_ENABLE register.
Source code in src/pn5180_tagomatic/proxy.py
640 641 642 | |
enable_only_rx_irq()
Enable only RX IRQ in IRQ_ENABLE register.
Source code in src/pn5180_tagomatic/proxy.py
636 637 638 | |
get_rx_data_len()
Read the RX_STATUS register and get the length bits.
Source code in src/pn5180_tagomatic/proxy.py
644 645 646 647 648 649 | |
read_received_data()
Returns received data, empty bytes, if none.
Source code in src/pn5180_tagomatic/proxy.py
651 652 653 654 655 656 | |
send_15693_request(command, parameters, is_inventory=False, slow_rate=False, dual_sub_carrier=False, protocol_extension=False, to_selected=False, option_flag=False, uid=None, afi=None)
Send ISO/IEC 15693 Request
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
command
|
int
|
The command's 8-bit value. |
required |
parameters
|
bytes
|
Up to 250 bytes to send. |
required |
is_inventory
|
bool
|
Only set for the INVENTORY command. |
False
|
slow_rate
|
bool
|
Use low data rate. |
False
|
dual_sub_carrier
|
bool
|
Use dual sub-carrier |
False
|
protocol_extension
|
bool
|
Sets that bit in flags. |
False
|
to_selected
|
bool
|
Sets Select flag bit in flags. |
False
|
option_flag
|
bool
|
Sets that bit in flags. |
False
|
uid
|
Iso15693UniqueId | None
|
Sets the UID flag bit and includes the uid after command. |
None
|
Raises:
| Type | Description |
|---|---|
PN5180Error
|
If communication fails. |
ValueError
|
Incorrect parameters to function. |
Source code in src/pn5180_tagomatic/proxy.py
686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 | |
send_and_receive(bits, data)
Send data and receive response.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bits
|
int
|
Number of valid bits in final byte (byte: 0-255). |
required |
data
|
bytes
|
Up to 260 bytes to send. |
required |
Returns:
| Type | Description |
|---|---|
bytes
|
Received data as bytes. Empty bytes() if no data was received. |
Raises:
| Type | Description |
|---|---|
PN5180Error
|
If communication fails. |
Source code in src/pn5180_tagomatic/proxy.py
658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 | |
send_and_receive_15693(command, parameters, is_inventory=False, slow_rate=False, dual_sub_carrier=False, protocol_extension=False, to_selected=False, option_flag=False, uid=None, afi=None)
Send ISO/IEC 15693 Request
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
command
|
int
|
The command's 8-bit value. |
required |
parameters
|
bytes
|
Up to 250 bytes to send. |
required |
is_inventory
|
bool
|
Only set for the INVENTORY command. |
False
|
slow_rate
|
bool
|
Use low data rate. |
False
|
dual_sub_carrier
|
bool
|
Use dual sub-carrier |
False
|
protocol_extension
|
bool
|
Sets that bit in flags. |
False
|
to_selected
|
bool
|
Sets Select flag bit in flags. |
False
|
option_flag
|
bool
|
Sets that bit in flags. |
False
|
uid
|
Iso15693UniqueId | None
|
Sets the UID flag bit and includes the uid after command. |
None
|
Returns:
| Type | Description |
|---|---|
bytes
|
Received data as bytes. Empty bytes() if no data was received. |
Raises:
| Type | Description |
|---|---|
ISO15693Error
|
If the tag returns an error response. |
TimeoutError
|
If no response is received within timeout. |
PN5180Error
|
If communication with the PN5180 fails. |
Source code in src/pn5180_tagomatic/proxy.py
762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 | |
send_and_wait_for_ack(bits, data)
Send a request and wait for an ACK/NACK response.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bits
|
int
|
Number of valid bits in the data to send. |
required |
data
|
bytes
|
Payload bytes to transmit. |
required |
Returns:
| Type | Description |
|---|---|
bytes
|
The raw response bytes received from the PN5180. |
Raises:
| Type | Description |
|---|---|
TimeoutError
|
If no response is received within the configured timeout. |
Source code in src/pn5180_tagomatic/proxy.py
830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 | |
set_rx_crc_and_first_bit(on, bit_start=0)
Set RX_CRC_ENABLE and RX_BIT_ALIGN fields
Enables/disables CRC verification for reception, sets the RX_BIT_ALIGN field as needed for the first received bits.
Source code in src/pn5180_tagomatic/proxy.py
601 602 603 604 605 606 607 608 609 610 611 612 | |
turn_off_crc()
Turn off CRC for TX and RX. Sets RX_BIT_ALIGN to 0
Disables CRC calculation and verification for transmission and reception.
Source code in src/pn5180_tagomatic/proxy.py
577 578 579 580 581 582 583 | |
turn_off_rx_crc()
Turn off CRC for RX.
Disables CRC verification for reception.
Source code in src/pn5180_tagomatic/proxy.py
561 562 563 564 565 566 567 | |
turn_off_tx_crc()
Turn off CRC for TX.
Disables CRC calculation for transmission.
Source code in src/pn5180_tagomatic/proxy.py
569 570 571 572 573 574 575 | |
turn_on_crc()
Turn on CRC for TX and RX. Sets RX_BIT_ALIGN to 0
Enables CRC calculation and verification for transmission and reception.
Source code in src/pn5180_tagomatic/proxy.py
614 615 616 617 618 619 620 | |
turn_on_rx_crc()
Turn on CRC for RX.
Enables CRC verification for reception.
Source code in src/pn5180_tagomatic/proxy.py
585 586 587 588 589 590 591 | |
turn_on_tx_crc()
Turn on CRC for TX.
Enables CRC calculation for transmission.
Source code in src/pn5180_tagomatic/proxy.py
593 594 595 596 597 598 599 | |
PN5180Proxy
Low-level PN5180 RFID reader interface.
This class provides direct access to the PN5180 RFID reader's RPC methods via the SimpleRPC protocol. It contains only the low-level methods that directly communicate with the hardware.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tty
|
str
|
The tty device path to communicate via. |
required |
Examples:
>>> from pn5180_tagomatic import PN5180Proxy
>>> reader = PN5180Proxy("/dev/ttyACM0")
>>> reader.reset()
Source code in src/pn5180_tagomatic/proxy.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 | |
__enter__()
Context manager entry.
Source code in src/pn5180_tagomatic/proxy.py
545 546 547 | |
__exit__(exc_type, exc_val, exc_tb)
Context manager exit.
Source code in src/pn5180_tagomatic/proxy.py
549 550 551 | |
__init__(tty)
Initialize the PN5180 low-level reader.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tty
|
str
|
The tty device path to communicate via. |
required |
Source code in src/pn5180_tagomatic/proxy.py
51 52 53 54 55 56 57 | |
close()
Close the serial connection.
Source code in src/pn5180_tagomatic/proxy.py
540 541 542 543 | |
epc_inventory(select_command, select_command_final_bits, begin_round, timeslot_behavior)
Start EPC inventory algorithm.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
select_command
|
bytes
|
Up to 39 bytes. |
required |
select_command_final_bits
|
int
|
Number of valid bits in final byte (byte: 0-255). |
required |
begin_round
|
bytes
|
Exactly 3 bytes. |
required |
timeslot_behavior
|
int
|
Timeslot behavior (TimeslotBehavior enum): - MAX_TIMESLOTS (0): NextSlot issued until buffer full - SINGLE_TIMESLOT (1): Algorithm pauses after one timeslot - SINGLE_WITH_HANDLE (2): Req_Rn issued if valid tag response |
required |
Raises:
| Type | Description |
|---|---|
PN5180Error
|
If the operation fails. |
Source code in src/pn5180_tagomatic/proxy.py
386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 | |
epc_resume_inventory()
Continue EPC inventory algorithm.
Raises:
| Type | Description |
|---|---|
PN5180Error
|
If the operation fails. |
Source code in src/pn5180_tagomatic/proxy.py
436 437 438 439 440 441 442 443 444 | |
epc_retrieve_inventory_result_size()
Get result size from EPC algorithm.
Returns:
| Type | Description |
|---|---|
int
|
Result size in bytes. |
Raises:
| Type | Description |
|---|---|
PN5180Error
|
If the operation fails. |
Source code in src/pn5180_tagomatic/proxy.py
446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 | |
is_irq_set()
Is the IRQ pin set.
Returns:
| Type | Description |
|---|---|
bool
|
True if IRQ is set. |
Source code in src/pn5180_tagomatic/proxy.py
517 518 519 520 521 522 523 | |
load_rf_config(tx_config, rx_config)
Load RF config settings for RX/TX.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tx_config
|
TxProtocol
|
TX configuration index (byte: 0-255, see table 32). |
required |
rx_config
|
RxProtocol
|
RX configuration index (byte: 0-255, see table 32). |
required |
Raises:
| Type | Description |
|---|---|
PN5180Error
|
If the operation fails. |
Source code in src/pn5180_tagomatic/proxy.py
463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 | |
mifare_authenticate(key, key_type, block_addr, mifare_uid)
Authenticate to mifare card.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
bytes
|
6 byte key. |
required |
key_type
|
int
|
MifareKeyType.KEY_A (0x60) or MifareKeyType.KEY_B (0x61). |
required |
block_addr
|
int
|
Block address (byte: 0-255). |
required |
mifare_uid
|
int
|
card's UID (32-bit) |
required |
Returns:
| Type | Description |
|---|---|
int
|
Authentication result: 0=authenticated, 1=permission denied, 2=timeout. |
Raises:
| Type | Description |
|---|---|
PN5180Error
|
If the operation fails with error < 0. |
Source code in src/pn5180_tagomatic/proxy.py
348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 | |
read_data(length)
Read from RX buffer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
length
|
int
|
Number of bytes to read (max 508, 16-bit value: 0-65535). |
required |
Returns:
| Type | Description |
|---|---|
bytes
|
Bytes read from RX buffer. |
Raises:
| Type | Description |
|---|---|
PN5180Error
|
If the operation fails. |
Source code in src/pn5180_tagomatic/proxy.py
303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 | |
read_eeprom(addr, length)
Read from the EEPROM.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
addr
|
int
|
EEPROM address (byte: 0-255). |
required |
length
|
int
|
Number of bytes to read (byte: 0-255). |
required |
Returns:
| Type | Description |
|---|---|
bytes
|
Bytes read from EEPROM. |
Raises:
| Type | Description |
|---|---|
PN5180Error
|
If the operation fails. |
Source code in src/pn5180_tagomatic/proxy.py
251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 | |
read_register(addr)
Read from a PN5180 register.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
addr
|
int
|
Register address (byte: 0-255). |
required |
Returns:
| Type | Description |
|---|---|
int
|
32-bit register value. |
Raises:
| Type | Description |
|---|---|
PN5180Error
|
If the operation fails. |
Source code in src/pn5180_tagomatic/proxy.py
192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 | |
read_register_multiple(addrs)
Read from multiple PN5180 registers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
addrs
|
list[int]
|
List of up to 18 register addresses (each byte: 0-255). |
required |
Returns:
| Type | Description |
|---|---|
list[int]
|
List of 32-bit register values. |
Raises:
| Type | Description |
|---|---|
PN5180Error
|
If the operation fails. |
Source code in src/pn5180_tagomatic/proxy.py
210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 | |
reset()
Reset the PN5180 NFC frontend.
This method calls the reset function on the Arduino device, which performs a hardware reset of the PN5180 module.
Source code in src/pn5180_tagomatic/proxy.py
79 80 81 82 83 84 85 | |
rf_off()
Turn off RF field.
Raises:
| Type | Description |
|---|---|
PN5180Error
|
If the operation fails. |
Source code in src/pn5180_tagomatic/proxy.py
507 508 509 510 511 512 513 514 515 | |
rf_on(disable_collision_avoidance=False, use_active_communication=False)
Turn on RF field.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
disable_collision_avoidance
|
bool
|
Turn off collision avoidance for ISO/IEC 18092. |
False
|
use_active_communication
|
bool
|
Use Active Communication mode. |
False
|
Raises:
| Type | Description |
|---|---|
PN5180Error
|
If the operation fails. |
Source code in src/pn5180_tagomatic/proxy.py
484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 | |
send_data(bits, values)
Write to TX buffer and send it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bits
|
int
|
Number of valid bits in final byte (byte: 0-255). |
required |
values
|
bytes
|
Up to 260 bytes to send. |
required |
Raises:
| Type | Description |
|---|---|
PN5180Error
|
If the operation fails. |
Source code in src/pn5180_tagomatic/proxy.py
286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 | |
switch_mode(mode, params)
Switch mode.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mode
|
int
|
Operating mode (SwitchMode.STANDBY, LPCD, or AUTOCOLL). |
required |
params
|
list[int]
|
List of mode-specific parameters (each byte: 0-255). |
required |
Raises:
| Type | Description |
|---|---|
PN5180Error
|
If the operation fails. |
Source code in src/pn5180_tagomatic/proxy.py
323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 | |
test_it()
Run a basic self-test on the PN5180 NFC frontend.
This method invokes the underlying Arduino test_it RPC to verify
communication with the PN5180 and perform a simple hardware check.
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
Status code from the Arduino implementation:
* |
Raises:
| Type | Description |
|---|---|
Exception
|
Any communication or transport-related exception
raised by the underlying :class: |
Source code in src/pn5180_tagomatic/proxy.py
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 | |
wait_for_irq(timeout_ms)
Wait up to a timeout value for the IRQ to be set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
timeout_ms
|
int
|
Time in milliseconds to wait (16-bit value: 0-65535). |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if IRQ is set. |
Source code in src/pn5180_tagomatic/proxy.py
525 526 527 528 529 530 531 532 533 534 535 536 537 538 | |
write_eeprom(addr, values)
Write to the EEPROM.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
addr
|
int
|
EEPROM address (byte: 0-255). |
required |
values
|
bytes
|
Up to 255 bytes to write. |
required |
Raises:
| Type | Description |
|---|---|
PN5180Error
|
If the operation fails. |
Source code in src/pn5180_tagomatic/proxy.py
234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 | |
write_register(addr, value)
Write to a PN5180 register.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
addr
|
int
|
Register address (byte: 0-255). |
required |
value
|
int
|
32-bit value to write (0-2^32-1). |
required |
Raises:
| Type | Description |
|---|---|
PN5180Error
|
If the operation fails. |
Source code in src/pn5180_tagomatic/proxy.py
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 | |
write_register_and_mask(addr, value)
Write to a PN5180 register AND the old value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
addr
|
int
|
Register address (byte: 0-255). |
required |
value
|
int
|
32-bit mask to AND (0-2^32-1). |
required |
Raises:
| Type | Description |
|---|---|
PN5180Error
|
If the operation fails. |
Source code in src/pn5180_tagomatic/proxy.py
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 | |
write_register_multiple(elements)
Write to multiple PN5180 registers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
elements
|
list[tuple[int, int, int]]
|
List of (address, op, value/mask) tuples. address: byte (0-255) op: RegisterOperation (1=SET, 2=OR, 3=AND) value/mask: 32-bit value (0-2^32-1) |
required |
Raises:
| Type | Description |
|---|---|
PN5180Error
|
If the operation fails. |
Source code in src/pn5180_tagomatic/proxy.py
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 | |
write_register_or_mask(addr, value)
Write to a PN5180 register OR the old value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
addr
|
int
|
Register address (byte: 0-255). |
required |
value
|
int
|
32-bit mask to OR (0-2^32-1). |
required |
Raises:
| Type | Description |
|---|---|
PN5180Error
|
If the operation fails. |
Source code in src/pn5180_tagomatic/proxy.py
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 | |
write_tx_data(values)
Write to tx buffer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
values
|
bytes
|
Up to 260 bytes to write. |
required |
Raises:
| Type | Description |
|---|---|
PN5180Error
|
If the operation fails. |
Source code in src/pn5180_tagomatic/proxy.py
271 272 273 274 275 276 277 278 279 280 281 282 283 284 | |
PN5180RFSession
Manages RF communication session.
This class handles the lifecycle of an RF communication session, ensuring that the RF field is turned off when the session ends.
Source code in src/pn5180_tagomatic/session.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 | |
__del__()
Cleanup when object is destroyed.
Source code in src/pn5180_tagomatic/session.py
456 457 458 | |
__enter__()
Context manager entry.
Source code in src/pn5180_tagomatic/session.py
448 449 450 | |
__exit__(exc_type, exc_val, exc_tb)
Context manager exit.
Source code in src/pn5180_tagomatic/session.py
452 453 454 | |
__init__(reader)
Initialize PN5180RFSession.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
reader
|
PN5180Helper
|
The PN5180 reader instance. |
required |
Source code in src/pn5180_tagomatic/session.py
26 27 28 29 30 31 32 33 | |
close()
Close the communication session and turn off RF field.
Source code in src/pn5180_tagomatic/session.py
442 443 444 445 446 | |
connect_iso14443a(card_id)
Select an ISO/IEC 14443A card and return an object representing it.
Source code in src/pn5180_tagomatic/session.py
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | |
connect_iso15693(card_id)
Connect to an ISO 15693 card.
This method selects an ISO 15693 card and returns a card object.
Args: card_id: A unique identifier for the card.
Returns:
| Type | Description |
|---|---|
ISO15693Card
|
ISO15693Card object representing the connected card. |
Raises:
| Type | Description |
|---|---|
PN5180Error
|
If communication with the card fails. |
ValueError
|
If the card's response is invalid. |
TimeoutError
|
If no card responds. |
Source code in src/pn5180_tagomatic/session.py
414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 | |
connect_one_iso14443a()
Connect to an ISO 14443-A card.
This method performs the ISO 14443-A anticollision protocol to retrieve the card's UID and returns a card object.
Returns:
| Type | Description |
|---|---|
ISO14443ACard
|
ISO14443ACard object representing the connected card. |
Raises:
| Type | Description |
|---|---|
PN5180Error
|
If communication with the card fails. |
ValueError
|
If the card's response is invalid. |
TimeoutError
|
If no card responds. |
Source code in src/pn5180_tagomatic/session.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | |
get_all_iso14443a_uids(wake_up_first=True, halt_when_found=True, max_cards=32)
Get the UIDs of ISO 14443-A cards using anticollision protocol.
Cards may be halted after discovery.
If called again without "wake_up_first", cards that have previously been halted might not be found again. It depends on the cards' UIDs relative to each other.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
wake_up_first
|
bool
|
Send WUPA first to wake up halted cards. |
True
|
halt_when_found
|
bool
|
Send HLTA to found cards. |
True
|
max_cards
|
int
|
The maximum number of cards that can be found. |
32
|
Returns:
| Type | Description |
|---|---|
list[Iso14443AUniqueId]
|
A list of the card's IDs. |
Raises:
| Type | Description |
|---|---|
PN5180Error
|
If communication with the card fails. |
ValueError
|
If the card's response is invalid. |
Source code in src/pn5180_tagomatic/session.py
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 | |
iso15693_inventory(slots=16, mask_length=0, afi=None)
Perform ISO 15693 inventory to find tags.
This method implements the ISO 15693 inventory protocol to discover tags in the RF field. It uses 16 slots by default for anticollision.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
slots
|
int
|
Number of slots for anticollision (default: 16). Must be 16 for mask_length 0. |
16
|
mask_length
|
int
|
Length of mask (default: 0). |
0
|
Returns:
| Type | Description |
|---|---|
list[Iso15693UniqueId]
|
List of UniqueIds found. |
Raises:
| Type | Description |
|---|---|
PN5180Error
|
If communication fails. |
Examples:
>>> with reader.start_session(0x0D, 0x8D) as session:
... card_ids = session.iso15693_inventory()
... for card_id in card_ids:
... print(f"Found UID: {card_id}")
Source code in src/pn5180_tagomatic/session.py
332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 | |
RegisterOperation
Bases: IntEnum
Register write operations for write_register_multiple.
Source code in src/pn5180_tagomatic/constants.py
75 76 77 78 79 80 | |
Registers
Bases: IntEnum
PN5180 register addresses.
Source code in src/pn5180_tagomatic/constants.py
192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 | |
SwitchMode
Bases: IntEnum
PN5180 operating modes.
Source code in src/pn5180_tagomatic/constants.py
83 84 85 86 87 88 | |
TimeslotBehavior
Bases: IntEnum
EPC inventory timeslot behavior options.
Source code in src/pn5180_tagomatic/constants.py
91 92 93 94 95 96 | |
UniqueId
Bases: Protocol
Represents a cards unique identifier. Subtypes contain type specific extensions.
Source code in src/pn5180_tagomatic/cards.py
9 10 11 12 13 14 15 16 17 18 19 20 21 | |
__str__()
Returns a printable representation
Source code in src/pn5180_tagomatic/cards.py
20 21 | |
uid_as_bytes()
Returns the UID as bytes
Source code in src/pn5180_tagomatic/cards.py
14 15 | |
uid_as_string()
Returns the UID as a string
Source code in src/pn5180_tagomatic/cards.py
17 18 | |