uFCoder 2.62
Loading...
Searching...
No Matches
Communication with the reader

Functions related to establishing, closing and changing speed of communication with the reader and more. More...

Functions

UFR_STATUS DL_API ReaderClose (void)
 Close reader communication port.
 
UFR_STATUS DL_API ReaderOpen (void)
 Opens reader communication port for all µFR devices. You can also use this function to open communication with µFR Online devices.
 
UFR_STATUS DL_API ReaderOpen_uFROnline (c_string serial_number)
 Opens uFR Online device by serial number.
 
UFR_STATUS DL_API ReaderOpenByType (uint32_t reader_type)
 Opens a port of connected reader using readers family type. Useful for speed up opening for non uFR basic reader type (e.g. BaseHD with uFR support).
 
UFR_STATUS DL_API ReaderOpenEx (uint32_t reader_type, IN c_string port_name, uint32_t port_interface, IN void *arg)
 Open reader communication port in several different ways. Can be used for establishing communication with COM port too.
 
UFR_STATUS DL_API ReaderReset (void)
 Physical reset of reader communication port.
 
UFR_STATUS DL_API ReaderResetWait (void)
 Physical reset of reader communication port & tests the communication before returning a UFR_STATUS code.
 
UFR_STATUS DL_API ReaderSoftRestart (void)
 This function is used to restart the reader by software. It sets all readers parameters to default values and close RF field which resets all the cards in the field.
 
UFR_STATUS DL_API SetDefaultUartSpeed (uint8_t reader_type, uint8_t comm_type, IN c_string port_name)
 This function returns communication speed (UART baud rate) to default value.
 
UFR_STATUS DL_API SetUartSpeed (uint32_t baud_rate)
 This function sets communication speed (UART baud rate).
 

Detailed Description

Functions related to establishing, closing and changing speed of communication with the reader and more.

Function Documentation

◆ ReaderClose()

UFR_STATUS DL_API ReaderClose ( void )

Close reader communication port.

Returns
Operation status

◆ ReaderOpen()

UFR_STATUS DL_API ReaderOpen ( void )

Opens reader communication port for all µFR devices. You can also use this function to open communication with µFR Online devices.

Using ReaderOpen to open communication with µFR Online devices: If you have only one reader attached to your PC, it will open that reader serial port on 1Mbit/s. If you have more than one µFR Online device, ReaderOpen function will open the first one found, for the device not connected to the PC via cable, use ReaderOpenEx() instead.
NOTE: On Android, using ReaderOpen() will establish communication with uFR Series readers connected via OTG cable.

Returns
Operation status

◆ ReaderOpen_uFROnline()

UFR_STATUS DL_API ReaderOpen_uFROnline ( c_string serial_number)

Opens uFR Online device by serial number.

Function will open communication (UDP or TCP) with device based on its working mode. If function cannot find given serial number, it will open communication on serial port with 1Mbit/s.

Parameters
serial_numberPointer to const char array (c_string) containing devices serial number (ex. “ON101390”).
Returns
Operation status

◆ ReaderOpenByType()

UFR_STATUS DL_API ReaderOpenByType ( uint32_t reader_type)

Opens a port of connected reader using readers family type. Useful for speed up opening for non uFR basic reader type (e.g. BaseHD with uFR support).

Do not use this function for opening communication with µFR Online devices.

Parameters
reader_type0 : auto - same as call ReaderOpen() 1 : uFR type (1 Mbps) 2 : uFR RS232 type (115200 bps) 3 : BASE HD uFR type (250 Kbps)
Returns
Operation status

◆ ReaderOpenEx()

UFR_STATUS DL_API ReaderOpenEx ( uint32_t reader_type,
IN c_string port_name,
uint32_t port_interface,
IN void * arg )

Open reader communication port in several different ways. Can be used for establishing communication with COM port too.

