Commit graph

957 commits

Author SHA1 Message Date
Philippe Teuwen
b65674a8e3 Some systems (e.g. glibc < 2.17) require librt to get clock_gettime -> CMAKE 2017-03-02 23:42:36 +01:00
Philippe Teuwen
bf31594410 conf: close file 2017-02-18 22:20:15 +01:00
Philippe Teuwen
04ef5ca902 Reduce variables scopes 2017-02-18 22:20:15 +01:00
Philippe Teuwen
2033519b0c Add asserts to tell static analyzer we know what we're doing...
nfc.c:1244:19: warning: Dereference of undefined pointer value
  for (int i = 0; nmt[i]; i++) {
                  ^~~~~~
nfc.c:1256:23: warning: Dereference of undefined pointer value
      for (int j = 0; nbr[j]; j++) {
                      ^~~~~~
2017-02-18 18:08:27 +01:00
Philippe Teuwen
f2c264d4ae pn53x: avoid warning about uninitialized value (false positive)
pn53x.c:1746:15: warning: Function call argument is an uninitialized value
    *cycles = __pn53x_get_timer(pnd, pbtTxRaw[szTx + 1]);
              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2017-02-18 17:29:57 +01:00
Philippe Teuwen
05220537ea i2c: fix struct initialization
pn532_i2c.c:125:57: warning: missing field 'tv_nsec' initializer [-Wmissing-field-initializers]
        struct timespec transaction_start, bus_free_time = { 0 };
                                                               ^
pn532_i2c.c:153:57: warning: missing field 'tv_nsec' initializer [-Wmissing-field-initializers]
        struct timespec transaction_start, bus_free_time = { 0 };
2017-02-18 17:23:22 +01:00
Philippe Teuwen
9a749e1a66 arygon: remove unused variable
arygon.c:94:22: warning: unused variable 'arygon_error_incomplete_command' [-Wunused-const-variable]
static const uint8_t arygon_error_incomplete_command[] = "FF0C0000\x0d\x0a";
                     ^
2017-02-18 17:17:33 +01:00
Philippe Teuwen
e4df2f3334 astyle 2017-02-18 13:05:59 +01:00
Philippe Teuwen
ff37cdb2be Replace deprecated readdir_r by readdir
This reverts 262555d5, 7fb53873 and a0b859b2
2017-02-17 12:10:33 +01:00
Philippe Teuwen
99a7d9aa35 Merge pull request #387 from ChristophGr/master
allow to cross-compile 32 and 64 bit versions of the library for windows
2017-02-17 11:45:55 +01:00
Philippe Teuwen
732a282190 Merge branch 'master' into master 2017-02-17 10:15:04 +01:00
Philippe Teuwen
11bcf05a75 Fix typo. Fix issue #377 2017-02-16 23:12:38 +01:00
Emmanuel Dreyfus
e26fe912fd NetBSD serial ports 2017-02-16 23:08:41 +01:00
Emmanuel Dreyfus
20a1b978f3 NetBSD definition for CCID ioctl 2017-02-16 23:08:36 +01:00
Philippe Teuwen
968f59a988 Remove unneeded test, fix issue #376 2017-02-16 23:05:02 +01:00
Philippe Teuwen
e50b18848f Remove spurious mirror_uint8_ts declaration, fix issue #375 2017-02-16 23:00:37 +01:00
Christoph Gritschenberger
11a2da2811 allow to cross-compile 32 and 64 bit versions of the library for windows 2017-01-25 18:44:44 +01:00
John Galt
9c7b9eda8c Fix typo in nfc.c 2016-12-07 07:22:27 -05:00
Olliver Schinagl
e946f7a97a drivers: pn532_i2c: Errata on i2c timing
The datasheet is wrong for the pn532_i2c. After having constant issues
with the device failing to respond on the bus and after contacting NXP
about this, it turns out 1.3 ms is too tight. The official timing spec
is unknown for now, but we tested 4 and 5 ms without problems. Thus we
have choosen 5 ms as a safe delay.

Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
2016-12-06 11:40:56 +01:00
Olliver Schinagl
d960673681 drivers: pn532_i2c: Add retry on error mechanism
Currently, we very occasionally can EXNIO errors from pn532_i2c_write() ->
i2c_write() -> write(). This may happen about once every 30 seconds.
Based from the kernel sources, EXNIO happens if the chip no longer
responds to its own address.

To make sure we do not loose any sent packets, we retry to send
PN532_SEND_RETRIES number of times. Since we miss 1 every 30 or so
seconds, doing 1 retry should be fine.

This might be considered a hack as the failure may be some other timing
related issue.

Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
2016-10-24 13:05:42 +02:00
Olliver Schinagl
8f8f780c2b drivers: pn532_i2c: Respect proper timing specifications
The pn532 user manual states that after a i2c stop condition and before a i2c
start condition there should be a delay of minimally 1.3 milliseconds.
This is probably a limitation of the i2c peripheral or the firmware. In
any case, each i2c_read and i2c_write creates the packets which are
complemented with start/stop markers. It is thus required to take care
of timing in these two functions.

We solve this by wrapping the lower i2c_read and i2c_write functions for
the pn532, as this requirement is not for all chips.

Currently, we keep time using local variable, and thus the code is not
thread-safe. With libnfc being single threaded and only one instances of
libnfc can open a bus anyway, this is not yet a problem.

Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
2016-10-24 12:02:58 +02:00
Olliver Schinagl
b953002f8f drivers: pn532_i2c: Clarify preamble and start byte
The pn532 documentation differs slightly from the included ascii art
documentation on how a packet looks like. The preamble was omitted
however the postamble is mentioned. This patch adds the Preamble to the
ascii frame documentation.

The code later refers incorrectly to the start byte as the preamble.
This variable was renamed to more descriptively state that it is the
preambe and the start bytes.

Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
2016-10-24 12:00:36 +02:00
Olliver Schinagl
512be89700 busses: i2c: improve logging
Currently we only inform the user with the error logging mechanism that
we received a different number of bytes than expected.

Thus in case of an error, we say that we sent/received -1 bytes. However
-1 indicates an error and errno is set to indicate the error state.

This patch extends the logging to also print the actual error.

Additionally the same debugging printing was added to read, which is now
silently returned to the caller.

Signed-off-by: Olliver Schinagl <o.schinagl@ultimaker.com>
2016-10-21 14:20:51 +02:00
yerzhanm
41d694013c added support for ACR1222U-C1
added ACR1222U-C1 ACS ACR1222 1SAM PICC Reader in supported devices
2016-06-23 18:20:39 +06:00
Alexander Inyukhin
10398b6bd9 А typo leads to improper pnd->name initialization
A for loop condition is always false so pnd->name
is not initialized. This results in garbage when
printing device name.
2016-03-19 08:08:38 +03:00
bhack
1d4720671e Add SCM_SCL3712 support 2015-11-04 20:15:56 +01:00
xaqq
17ed36a7a5 Drop PCRE dependency.
The config file is now manually parsed instead of using regex.
While this is less beautifull, it allows us to drop PCRE
as a dependency on Windows.
2015-07-22 15:47:36 +02:00
Philippe Teuwen
49dde9c28c Merge branch 'nfc_get_supported_baud_rate_proposal'
* nfc_get_supported_baud_rate_proposal:
  nfc_get_supported_baud_rate() proposal to reverse API
2015-06-18 22:07:09 +02:00
Philippe Teuwen
04a51df796 nfc_get_supported_baud_rate() proposal to reverse API
cf issue #298
nfc_get_supported_baud_rate() would be the one for "initiator mode"
and we add nfc_get_supported_baud_rate_target_mode()
2015-06-08 11:34:16 +02:00
Mati Vait
68094b4f6d export iso14443b* symbol 2015-05-27 23:01:48 +03:00
Boris Moiseev
11a4e3cd7f Fix nfc_initiator_poll_target without tag on PN532
When there is no tag on PN532 reader, the library
incorrectly processed call result and returned
NFC_ECHIP (chip error) instead of 0 (no targets
found).
2015-05-25 17:22:25 +03:00
Romuald Conty
d028bc725d Fix comparison when nfc_initiator_target_is_present() with a specified target 2015-05-18 20:43:10 +02:00
Romuald Conty
22078a8509 Documentation: fix str_nfc_target() explanation 2015-05-18 20:08:33 +02:00
Romuald Conty
c31f8bd9be Doc: minor documentation fixes 2015-04-28 19:22:16 +02:00
Romuald Conty
0f77565a3c Fix cmake soversion (doesn't match autotools)
Thanks to Julien Schueller
2015-04-15 17:19:42 +02:00
Romuald Conty
fce491c829 README: add a section to help to configure libnfc 2015-04-15 17:11:11 +02:00
Romuald Conty
f82aa75072 Merge remote-tracking branch 'socram8888/cygfix' 2015-04-14 17:16:20 +02:00
David Kreitschmann
1785ac14c2 Use more serial devices on Mac OS X
Some USB-serial adapters just use tty.usbserial or tty.usbmodem as a
device name. (e.g.
Prolific).  Currently part of a patch for homebrew here:
https://github.com/Homebrew/homebrew/blob/master/Library/Formula/libnfc.
rb
2015-04-04 22:37:03 +02:00
Marcos Vives Del Sol
4e823d8db0 Use TIOCINQ instead of FIONREAD in Cygwin 2015-02-22 20:41:59 +01:00
Marcos Vives Del Sol
9d82d598f0 Fix "missing return" compiler warnings 2015-02-21 23:04:06 +01:00
Marcos Vives Del Sol
b6a8745838 Fix compilation under Cygwin 2015-02-21 22:57:36 +01:00
Philippe Teuwen
9a254712b5 nfc_initiator_select_passive_target(): validate modulation and baud rate 2014-03-12 00:28:39 +01:00
Philippe Teuwen
e57dc8a746 Better list of supported modulations & baud rates
* Extend supported baud rates for TypeA
* Extend supported modulations B->BI,B2SR,B2CT
* Use InPSL only on TypeA
* Add mode to nfc_get_supported_baud_rate() (API change!)
* Fix supported baud rates for BI,B2SR,B2CT
* Remove supported modulations as target for ASK LoGO

Before:

$ nfc-scan-device -v
3 NFC device(s) found:
- ACS / ACR122U PICC Interface:
    acr122_usb:002:024
chip: PN532 v1.4
initator mode modulations: ISO/IEC 14443A (106 kbps), FeliCa (424 kbps, 212 kbps), ISO/IEC 14443-4B (106 kbps), Innovision Jewel (106 kbps), D.E.P. (424 kbps, 212 kbps, 106 kbps)
target mode modulations: ISO/IEC 14443A (106 kbps), FeliCa (424 kbps, 212 kbps), D.E.P. (424 kbps, 212 kbps, 106 kbps)
- SCM Micro / SCL3711-NFC&RW:
    pn53x_usb:002:028
chip: PN533 v2.7
initator mode modulations: ISO/IEC 14443A (106 kbps), FeliCa (424 kbps, 212 kbps), ISO/IEC 14443-4B (847 kbps, 424 kbps, 212 kbps, 106 kbps), Innovision Jewel (106 kbps), D.E.P. (424 kbps, 212 kbps, 106 kbps)
target mode modulations: ISO/IEC 14443A (106 kbps), FeliCa (424 kbps, 212 kbps), D.E.P. (424 kbps, 212 kbps, 106 kbps)
- ASK / LoGO:
    pn53x_usb:002:023
chip: PN533 v2.7
initator mode modulations: ISO/IEC 14443A (106 kbps), FeliCa (424 kbps, 212 kbps), ISO/IEC 14443-4B (847 kbps, 424 kbps, 212 kbps, 106 kbps), Innovision Jewel (106 kbps), D.E.P. (424 kbps, 212 kbps, 106 kbps)
target mode modulations: ISO/IEC 14443A (106 kbps), FeliCa (424 kbps, 212 kbps), D.E.P. (424 kbps, 212 kbps, 106 kbps)

After:

$ nfc-scan-device -v
3 NFC device(s) found:
- ACS / ACR122U PICC Interface:
    acr122_usb:002:024
chip: PN532 v1.4
initator mode modulations: ISO/IEC 14443A (424 kbps, 212 kbps, 106 kbps), FeliCa (424 kbps, 212 kbps), ISO/IEC 14443-4B (106 kbps), ISO/IEC 14443-4B' (106 kbps), ISO/IEC 14443-2B ST SRx (106 kbps), ISO/IEC 14443-2B ASK CTx (106 kbps), Innovision Jewel (106 kbps), D.E.P. (424 kbps, 212 kbps, 106 kbps)
target mode modulations: ISO/IEC 14443A (424 kbps, 212 kbps, 106 kbps), FeliCa (424 kbps, 212 kbps), D.E.P. (424 kbps, 212 kbps, 106 kbps)
- SCM Micro / SCL3711-NFC&RW:
    pn53x_usb:002:025
chip: PN533 v2.7
initator mode modulations: ISO/IEC 14443A (847 kbps, 424 kbps, 212 kbps, 106 kbps), FeliCa (424 kbps, 212 kbps), ISO/IEC 14443-4B (847 kbps, 424 kbps, 212 kbps, 106 kbps), ISO/IEC 14443-4B' (106 kbps), ISO/IEC 14443-2B ST SRx (106 kbps), ISO/IEC 14443-2B ASK CTx (106 kbps), Innovision Jewel (106 kbps), D.E.P. (424 kbps, 212 kbps, 106 kbps)
target mode modulations: ISO/IEC 14443A (424 kbps, 212 kbps, 106 kbps), FeliCa (424 kbps, 212 kbps), D.E.P. (424 kbps, 212 kbps, 106 kbps)
- ASK / LoGO:
    pn53x_usb:002:023
chip: PN533 v2.7
initator mode modulations: ISO/IEC 14443A (847 kbps, 424 kbps, 212 kbps, 106 kbps), FeliCa (424 kbps, 212 kbps), ISO/IEC 14443-4B (847 kbps, 424 kbps, 212 kbps, 106 kbps), ISO/IEC 14443-4B' (106 kbps), ISO/IEC 14443-2B ST SRx (106 kbps), ISO/IEC 14443-2B ASK CTx (106 kbps), Innovision Jewel (106 kbps), D.E.P. (424 kbps, 212 kbps, 106 kbps)
target mode modulations:
2014-03-12 00:00:08 +01:00
Philippe Teuwen
89fc6a723e make style 2014-03-11 00:25:33 +01:00
Philippe Teuwen
ddde2dd8f2 initiator_select_passive_target(): now supports all speeds for ISO14443-4A tags 2014-03-11 00:13:26 +01:00
Philippe Teuwen
108de27c1b Fix typo baud<>bauds thanks to Polluks 2014-03-05 17:48:55 +01:00
Philippe Teuwen
6b74323369 target_is_present(): remove unreachable code 2014-03-04 01:47:42 +01:00
Philippe Teuwen
db4fae9c2c Remove unreachable statements
As seen with clang -Wunreachable-code
2014-03-04 01:39:12 +01:00
Romuald Conty
78b827aa33 Bump library revision
According to https://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
2014-02-24 15:50:49 +01:00
Philippe Teuwen
415ad7cbac nfc_initiator_select_passive_target() accepts NULL pbtInitData and provides default values 2014-02-10 01:09:07 +01:00