giraut / pyufr Goto Github PK
View Code? Open in Web Editor NEWPython3 library to communicate with Digital Logic µFR-series NFC readers (https://www.d-logic.net/)
License: GNU General Public License v3.0
Python3 library to communicate with Digital Logic µFR-series NFC readers (https://www.d-logic.net/)
License: GNU General Public License v3.0
pyuFR ----- v0.4.0 Pure Python communication class for Digital Logic uFR-series NFC readers ------------------------------------------------------------------------ This is a Python class to communicate with Digital Logic uFR-series NFC readers such as the uFR Nano or Nano Online (https://www.d-logic.net/). Communication options include serial, UDP, TCP, websocket and HTTP POST (REST). See test routine at the bottom of the class for usage examples. Why? Digital Logic provides a full library for most platform that's perfectly usable in Python (https://www.d-logic.net/code/nfc-rfid-reader-sdk/ufr-lib). However, it has several drawbacks: - Need to import a proprietary binary blob - If your device uses a FTDI USB-to-serial interface, you must disable the native Linux FTDI kernel modules (ftdi_sio and usbserial), as it conflicts with the Digital Logic library. If you have other USB serial devices connected to your system, this is not an option. - The Digital Logic library makes it difficult to debug low-level issues Fortunately, Digital Logic is very open with their serial protocol and has documented it fully and comprehensively. This class reimplements it in pure Python, and adds a few addiitional functions. The uFR COM protocol is specified here: https://github.com/nfc-rfid-reader-sdk/ufr-doc/raw/master/uFR_COM_Protocol.pdf Debian, RPM and Arch Linux packages are available here: https://github.com/Giraut/ppa https://github.com/Giraut/rpm https://aur.archlinux.org/packages/python-pyufr-git/ /!\ WARNING: work in progress /!\ uFR COM protocol command uFRcomm class method Status ---------------------------------------------------------------------------- GET_READER_TYPE get_reader_type() Implemented GET_READER_SERIAL get_reader_serial() Implemented GET_SERIAL_NUMBER get_serial_number() Implemented GET_HARDWARE_VERSION get_hardware_version() Implemented GET_FIRMWARE_VERSION get_firmware_version() Implemented GET_BUILD_NUMBER get_build_number() Implemented READER_KEY_WRITE N/A Not implemented USER_DATA_READ user_data_read() Implemented USER_DATA_WRITE user_data_write() Implemented READER_KEYS_LOCK N/A Not implemented READER_KEYS_UNLOCK N/A Not implemented READER_PASSWORD_WRITE N/A Not implemented SELF_RESET self_reset() Implemented SET_SPEED_PERMANENTLY N/A Not implemented GET_SPEED_PARAMETERS N/A Not implemented SET_UART_SPEED N/A Not implemented RED_LIGHT_CONTROL red_light_control() Implemented USER_INTERFACE_SIGNAL user_interface_signal() Implemented SET_RF_ANALOG_SETTINGS set_rf_analog_settings() Implemented GET_RF_ANALOG_SETTINGS get_rf_analog_settings() Implemented SET_LED_CONFIG set_led_config() Implemented DEFAULT_UART_SPEED_SESSION N/A Not implemented GET_CARD_ID get_card_id() Implemented GET_CARD_ID_EX get_card_id_ex() Implemented GET_DLOGIC_CARD_TYPE get_dlogic_card_type() Implemented GET_LAST_CARD_ID_EX get_last_card_id_ex() Implemented SECTOR_TRAILER_WRITE N/A Not implemented SECTOR_TRAILER_WRITE_UNSAFE N/A Not implemented BLOCK_READ N/A Not implemented BLOCK_WRITE N/A Not implemented BLOCK_IN_SECTOR_READ N/A Not implemented BLOCK_IN_SECTOR_WRITE N/A Not implemented LINEAR_READ linear_read() Partially tested LINEAR_WRITE N/A Not implemented LINEAR_FORMAT_CARD N/A Not implemented LIN_ROW_READ N/A Not implemented VALUE_BLOCK_READ N/A Not implemented VALUE_BLOCK_WRITE N/A Not implemented VALUE_BLOCK_INC N/A Not implemented VALUE_BLOCK_DEC N/A Not implemented VALUE_BLOCK_IN_SECTOR_READ N/A Not implemented VALUE_BLOCK_IN_SECTOR_WRITE N/A Not implemented VALUE_BLOCK_IN_SECTOR_INC N/A Not implemented VALUE_BLOCK_IN_SECTOR_DEC N/A Not implemented GET_DESFIRE_UID N/A Not implemented SET_DESFIRE_KEY N/A Not implemented DESFIRE_WRITE_TO_FILE N/A Not implemented DESFIRE_READ_FROM_FILE N/A Not implemented DESFIRE_CREATE_APPLICATION N/A Not implemented DESFIRE_CREATE_FILE N/A Not implemented DESFIRE_CREATE_AES_KEY N/A Not implemented DESFIRE_GET_KEY_CONFIG N/A Not implemented DESFIRE_CHANGE_KEY_CONFIG N/A Not implemented DESFIRE_DELETE_APPLICATION N/A Not implemented DESFIRE_DELETE_FILE N/A Not implemented DESFIRE_SET_CONFIGURATION N/A Not implemented DESFIRE_FORMAT_CARD N/A Not implemented DESFIRE_FREE_MEM N/A Not implemented DESFIRE_WRITE_AES_KEY N/A Not implemented DESFIRE_CREATE_VALUE_FILE N/A Not implemented DESFIRE_READ_VALUE_FILE N/A Not implemented DESFIRE_INCREASE_VALUE_FILE N/A Not implemented DESFIRE_DECREASE_VALUE_FILE N/A Not implemented DESFIRE_CREATE_RECORD_FILE N/A Not implemented DESFIRE_WRITE_RECORD N/A Not implemented DESFIRE_READ_RECORDS N/A Not implemented DESFIRE_CLEAR_RECORD N/A Not implemented DESFIRE_GET_APPLICATION_IDS N/A Not implemented MFP_FIRST_AUTHENTICATE N/A Not implemented MFP_CHANGE_REG_KEY N/A Not implemented MFP_GET_UID N/A Not implemented GET_NFC_T2T_VERSION N/A Not implemented READ_COUNTER N/A Not implemented INCREMENT_COUNTER N/A Not implemented NT4H_COMMON_CMD N/A Not implemented READ_ECC_SIGNATURE N/A Not implemented SET_CARD_ID_SEND_CONF set_card_id_send_conf() Implemented GET_CARD_ID_SEND_CONF get_card_id_send_conf() Implemented SET_BAD_SELECT_NR_MAX N/A Not implemented GET_BAD_SELECT_NR_MAX N/A Not implemented ENTER_SLEEP_MODE enter_sleep_mode() Implemented LEAVE_SLEEP_MODE leave_sleep_mode() Implemented AUTO_SLEEP_SET N/A Not implemented AUTO_SLEEP_GET N/A Not implemented WRITE_EMULATION_NDEF write_emulation_ndef() Implemented TAG_EMULATION_START tag_emulation_start() Implemented TAG_EMULATION_STOP tag_emulation_stop() Implemented AD_HOC_EMULATION_START ad_hoc_emulation_start() Implemented AD_HOC_EMULATION_STOP ad_hoc_emulation_stop() Implemented GET_EXTERNAL_FIELD_STATE get_external_field_state() Implemented GET_AD_HOC_EMULATION_PARAMS get_ad_hoc_emulation_params() Implemented SET_AD_HOC_EMULATION_PARAMS set_ad_hoc_emulation_params() Implemented SET_DISPLAY_DATA N/A Not implemented SET_SPEAKER_FREQUENCY set_speaker_frequency() Implemented SET_DISPLAY_INTENSITY N/A Not implemented GET_DISPLAY_INTENSITY N/A Not implemented UFR_XRC_LOCK_OPEN N/A Not implemented UFR_XRC_SET_RELAY_STATE N/A Not implemented UFR_XRC_GET_IO_STATE N/A Not implemented ENTER_SHARE_RAM_COMM_MODE N/A Not implemented EXIT_SHARE_RAM_COMM_MODE N/A Not implemented READ_SHARE_RAM N/A Not implemented WRITE_SHARE_RAM N/A Not implemented I_BLOCK_TRANSCEIVE N/A Not implemented R_BLOCK_TRANSCEIVE N/A Not implemented S_BLOCK_DESELECT s_block_deselect() Untested SET_ISO14443_4_MODE set_iso14443_4_mode() Implemented APDU_TRANSCEIVE apdu_transceive() Untested ENABLE_ANTI_COLLISION enable_anti_collision() Implemented DISABLE_ANTI_COLLISION disable_anti_collision() Implemented ENUM_CARDS enum_cards() Implemented LIST_CARDS list_cards() Implemented SELECT_CARD select_card() Implemented DESELECT_CARD deselect_card() Implemented GET_ANTI_COLLISION_STATUS get_anti_collision_status() Implemented ESP_SET_IO_STATE esp_set_io_state() Implemented ESP_GET_IO_STATE esp_get_io_state() Implemented ESP_READER_TIME_WRITE N/A Not implemented ESP_READER_TIME_READ N/A Not implemented ESP_READER_EEPROM_READ N/A Not implemented ESP_SET_DISPLAY_DATA esp_set_display_data() Implemented ESP_READER_RESET esp_reader_reset() Implemented ESP_READER_PASSWORD_WRITE N/A Not implemented ESP_READER_EEPROM_WRITE N/A Not implemented CHECK_UID_CHANGE check_uid_change() Implemented RF_RESET rf_reset() Implemented GET_READER_STATUS get_reader_status() Implemented ---------------------------------------------------------------------------- State of completion: 38% uFRcomm class-specific methods ---------------------------------------------------------------------------- close() flush() get_async_id() uFR class methods ---------------------------------------------------------------------------- open() nano_online_host_discovery() nano_online_subnet_discovery() --------------------------------------------------------- Bug reports? Questions? You can email me. Run this command to get my email address: C=base64\ -d;$C<<<Y205emEybHpRSEoxYm1KdmVDNWpiMjBLCg==|$C ---------------------------------------------------------
Hi,
I try to use your example async_id_beep.py to test our lib with a ufr XL
This is what I get:
python3 async_id_beep.py -d serial:///dev/ttyUSB0:1000000
Traceback (most recent call last):
File "./pyuFR-master/examples/async_id_beep.py", line 30, in
with uFR.open(args.device, restore_on_close = True) as ufr:
File "./pyuFR-master/examples/pyufr.py", line 742, in init
self.leave_sleep_mode()
File "./pyuFR-master/examples/pyufr.py", line 1845, in leave_sleep_mode
self._get_last_command_response(timeout = timeout)
File "./pyuFR-master/examples/pyufr.py", line 1186, in _get_last_command_response
answer: uFRanswer = self._get_answer(timeout = timeout)
File "./pyuFR-master/examples/pyufr.py", line 1014, in _get_answer
self.__recbuf.extend(self._get_data(timeout = timeout))
File "./pyuFR-master/examples/pyufr.py", line 871, in _get_data
raise TimeoutError
TimeoutError
When I cross-check with cutecom and sending there some hex commands it works. Sorry I am not into python so it may be something stupid.
Thanks Christian
Dear @Giraut ,
this seems like a great Python API. Is there a pypi package for it?
Also i wanted to know how to use the package for reading simple ID and sending HTTP request with it.
Can you maybe provide some examples how to get started with the package from 0?
For example:
Best regards
Chris!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.