There is enumeration in uFCoder.h file called E_READER_TYPE with values: enum E_READER_TYPE { AUTO = 0, UFR_TYPE = 1, UFR_RS232_TYPE = 2, BASEHD_UFR_TYPE = 3, UFR_ONLINE_TYPE = 4, INTERNAL_NFC = 5 }; Values in this enumeration you can pass into ReaderOpenEx function as reader_type parameter.
For example, if you pass 4 as reader_type it will only work with µFR Online Series devices, and then as port_name you can pass devices IP address or serial number (ex: “192.168.1.123” or “ON101390”), for port_interface you can pass ‘U’ for UDP, ‘T’ for TCP or 0. If you pass 0, it will automatically search for reader working mode (UDP or TCP) and open it. For argument you can pass 0 or µFR Nano device serial number to open it on 1Mbit/s (ex: “UN123456”).
Using value 5 as reader_type implies usage of internal mobile device NFC. Upon a call to ReaderOpenEx with this parameter, the library will try to obtain license automatically via HTTP. On success, a valid license is stored for future use. On failure, it moves to looking up for stored licenses. Results other than UFR_OK status imply a corresponding error that occurred and as such use of internal mobile device NFC will be unavailable. When using 5 as reader_type, additionally you can specify port_interface parameter to decide whether to do online->offline validation or just offline. To use offline-only validation of a previously stored valid DLogic license, set port_interface to 1. Value 0 is default value for port_interface and implies online->offline license validation. More examples for port open are given in the “Reader Open Examples” document: https://www.d-logic.com/code/nfc-rfid-reader-sdk/ufr-doc/blob/master/Reader_Open_Examples.pdf Examples: ReaderOpenEx(1, “COM1”, 0, 0) This example will open communication with µFR device attached to COM1 port on 1Mbit/s ReaderOpenEx(1, 0, 0, 0) This example will automatically find COM port and open communication with first µFR device on 1Mbit/s ReaderOpenEx(2, 0, 0, 0) This example will automatically find COM port and open communication with first µFR RS232 device on 115200 bit/s ReaderOpenEx(4, “ON123456”, ‘U’, 0) This example will open communication with µFR Online reader with serial number ON123456 on UDP protocol. ReaderOpenEx(4, “ON123456”, ‘T’, 0) This example will open communication with µFR Online reader with serial number ON123456 on TCP protocol. ReaderOpenEx(4, “192.168.1.123”, ‘U’, 0) This example will open communication with µFR Online reader with IP address 192.168.1.123 on UDP protocol. ReaderOpenEx(4, “192.168.1.123”, ‘T’, 0) This will open communication with µFR Online reader with IP address 192.168.1.123 on TCP protocol. ReaderOpenEx(4, “192.168.1.123”, 0, 0) It will open communication with µFR Online reader with IP address 192.168.1.123 based on its working protocol (UDP or TCP), because we passed 0 as port_interface ReaderOpenEx(4, “ON123456”, 0, 0) It will open communication with µFR Online reader with serial number ON123456 based on its working protocol (UDP or TCP), because we passed 0 as port_interface ReaderOpenEx(4, “ON123456”, 0, “UN654321”) It will open communication with µFR Nano reader on 1Mbit/s with serial number UN654321 which is attached to µFR Online device with serial number ON123456 ReaderOpenEx(4, “192.168.1.123”, 0, “UN654321”) It will open communication with µFR Nano reader on 1Mbit/s with serial number UN654321 which is attached to µFR Online device with IP address 192.168.1.123

