Topic: How to use nfc_initiator_select_tag to wait for specific timeout

Hi,

How do we set the timeout to wait for a card to a specific timeout (ideally in milliseconds). Currently the only option I see is to use nfc_configure() to set DCO_INFINITE_SELECT to true or false.

Thanks,

snapdev

Re: How to use nfc_initiator_select_tag to wait for specific timeout

I'm using a while loop with a timeout in the exit guard (DCO_INFINITE_SELECT is false).

The body of the loop is something similar to:

time_t timeout = ...;
time_t start = now();
while (now() - start < timeout)
{
    if (nfc_select_tag(...))
        return true;
}

return false;

Re: How to use nfc_initiator_select_tag to wait for specific timeout

I was hoping for an alternative to polling. smile

Re: How to use nfc_initiator_select_tag to wait for specific timeout

There are possible registers/parameters to configure to let the PN53X chip poll for n-times during a .._select_tag()
Plus there is a way to set the time-out to a value related to milliseconds. If you both think this is a useful feature, we could think of a way to implement this into the nfc_configuration()

At the moment it takes a bool

bool nfc_configure(dev_info* pdi, const dev_config_option dco, const bool bEnable);

We could let it take a value

bool nfc_configure(dev_info* pdi, const dev_config_option dco, const dev_config_value dcv);

byte or longer?

typedef byte_t dev_config_value
typedef uint64_t dev_config_value

Thanks for the help!

Re: How to use nfc_initiator_select_tag to wait for specific timeout

The comparisons I could make would be with ioctl and setsockopt/getsockopt, both effectively take pointers. "SO_LINGER" springs to mind as an option that is timeout based.

I would avoid uint64_t types if possible, consider limited handheld devices.

Re: How to use nfc_initiator_select_tag to wait for specific timeout

hmm, I don't think there are many options that require more than a byte_t of value. So uint64_t or a buffer may would be just to much, right?

Re: How to use nfc_initiator_select_tag to wait for specific timeout

Some options

(a) uint32_t for all options
(b) each option only holds the size of data they actually need
(c) a byte is used for timeout but a table or function is used to map a byte to a useful range of timeouts ranging from 1ms to 60s.

Re: How to use nfc_initiator_select_tag to wait for specific timeout

Probably option 'c' would be the best then, since the PN53x chip gives the following options for "easy" time-out configuration (separately configurable for both, anticollision (=_select_tag()) and transmission (=transceive())

Byte Value (n)  Timeout Value 
0x00 no timeout 
0x01 100 µs 
0x02 200 µs 
0x03 400 µs 
0x04 800 µs 
0x05 1.6 ms 
0x06 3.2 ms 
0x07 6.4 ms 
0x08 12.8 ms 
0x09 25.6 ms 
0x0A 51.2 ms 
0x0B 102.4 ms 
0x0C 204.8 ms 
0x0D 409.6 ms 
0x0E 819.2 ms 
0x0F 1.64 sec 
0x10 3.28 sec 

Re: How to use nfc_initiator_select_tag to wait for specific timeout

(c) looks good then.

Would the headers include a series of #defines that map the code to the timeout?

Also, will nfc_configure return an error in the case of an unsupported value?

Re: How to use nfc_initiator_select_tag to wait for specific timeout

A descent typedef for the options sounds reasonable. A incorrect configuration option would most likely fail (rejected by the PN53x chip).

Re: How to use nfc_initiator_select_tag to wait for specific timeout

Has this feature been implemented?

TA

Re: How to use nfc_initiator_select_tag to wait for specific timeout

jlanza wrote:

Has this feature been implemented?

This feature (i.e. tweaking select timing) is not implemented but an hardware polling is now possible using nfc_initiator_poll_targets()

Romuald Conty