Parameters
reader_type0 : auto - same as call ReaderOpen() 1 : uFR type (1 Mbps) 2 : uFR RS232 type (115200 bps) 3 : BASE HD uFR type (250 Kbps) When uFR Online reader works in BT serial mode or transparent mode, reader_type must be set to 1.
port_nameis c-string type used to open port by given serial name. If you provide NULL or empty string that is AUTO MODE which calls ReaderOpenEx() and all available ports on the system. serial port name, identifier, like "COM3" on Windows or "/dev/ttyS0" on Linux or "/dev/tty.serial1" on OS X or if you select FTDI, reader serial number like "UN123456", if reader have integrated FTDI interface When the UDP interface type is selected, port_name must be provided in “address:port” format. Like "192.168.1.162:8881" IP for UDP I/F
port_interfacetype of communication interfaces (define interface which we use while connecting to the printer), supported value's: 0 : auto - first try FTDI than serial if port_name is not defined 1 : try serial / virtual COM port / interfaces 2 : try only FTDI communication interfaces 10 : try to open Digital Logic Shields with RS232 uFReader on Raspberry Pi (serial interfaces with GPIO reset) 84 ('T') : TCP/IP interface 85 ('U') : UDP interface 102 ('B'): BT serial interface. Android library only. 114 ('L'): BLE interface. Android library only. When uFR Online reader works in BT serial mode, port_interface must be set to 0 (Except Android). arg C-string with additional settings delimited with new lines. Settings C-string constant: “UNIT_OPEN_RESET_DISABLE” : do not reset the reader when opening “UNIT_OPEN_RESET_FORCE” : force reset the reader when opening “UNIT_OPEN_RESET_ONLY”: only resets the device and will not send additional commands that are used when establishing communication with the reader. "READER_ACTIVE_ON_RTS_LOW" : (default) Reset the reader when RTS is high - the reader works when RTS is low "READER_ACTIVE_ON_RTS_HIGH" : Reset the reader when RTS is low - the reader works when RTS is high "RTS_ALWAYS_HIGH" : not implemented yet "RTS_ALWAYS_LOW" : not implemented yet "RTS_DISCONNECTED" : disconnect RTS (RTS is not initiate nor use) When uFR Online reader works in BT serial mode or transparent mode, arg must be set to “UNIT_OPEN_RESET_DISABLE”. Custom baud rates from library version 5.0.28. For all RS232 devices and USB devices from firmware version 5.0.31 "BR_1000000" : 1 Mbps "BR_115200" : 115200 bps "BR_250000" : 250000 bps "BR_9600" : 9600 bps "BR_19200" : 19200 bps "BR_38400" : 38400 bps "BR_57600" : 57600 bps "BR_230400" : 234000 bps "BR_460800" : 460800 bps "BR_500000" : 500000 bps
argC-string with additional settings delimited with new lines. Settings C-string constant: “UNIT_OPEN_RESET_DISABLE” : do not reset the reader when opening “UNIT_OPEN_RESET_FORCE” : force reset the reader when opening “UNIT_OPEN_RESET_ONLY”: only resets the device and will not send additional commands that are used when establishing communication with the reader. "READER_ACTIVE_ON_RTS_LOW" : (default) Reset the reader when RTS is high - the reader works when RTS is low "READER_ACTIVE_ON_RTS_HIGH" : Reset the reader when RTS is low - the reader works when RTS is high "RTS_ALWAYS_HIGH" : not implemented yet "RTS_ALWAYS_LOW" : not implemented yet "RTS_DISCONNECTED" : disconnect RTS (RTS is not initiate nor use) When uFR Online reader works in BT serial mode or transparent mode, arg must be set to “UNIT_OPEN_RESET_DISABLE”. Custom baud rates from library version 5.0.28. For all RS232 devices and USB devices from firmware version 5.0.31 "BR_1000000" : 1 Mbps "BR_115200" : 115200 bps "BR_250000" : 250000 bps "BR_9600" : 9600 bps "BR_19200" : 19200 bps "BR_38400" : 38400 bps "BR_57600" : 57600 bps "BR_230400" : 234000 bps "BR_460800" : 460800 bps "BR_500000" : 500000 bps
Returns
Operation status

◆ ReaderReset()

UFR_STATUS DL_API ReaderReset ( void )

Physical reset of reader communication port.

Returns
Operation status

◆ ReaderResetWait()

UFR_STATUS DL_API ReaderResetWait ( void )

Physical reset of reader communication port & tests the communication before returning a UFR_STATUS code.

Returns
Operation status

◆ ReaderSoftRestart()

UFR_STATUS DL_API ReaderSoftRestart ( void )

This function is used to restart the reader by software. It sets all readers parameters to default values and close RF field which resets all the cards in the field.

Returns
Operation status

◆ SetDefaultUartSpeed()

UFR_STATUS DL_API SetDefaultUartSpeed ( uint8_t reader_type,
uint8_t comm_type,
IN c_string port_name )

This function returns communication speed (UART baud rate) to default value.

For RS23 devices default communication speed is 115200 bps, and for USB devices is 1000000 bps. For RS232 devices from version 5.0.1 (plus devices), and for USB devices from version 5.0.31.

Parameters
reader_type1 - USB 2 - RS232
comm_type1 - COM port 2 - FTDI
port_nameIf comm_type is FTDI enter empty string If comm_type is COM port Windows “COMx” Linux “/dev/ttyUSBx” Mac OS “/dev/tty.usbserial-xxxxxxxx”
Returns
Operation status

◆ SetUartSpeed()

UFR_STATUS DL_API SetUartSpeed ( uint32_t baud_rate)

This function sets communication speed (UART baud rate).

Allowed values of baud rate are: 9600, 19200, 38400, 57600, 115200, 230400, 460800, 500000, and 1000000 bps. All RS232 devices are supported, and USB devices (Nano FR, Classic) from firmware version 5.0.31.

Parameters
baud_rateUART baud rate
Returns
Operation status