Commit graph

656 commits

Author SHA1 Message Date
Romuald Conty
ba37313cb8 Prevent from stack corruption when using PN533-based device and add errors handling for ReadRegister and WriteRegister. (Fixes Issue 135) 2010-12-29 14:01:14 +00:00
Romuald Conty
6aa07aa78b Add extra dist to make distcheck pass and force distcheck to compile all drivers 2010-11-17 10:14:26 +00:00
Romuald Conty
835823809f Split UART implementations: POSIX and Windows
It could ease to port to other system like MiKey and it should be easy to track which is the concerned OS while uart driver is modified.
2010-11-17 08:48:03 +00:00
Romuald Conty
58dcf63e7c MERGE: libnfc-mingw-cross merge with trunk (r805-821) 2010-11-17 08:29:41 +00:00
Romuald Conty
6df612a364 Errors use #define instead of constant values.
Update Issue 84
Current 'ident' command breaks commit-concerned lines.
2010-11-15 18:50:53 +00:00
Philippe Teuwen
779fdd5df6 Tweaks Touchatag detection under MacOSX (Fixes issue 128) 2010-11-15 13:00:07 +00:00
Romuald Conty
6e29450d69 Fix memory leak while using *_pick(). Thanks to frankmorgner (Fixes Issue 130) 2010-11-12 19:24:20 +00:00
Romuald Conty
6e70cfa5ef Fix UART default serial ports under Linux. 2010-11-12 18:38:47 +00:00
Romain Tartiere
4e5d0766e1 Rename append_iso14443a_crc() to iso14443a_crc_append(). 2010-10-29 10:59:26 +00:00
Romuald Conty
5c8749c63e drivers/arygon: retrieve ARYGON firmware version 2010-10-22 15:21:06 +00:00
Romuald Conty
8798f6bbcd Fix ARYGON driver:
- Does not send any ACK frame at start: my ARYGON does get happy with this frame (see code comments)
 - Send a TAMA reset (for PN532) instead of ACK frame
 - Remove bzero use: its a deprecated function
2010-10-22 14:29:44 +00:00
Romuald Conty
ca8c5cabe1 Fix minor compilation warnings 2010-10-22 14:25:09 +00:00
Romuald Conty
1a320d5577 Adjust uart's timeout from baud rate 2010-10-22 14:10:36 +00:00
Romuald Conty
97cf9e925b Attempt to fix ARYGON driver 2010-10-20 16:14:53 +00:00
Romuald Conty
72d7b66d2b Handle more corner case during convertion from nfc_* types to available pn53x_* types 2010-10-20 09:28:36 +00:00
Romuald Conty
5538fbd20f Add NBR_847 (used with ISO14443B) and update convert function. 2010-10-20 08:34:06 +00:00
Romuald Conty
f249af6266 Add ISO14443-4 modulation to hardware polling only when NDO_AUTO_ISO14443_4A have been enabled and document this features and known issues. 2010-10-19 09:34:18 +00:00
Philippe Teuwen
f75d2d3582 Typo 2010-10-18 16:17:01 +00:00
Romuald Conty
f9391ad823 Update some TODOs 2010-10-18 15:47:56 +00:00
Romuald Conty
b5d85fc6e1 Decode supported modulation from PN53x 2010-10-18 14:26:49 +00:00
Romuald Conty
bfb49b594f Clean the way to retrieve firmware 2010-10-18 13:19:30 +00:00
Romuald Conty
c6c43afc87 Minor FIXME or XXX removes 2010-10-18 12:22:04 +00:00
Romuald Conty
7d59b6b1a3 Make sure the field is disabled then enabled before listing.
Improve documentation about default configuration values.
2010-10-18 10:11:30 +00:00
Romuald Conty
ecc1eeca8f API documentation improvement: explain a bit what is pbtInitData for nfc_initiator_select_passive_target() 2010-10-18 09:53:14 +00:00
Romuald Conty
1f62e9e2f2 Improve API for target emulation, nfc_target_mode_t does not exist anymore (this mode is computed from nfc_target_t) 2010-10-15 14:32:10 +00:00
Philippe Teuwen
33a99288f3 pn53x target_init: fix bug to use Tk; nfc-relay-picc: fix potential segfault 2010-10-14 20:17:58 +00:00
Philippe Teuwen
ffe50562dd Make use of the now available Tk info 2010-10-14 18:33:17 +00:00
Romuald Conty
cbca45e21c Oups it miss some space to handle HB. 2010-10-14 17:43:28 +00:00
Romuald Conty
41758ab63f pn53x_target_init() now takes care of Historical Bytes 2010-10-14 17:38:54 +00:00
Romuald Conty
4a50be27de Add a iso14443a function to extract Historical Bytes from ATS 2010-10-14 17:32:15 +00:00
Romuald Conty
7c76e1bf32 nfc_target_init() now update nfc_target_t baud rate 2010-10-14 16:27:50 +00:00
Romuald Conty
7294e4fbaf examples/nfc-utils: decode more ATS info 2010-10-14 14:48:59 +00:00
Romuald Conty
507a23b708 Improve nfc_target_init() 2010-10-14 13:31:36 +00:00
Romuald Conty
60c9da598a Support different baud rates for nfc_initiator_select_dep_target() 2010-10-14 13:03:23 +00:00
Philippe Teuwen
5a5b5d681b Small typos 2010-10-14 11:53:27 +00:00
Romuald Conty
af88da1a9c Replace nfc_target_info_t with nfc_target_t in API function, we now have a coherent struct to handle nfc_target_t, use it! 2010-10-14 11:44:43 +00:00
Romuald Conty
6f3fbcb6bf Fix nfc_dep_mode_t usage in API, fix/improve documentation 2010-10-14 11:12:23 +00:00
Romuald Conty
d41e7f2ca0 Hack polling modulations in order to have ISO14443-4 with ATS and ISO14443-3 targets 2010-10-13 22:28:29 +00:00
Romuald Conty
9d9b5a629e Fix nfc-poll, improve pn53x_target_type_t decoding 2010-10-13 21:40:54 +00:00
Romuald Conty
adba90684d introduce nfc_dep_mode_t type instead of bool in nfc_initiator_select_dep_target() 2010-10-13 19:59:39 +00:00
Romuald Conty
124cc28bac Typo 2010-10-13 19:51:21 +00:00
Romuald Conty
f2a3d51037 Fix a bug introduce in r729, fix a compilation warning 2010-10-13 19:50:43 +00:00
Romuald Conty
ec601f6a00 Fix two bugs introduced in r729, typo. 2010-10-13 19:31:02 +00:00
Romuald Conty
d67527932c Add some FIXME/TODO about PN532 that does not supported B type (ISO14443) 2010-10-13 19:24:24 +00:00
Romuald Conty
979430ecd1 nfc_target_t have now nfc_modulation_t instead of nfc_modulatation_type_t 2010-10-13 19:17:51 +00:00
Romuald Conty
584a18ec11 Remove unused pn53x_modulations 2010-10-13 18:41:48 +00:00
Romuald Conty
d289eabc36 Attempt to provide clean types for API 2010-10-13 17:43:23 +00:00
Romuald Conty
9020014160 Rename nfc_modulation_t as pn53x_modulation_t 2010-10-13 15:39:52 +00:00
Romuald Conty
695e5c2f37 Rename nfc_target_type_t as pn53x_target_type_t 2010-10-13 15:31:48 +00:00
Romuald Conty
c53c512831 Change some nfc_target_type_t to insist on the ISO/IEC 14443-4 compliance 2010-10-13 11:49:34 +00:00
Romuald Conty
0fe30e3db7 Change some nfc_target_mode_t to insist on the restrictions offer these mode 2010-10-13 11:35:28 +00:00
Philippe Teuwen
572499f598 pn53x_usb: remove USB timeout (Fixes issue 122) 2010-10-13 07:21:34 +00:00
Philippe Teuwen
2fb1de34f4 pn53x_usb: try to recover device if usb read fails, solves partly Issue 122 2010-10-12 16:04:40 +00:00
Philippe Teuwen
9d1e72a9f7 pn53x_usb: leave the device in cleaner state (Fixes Issue 123) 2010-10-12 15:51:57 +00:00
Romuald Conty
61b0df5fe9 Minor documentation fix 2010-10-12 15:34:37 +00:00
Romuald Conty
c34be50ef1 For the sake of consistency, rename all szRxLen to szRx and szTxLen to szTx 2010-10-12 14:56:42 +00:00
Romuald Conty
b333a4b1cf Add FeliCa to emulation capabilities 2010-10-12 09:44:39 +00:00
Romuald Conty
2857b1dd1a Remove a wrong FIXME 2010-10-11 14:53:10 +00:00
Romuald Conty
602787bd03 We can now use an nfc_dep_info_t to specify DEP info as initiator. 2010-10-11 14:49:08 +00:00
Romuald Conty
6e932142f0 arygon: send ACK frame for ARYGON devices too. 2010-10-11 10:54:49 +00:00
Romuald Conty
0bdef6cb2a pn532_uart: send ACK frame to cancel a eventual previous command during nfc_connect() too. 2010-10-11 10:53:24 +00:00
Romuald Conty
49e6fff104 pn532_uart: start with sending an ACK frame to cancel a eventual previous command. 2010-10-11 10:41:03 +00:00
Romuald Conty
08b06c1d03 Emulated DEP targets can now be customized (NFCID3 and General Bytes). 2010-10-08 21:54:59 +00:00
Romuald Conty
1e9c390dfa Improve DEP info struct: add more info, and InJumpDEP now fill fully this struct. 2010-10-08 20:25:34 +00:00
Romuald Conty
814ccad1e3 Only send WriteRegister command if register sent value is different from actual one. 2010-10-07 09:46:21 +00:00
Romuald Conty
b8d65f9b27 Keep the last byte as \0 to be sure abtFw will be null-terminated. Fixes an issue I have with my ACR122U205: the last char of the firmware string was changing each nfc-list launch. 2010-10-06 17:52:15 +00:00
Romuald Conty
d9505bbbcc Better handling of SetParameters command, use a cache, prevent from double set, adjust comments, remove junk code. 2010-10-06 15:12:33 +00:00
Romuald Conty
da7a2bc4c6 Add ISO/IEC 14443B baud rates: 212, 424 and 847 kbps. Set a device error when using a not supported modulation baud rate in InListPassive(). 2010-10-06 10:06:12 +00:00
Romuald Conty
e03fb8a916 Minor code clean up. 2010-10-06 10:02:12 +00:00
Philippe Teuwen
69fba08661 acr122u: fixes escape ioctl under linux & make it OS-dependent, to be tested on other OSes! 2010-10-05 13:49:48 +00:00
Philippe Teuwen
d75e25d29d nfc-emulate-ndef now using easy framing & fix timing issues 2010-10-05 10:05:22 +00:00
Romuald Conty
e9fdccfa63 Fix missing renaming. 2010-10-04 16:34:02 +00:00
Romuald Conty
5233fceda7 Improve the target emulation functions (ATM, only ISO14443A), add an example (nfc-emulate-tag), update examples to use the new API. 2010-10-04 12:46:03 +00:00
Philippe Teuwen
ba4c920af7 pn53x: avoid mix of hardcoded/sizeof values 2010-10-02 20:39:11 +00:00
Philippe Teuwen
c937e8d178 pn53x: handle properly ReadRegister of PN533 2010-10-01 17:42:16 +00:00
Romuald Conty
b53b623c38 Split pn53x_target_init() into TgInitAsTarget command wrapper and the "logical" part 2010-09-30 12:51:13 +00:00
Romuald Conty
33e42f389a Detect PN53x USB devices before ACR122.
This change is needed by the fact that ACR122 use PCSC framework, and PCSC try to detect more than ACR122 devices, this reduce the connection speed (Plus, one some systems pcscd is not launched at boot time, its launched when some application access to using libpcsclite.)
2010-09-30 10:32:44 +00:00
Romuald Conty
6b679862e7 Fix bad indent.
Update issue 84
Current indent command push these comments the next line.
2010-09-30 10:27:34 +00:00
Romuald Conty
10f9a3d2b0 PN531 and PN533 does not support NTM_PICC mode 2010-09-30 08:37:46 +00:00
Romuald Conty
68879ba255 Fix bad indent.
Update issue 84
Status: Reopened
Currently, indent trucate long line which make the code almost unreadable.
2010-09-30 08:14:21 +00:00
Romuald Conty
4d880e6ce8 Enhance documentation and fix typo. 2010-09-29 14:26:06 +00:00
Romuald Conty
0c72e7ed1a Workaround to prevent from USB toogle bit issue discussed on Issue 114.
Update issue 114
Status: Fixed
Owner: yobibe
This workaround allow to use PN533 USB (like SCL3711) without toogle bit issue (on OSes that care about this toogle bit: e.g. GNU/Linux, MacOS).
libfreefare tests suite now works as expected, enjoy!
2010-09-29 09:57:50 +00:00
Roel Verdult
6dfe88113e Added new example, PN53x chips will now emulate NDEF tag! not in build-script yet 2010-09-28 16:15:59 +00:00
Romuald Conty
8672c809bd example: Jewel support in nfc-list and nfc-poll. (Many thanks to Phil) 2010-09-28 15:31:31 +00:00
Romuald Conty
7a7687b3b8 Hack that allow to re-use PN53x (connected in USB) when something goes wrong.
New issue
Summary: Implement the abort mechanism (PCD->PICC ACK)
Currently, this issue is motivated by the need to reconnect to the device after a failure: ie. Issue 114.
BTW, this feature could also be useful to break an infinite polling or to cancel a previously sent command.
2010-09-28 15:15:36 +00:00
Roel Verdult
a0ece60203 let the PN53x functions call it's own configuration, not the main nfc_configure() 2010-09-28 14:48:57 +00:00
Romuald Conty
2f95fb254b Improve ATQB decoding: "PUPI", "Application Data", and "Protocol Info" is now available as separated fields. 2010-09-23 16:26:06 +00:00
Romuald Conty
ccfd24a682 nfc-anticol now works even after running another program that change the modulation (Fixes Issue 111) (Thanks to Phil for help). 2010-09-23 16:03:05 +00:00
Romuald Conty
868919107a Fix Zero Lenght Packet problem on USB (Thanks to Phil) 2010-09-23 10:28:35 +00:00
Romuald Conty
7e2ddedfc1 Fix ISO14443-B ATTRIB_RES decoding. (Thanks to Phil) 2010-09-23 10:12:10 +00:00
Romuald Conty
e2a2557396 Replace wrong decoded ISO14443-B data by ATTRIB_RES field.
New issue
Summary: Improve ISO 14443-B data (ATTRIB_RES) decoding
Before this revision, pn53x_decode_target_data() wrongly decode ISO14443-B. Currently, whole ATTRIB_RES field is stored in nfc_target_info_t struct.
I do not find the correct documentation to fix it better than this, but at least it now retrieves a correct value.
2010-09-22 19:10:50 +00:00
Romuald Conty
2d6c0f5f1a Decode more targets types from PN53x. 2010-09-22 12:51:32 +00:00
Romuald Conty
0e37a1e9e9 Fix typo, add a minor XXX 2010-09-22 12:42:14 +00:00
Romuald Conty
9cf4f5debb Fix Felica listing. (Thanks to the contibutor who provide me this patch) 2010-09-21 16:15:27 +00:00
Romuald Conty
52354daa1e Stop target listing when the maximal wanted target count is reached. 2010-09-21 16:05:24 +00:00
Romuald Conty
0ea9467b56 Minor indentation fixes. 2010-09-20 14:41:41 +00:00
Romuald Conty
362dfb51db API documentation is more clean now: functions order have more sense. 2010-09-10 13:35:25 +00:00
Romuald Conty
5929bc10e7 Minor documentation improvements. 2010-09-08 22:20:09 +00:00
Romuald Conty
7be31d0ba8 Update documentation and associated example. 2010-09-08 09:16:24 +00:00
Romuald Conty
26b9fee648 Copy missing additional-pages.dox from 1.3.4 tag. 2010-09-08 09:13:12 +00:00
Romuald Conty
18cc86a613 Indent whole code using make indent. (Fixes issue 84). 2010-09-07 17:51:03 +00:00
Romuald Conty
f93b4939f4 Set/reset configuration options at nfc_connect() time. (Fixes issue 108) 2010-09-07 17:33:45 +00:00
Romain Tartiere
b9cb5b22c8 Fix build on Microsoft Windows. 2010-09-07 09:59:12 +00:00
Romain Tartiere
ec58634a67 Fix build on Microsoft Windows. 2010-09-07 08:45:03 +00:00
Romuald Conty
5dbdabcec2 Be sure that NDO_AUTO_ISO14443_4 is activated by default. 2010-09-06 11:16:24 +00:00
Romuald Conty
190b52c4cd Remove a miss-placed prototypes. 2010-09-06 10:00:41 +00:00
Romuald Conty
fbee88b63e Prevent from warning: implicit declaration of function ‘bzero’. 2010-09-06 09:09:52 +00:00
Romain Tartiere
cbbe559f94 Alse remove nfc_target_receive_dep_bytes() and nfc_target_send_dep_bytes().
Update issue 106
Implement what's described in comment 3, 7 and 8.
2010-09-03 16:45:24 +00:00
Romain Tartiere
a5676ecd94 Remove nfc_initiator_transceive_dep_bytes() and introduce NDO_EASY_FRAMING option.
Always use nfc_initiator_transceive_bytes(). If you where using advanced
features and already relying on nfc_initiator_transceive_bytes(), then your
code has to be updated to unset the NDO_EASY_FRAMING option.  See an example of
such a change in the libfreefare's repository:
http://code.google.com/p/nfc-tools/source/detail?r=566

Updates issue 106
Status: Feedback
Romuald: I am not sure about the option enum values.  I took 0x02 thinking it
would not hurt but am not really sure about that because I can see many 'holes'
in the sequence.
2010-09-03 16:13:36 +00:00
Romuald Conty
d49439246c Fix ARYGON driver. 2010-08-31 12:55:45 +00:00
Romuald Conty
16330c2f65 Minor code clean up in pn532_uart 2010-08-31 12:54:59 +00:00
Romain Tartiere
1130036bf3 - Detect errors in pn53x_get_reg();
- Add a test case to confirm an endianness problem on little-endian machines.
2010-08-28 14:27:33 +00:00
Romain Tartiere
af291c5a16 Report errors of ACR122 devices in the transceive function. 2010-08-28 14:25:49 +00:00
Romain Tartiere
a676d34e5d Fix build on Microsoft Windows. 2010-08-24 11:03:59 +00:00
Romain Tartiere
cbc3a62db1 Remove extern reference to pn53x-specific commands.
Fixes issue 101.
2010-08-24 10:31:21 +00:00
Romain Tartiere
f8ed119d1b Reset pnd->iLastError in nfc.c. 2010-08-24 10:30:18 +00:00
Romain Tartiere
9b44e3b2b7 Rename some internal API to highlight the PN53x operating mode.
pn53x_select_dep_target    -> pn53x_initiator_select_dep_target
pn53x_transceive_dep_bytes -> pn53x_initiator_transceive_dep_bytes
pn53x_transceive_bits      -> pn53x_initiator_transceive_bits
pn53x_transceive_bytes     -> pn53x_initiator_transceive_bytes
2010-08-24 10:26:56 +00:00
Romain Tartiere
ecb51c3554 New internal API functions: pn53x_target_send_bits(), pn53x_target_send_bytes(). 2010-08-24 10:22:55 +00:00
Romain Tartiere
047f274270 New internal API functions: pn53x_target_receive_bits(), pn53x_target_receive_bytes(). 2010-08-24 10:20:04 +00:00
Romain Tartiere
92a6789013 New internal API function: pn53x_target_init(). 2010-08-24 10:17:38 +00:00
Romain Tartiere
7f698431b7 New internal API function: pn53x_target_send_dep_bytes(). 2010-08-24 10:13:09 +00:00
Romain Tartiere
3d69c8b694 New internal API function: pn53x_target_receive_dep_bytes(). 2010-08-24 10:11:48 +00:00
Romain Tartiere
7a231cfb03 New internal API functions: pn53x_transceive_bits(), pn53x_transceive_bytes(). 2010-08-24 09:59:45 +00:00
Romain Tartiere
3cba76cc6f New internal API function: pn53x_transceive_dep_bytes(). 2010-08-24 09:56:22 +00:00
Romain Tartiere
ca0d73875d New internal API function: pn53x_select_dep_target(). 2010-08-24 09:53:51 +00:00
Romain Tartiere
5055f3d30b New internal API function: pn53x_configure(). 2010-08-24 09:49:59 +00:00
Romain Tartiere
71b3a1ad6e New internal API function: pn53x_get_firmware_version(). 2010-08-24 09:47:03 +00:00
Romuald Conty
6a6ae42a97 Fix minor compilation warnings 2010-08-20 10:42:31 +00:00
Romain Tartiere
5b0589c381 Merge r551-563 from trunk. 2010-08-20 10:41:30 +00:00
Romain Tartiere
fd337dd0cc Also detect error frames in pn532_uart (tested) and arygon drivers (not tested). 2010-08-20 10:40:00 +00:00
Romuald Conty
dadaee4cc0 Fix ARYGON compilation 2010-08-20 10:28:11 +00:00
Romuald Conty
bd8a46c3c8 Fix pn532_uart compilation 2010-08-20 10:25:37 +00:00
Romuald Conty
084c001c11 Generate an error before sending InAutoPoll command if chip does not support it. 2010-08-20 10:11:06 +00:00
Romain Tartiere
f4aa4edc94 Rework and fix error frames detection.
While here, rename the pn53x_transceive_callback() function to
pn53x_transceive_check_ack_frame_callback() to make it more obvious what it is
supposed to do.
2010-08-20 10:06:19 +00:00
Romain Tartiere
b0737bd1a0 Fix pn53x_InAutoPoll(). 2010-08-20 09:36:38 +00:00
Romain Tartiere
5744c67039 Fix build on Microsoft Windows (not tested, no hardware). 2010-08-19 18:19:40 +00:00
Romuald Conty
8f19b078ff Add configuration option to enable/disable auto iso14443-4 mode. 2010-08-19 10:58:15 +00:00
Romuald Conty
edba53c5da Fix pn532_uart driver. 2010-08-19 09:01:39 +00:00
Romain Tartiere
076fa3686c Merge r547-550 from trunk. 2010-08-18 17:01:08 +00:00
Romain Tartiere
27b97c0fda Fix build on Microsoft Windows. 2010-08-18 16:55:16 +00:00
Romain Tartiere
c9f88e17a1 Reset pnd->iLastError in nfc.c. 2010-08-18 14:44:19 +00:00
Romain Tartiere
769eef20f7 Merge r520-546 from trunk. 2010-08-18 14:32:01 +00:00
Romuald Conty
d0fe1f8255 Fix debug trace of pn532_uart driver. 2010-08-18 13:56:31 +00:00
Romuald Conty
5c206b7815 Improve ISO14443B support of nfc_initiator_list_passive_targets() function. 2010-08-18 13:10:21 +00:00
Romuald Conty
43694183ff Minor documentation improvements. 2010-08-18 12:39:32 +00:00
Romuald Conty
0c19124984 Increase UART timeout to gain in stability. 2010-08-18 08:06:35 +00:00
Romuald Conty
c021a50768 Oups, r534 was not a joke... just a mistake ;-) This commit fix my r534. 2010-08-17 13:50:49 +00:00
Romuald Conty
88002bf977 Code cleaning: driver_connect() is never executed with pndd==NULL. 2010-08-17 13:31:32 +00:00
Romuald Conty
7788c33da8 Default serial-port paths are now fully hardcoded instead of half-hardcoded and soft-expanded. 2010-08-17 13:29:01 +00:00
Romuald Conty
476c05cfb4 Cleanup up nfc_initiator_list_passive_targets(): remove attempts to retrieve ATQA when collision occurs, after a lot of tests by Romain and me we are not able to find a way to retrieve all tags ATQA if different card types are on the nfc device. 2010-08-17 10:08:38 +00:00
Romuald Conty
3c57861d6b Improve pn53x_decode_target_data() function: move code from nfc_initiator_select_passive_target() to the right place (pn53x.c). 2010-08-17 10:01:11 +00:00
Romuald Conty
ae04479968 Move hardware polling function in pn53x.c/h. 2010-08-17 08:24:38 +00:00
Romain Tartiere
f797d737d3 Fix build on Microsoft Windows. 2010-08-16 17:43:48 +00:00
Romain Tartiere
08eb21aa9d Second part of error handling.
- Define two sets of DE<FOOBAR> macros: the first one for 'generic' errors
  which could be encountered regardless of the NFC device the library is acting
  with (0xX000), and ont set for device-dependant errors (0x0X00).
- Make some more functions accept a nfc_device_t* as first argument to have
  access to the iLastError;
- Reset errors when entering public API functions;
- Save errors when applicable;
- Distinguish system-level errors (e.g. I/O error) and operational errors (the
  PCD returns an unexpected value);
- Minor tweaks.

Update issue 65
Status: Feedback

New review:
Owner: rconty@il4p.fr
Cc: rtartiere@il4p.fr
Summary: Review the error-handling code.
Branch: /branches/libnfc-error-handling

For this development, a strong emphasis has been set on making changes that
will not go through our way on the way to libnfc-1.6+.  For this reason, some
constructs are not natural (e.g. error codes defined in two different places),
please keep this in mind when reviewing.
2010-08-15 14:08:29 +00:00
Romain Tartiere
8a75f5b45e Fix wrong comment 2010-08-15 12:42:40 +00:00
Romain Tartiere
fab08a3951 Fix doxygen comment: the string SHALL NOT be freed (it's const BTW).
Or maybe I would rather have removed the const and called strdup(3)?

New issue
Summary: Sync code and comments
Owner: rconty@il4p.fr
Status: New
Romuald, can you please review this changeset and fix the code if I corrected
the wrong way (i.e. the comment was Okay and the code bogus while I fixed the
comment thinking the cod was right).

Thanks!
2010-08-13 19:10:31 +00:00
Romain Tartiere
57b775bae2 Always ACK on transmission.
New issue
Summary: Make sending ACK on message transmission skipable.
Owner: rtartiere@il4p.fr
Cc: rtartiere@il4p.fr
Status: New
I guess that for performance reasons, some advance users would prefer to skip
sending the non-mandatory ACK on data transmission.  They may also perform a
quicker check of the ACK returned by the chip after sending the command and
before receiving the response (not sure about this one).

It will probably be a ./configure option disabled by default that allows some "shortcuts" to perform NFC hacking.
2010-08-13 16:02:18 +00:00
Romain Tartiere
f4bc39bf41 Mostly revert r521.
It was obviously an April joke: iErrorCode which was renamed iPICCError is
indeed a PCD Error, so I renamed it to iLastError since communications errors are
also to handle at the device driver level (read chip level), although I guess
that some errors would be common to distinct devices.
PICC error are irrelevant because they can either be transmission error
detection (in which case the libnfc should retry the transmission) or
application-level errors the libnfc cannot be aware of.
2010-08-13 09:02:20 +00:00
Romain Tartiere
0502401a29 Minor tweaks.
- Rename the nfc_device_t's struct iErrorCode member to iPICCError (We are
    likely to have both PICC and PCD errors fields to avoid unneeded complexity
    at some point);
  - Make the PN53x error descriptions static;
  - Enhance some comments here and there.
2010-08-13 08:31:16 +00:00
Romain Tartiere
b289784359 Merge r511-519 from trunk. 2010-08-11 16:59:09 +00:00
Romuald Conty
2029e0c66f Remove usb_reset() call: this function always failed. 2010-08-11 16:44:34 +00:00
Romuald Conty
d11e7a1320 Prevent from segfault when nfc_disconnect() on NULL pointer 2010-08-11 16:38:22 +00:00
Romain Tartiere
caa594eba8 Remove deprecated code.
Reported by:	rconty@il4p.fr
2010-08-11 09:46:14 +00:00
Romain Tartiere
ca6b768a67 Fix build on Microsoft Windows. 2010-08-10 21:45:30 +00:00
Romain Tartiere
dfb82f8893 Merge r499-510 from trunk. 2010-08-10 21:14:13 +00:00
Romain Tartiere
fd0efd4a62 Fix build on Microsoft Windows.
Windows users: I hate you in secret.
2010-08-10 19:50:29 +00:00
Romain Tartiere
8fef257d16 Also use pn53x_transceive_callback() in the arygon driver.
While here, remove unneeded header in pn532_uart.c.
2010-08-08 15:25:06 +00:00
Romain Tartiere
d7c16d6d1a Factorise UART-relative macros definitions. 2010-08-08 09:34:18 +00:00
Romain Tartiere
8e5d235cd2 Implement pn53x_InRelease().
I used it for some experiments and guess that it should be part of the API.
2010-08-06 07:29:57 +00:00
Romain Tartiere
d0357cf3aa Merge r486-498 from trunk. 2010-07-31 14:23:33 +00:00
Romain Tartiere
79aeaa6287 Factorise code.
Avoid redundant code in PN53x usb and uart drivers.  Since it makes sense to
report errors at the nfc_device_t level, pass it directly to
pn53x_transceive().

Programs using the libnfc MAY use pn53x_transceive() to communicate with a NFC
device, and SHALL not use anymore pnd->pdc->transceive().  Code in the library
itself SHOULD avoid calling pnd->pdc->transceive(), so such construct have been
updated accordingly.
2010-07-31 14:20:15 +00:00
Romain Tartiere
b60d045537 Remove another deprecated test that '^#ifdef' did not matched for previous commit. 2010-07-31 13:46:32 +00:00
Romain Tartiere
cd53efb038 Enforce ISO C conformance about empty files.
ISO C forbids empty source files.  Instead of compiling possibly empty source
files depending on the compiler parameters, only compile required files to
build the library as requested at the ./configure stage.

Windows users (and more precisely non-autotools users), you may have to update
whatever you use to build the libnfc to fit your needs.  The Makefile shipped
in the windows directory compiles all drivers as it is written so you should
not notice any difference, but if you don't use _that_ makefile, then you will
have to do some adjustment.

For now, keep the defines in CFLAGS just in case.  Planned for removal in circa
one week.

While here, pet `./configure` output (--help format and summary).
2010-07-31 13:21:56 +00:00
Romain Tartiere
93494aad24 Fix serial string for FreeBSD.
I am sure we don't have /dev/ttyUSB*, and since I use /dev/cuau0 with a
cross-over cable to connect 2 machines and have a serial console, I guess
"/dev/cuau" is the SERIAL_STRING that's expected to work for me.  A quick test
would be cool however, but I don't own a serial NFC device.
2010-07-31 10:13:18 +00:00
Romain Tartiere
d498fcd48e Comment all commands that return a status code in the list. Found a typo at that occasion so s/0x93/0x92/. 2010-07-31 09:50:04 +00:00
Romain Tartiere
fb6d9d2d20 Yes we can... remove all those pnd->pdc->transceive() from nfc.c.
Within the ongoing effort to improve the NFC devices abstraction, and now that
pn53x_transceive() does not fail when it reads a response that has no
status-code, do not call directly pnd->pdc->transceive() from nfc.c.  In a
mid-term future this will be changed again, and calling pn53x_transceive() from
nfc.c will be forbiden, in favor of colling some pnd->transceive() function,
but that's another part of the story.

Of course, it changes the API one more and it's not going to be the last time
in this branch.
2010-07-31 09:40:29 +00:00
Romain Tartiere
705e037b12 Only report status error for commands that provide it in pn53x_transceive().
This is the first step for improving abstraction in libnfc.
2010-07-31 09:19:22 +00:00
Romain Tartiere
36ee32f81a Merge r478-485 from trunk. 2010-07-30 16:34:12 +00:00
Romuald Conty
0afaf656fa Attempt to provide target listing function (WARNING: this function is actually incomplete)
New issue
Summary: Provide a target listing function
Labels: Milestone-1.4.x
Libnfc lacks of target listing function. Actually, applications or libraries based on libnfc have to wrote their own listing function which can provide side effect if two or more of theses libraries are used together in the same application. Plus, some kind of problem could appears during listing multiples targets (i.e. collisions) and this problem should be solved in libnfc (i.e. using NFC chip capabilities), not in applications based on libnfc.
2010-07-30 13:27:03 +00:00
Romuald Conty
7113d1418b Add FIXME to raise an E_NOTSUPPORTED error in future,
New issue
Summary: Catch unsupported command before sending to chip
Labels: Milestone-1.6.x
Actually, libnfc support PN531, PN532 and PN533 NFC chips, but the devices does not the same features. e.g. PN531 does not support ISO14443B modulation.
It should great to catch theses unsuported commands before sending to chip in order to prevent a chip error.
2010-07-30 11:45:59 +00:00
Romuald Conty
5ac580a241 Code cleanup: remove many debug prints, enhance comments and documentation. 2010-07-30 11:30:19 +00:00
Romain Tartiere
daa178b18f Enhance error handeling.
- New API functions: nfc_strerror(), nfc_strerror_r() and nfc_perror();
  - Drivers now have a reference to chips callback methods;
  - Rename -pn53x_err2string to pn53x_strerror and add it to pn53x_callbacks_list.
2010-07-29 14:16:11 +00:00
Romuald Conty
18e6e1bc7c Add documentation for pn53x_InListPassiveTarget() 2010-07-29 12:48:59 +00:00
Romuald Conty
fc15146bf2 Minor code cleanning. 2010-07-29 12:47:51 +00:00
Romain Tartiere
30e715cff0 Merge r470-477 from trunk. 2010-07-29 10:59:52 +00:00
Romain Tartiere
740b5b430d libnfc-error-handling: Remove boring debug stuff. 2010-07-29 10:53:14 +00:00
Romain Tartiere
f01b73ab32 Move usb_reset(3) call.
As the documentation states, and as reported in isssue 81 (fixed in r421),
usb_reset()'s argument is invalid after the call and so usb_close(3) must be
called before usb_reset(3).
2010-07-29 10:47:53 +00:00
Roel Verdult
5129a37ec8 fixed typo, missed closing bracket ;) 2010-07-28 12:56:40 +00:00
Roel Verdult
20ed5e1a52 fixed wakeup preamble, change PN532 chip to normal mode after wakeup 2010-07-28 12:52:39 +00:00
Romuald Conty
d63157a41d Fix mask to extract "Error Code" from status byte. 2010-07-27 09:29:54 +00:00
Romain Tartiere
9984e1bdcb Start of work on error handling. 2010-07-26 12:41:46 +00:00
Romain Tartiere
af584bd474 Fix packet length checksum computation.
The doc says LCS (aka abtTx[4]) must be set so that the lower byte of LCS+LEN
(aka abtTx[3]) is 0x00.  This has not to be related to the USB buffer size, so
that we can adjust it without breaking down the libnfc.
2010-07-25 16:31:53 +00:00
Romain Tartiere
7f9f907bc2 Silent down compiler. 2010-07-24 18:54:50 +00:00
Romain Tartiere
e6d079d87a Fix a regression introduced at r461.
This prevents the ATR_REQ from being processed and some tags detection fails in
libfreefare.
2010-07-24 17:20:48 +00:00
Romain Tartiere
4ff66d125f Fix a regression introduced at r458.
Both abtInit and szInitLen are initialised using pbtInitData and szInitDataLen,
so we must use them when calling pn53x_InListPassiveTarget().
2010-07-24 16:30:44 +00:00
Romuald Conty
edb62bd1cb Create pn53x_InDeselect function. 2010-07-23 13:30:06 +00:00
Romuald Conty
7eeb46ab68 Minor indentation fix. 2010-07-23 12:48:30 +00:00
Romuald Conty
7dd1053d03 Fix incorrect selected targets size in pn53x_InListPassive(). 2010-07-23 12:45:21 +00:00
Romuald Conty
3f17e5e032 Minor indentation fix. 2010-07-23 12:41:29 +00:00
Romuald Conty
aca1eb40a8 Comment out extern symbol related to PN53x in nfc.c; The goal is to remove all of them from nfc.c 2010-07-22 16:24:24 +00:00
Romuald Conty
d932cd8450 Move some PN53x related code from nfc.c to pn53x.c 2010-07-22 16:21:59 +00:00
Romuald Conty
424a48714f Minor documentation improvements. 2010-07-22 16:16:37 +00:00
Romuald Conty
c4bb23631b Do not export nfc_parse_device_desc() in libnfc API. 2010-07-22 16:13:02 +00:00
Emanuele Bertoldi
4bc522cd1e First prototype of argument parsing for device description (issue #87). 2010-07-22 13:41:20 +00:00
Romuald Conty
2688de6500 API change: nfc_initiator_select_tag() is now nfc_initiator_select_passive_target() AND nfc_initiator_deselect_tag() is now nfc_initiator_deselect_target() 2010-07-21 10:37:37 +00:00
Romuald Conty
f7c31885f5 Move all Mifare related code from libnfc API to examples: NFC is capable of Mifare, but Mifare is not NFC. 2010-06-15 15:33:22 +00:00
Romuald Conty
2e39e56e17 Return value of pn53x_usb_list_devices() must bool, not void* 2010-05-28 09:55:13 +00:00
Romuald Conty
ac663d02a1 Use pn53x_decode_target_data() to decode target data in nfc_initiator_select_tag(). Fix Issue 82. 2010-05-18 10:57:38 +00:00
Romuald Conty
cf0c2dd9f2 Fix ATS lenght in pn53x_decode_target_data(). 2010-05-18 10:55:18 +00:00
Romuald Conty
8c1815fbea Move variable declarations in order to compile using non-C99 compiler. Fix Issue 80. 2010-05-18 08:27:50 +00:00
Romuald Conty
404dfba6e8 usb_release() must be called before usb_reset(). Fix Issue 81 (Thanks to thaolx). 2010-05-18 08:13:26 +00:00
Romain Tartiere
9941191cfc Fix build when configured with --enable-debug. 2010-04-28 12:55:00 +00:00
Romain Tartiere
16786c61e3 Remove bitutils I reverted instead of removing in r412. 2010-04-26 13:20:57 +00:00
Romain Tartiere
b28abd77b0 Merge the libnfc-less-bitutils-more-ponies branch into trunk. 2010-04-26 13:13:13 +00:00
Romuald Conty
e45a0943e8 Change to way to handle DRIVERS_SOURCES in CMake. 2010-04-26 13:00:41 +00:00
Romuald Conty
854cfe15ec Fix ARYGON detection. Rename acConnect to acPort. Now use snprintf and strncpy (see Issue 78) 2010-04-22 10:22:41 +00:00
Romuald Conty
3e16031877 Fix ARYGON driver build (missing comma). 2010-04-22 09:01:22 +00:00
Romuald Conty
367e14dcc0 Prevent from potential buffer-overflows. 2010-04-21 10:58:04 +00:00
Romuald Conty
fa1f9a1ff6 Fix device name: snprintf could not be used to append something to source string. 2010-04-21 10:50:29 +00:00
Romuald Conty
d9ec086beb Replace some sprintf with snprintf to prevent from buffer-overflow. 2010-04-21 10:23:11 +00:00
Romuald Conty
ce6f7f2c84 Fix potential UART speed problem while autoprobing. Extract communication test from pn532_uart_wakeup(). 2010-04-21 10:19:26 +00:00
Romuald Conty
942dcfa631 PN532_UART: prevent from blocking when device doesn't reply correctly to wakeup command. 2010-04-20 15:05:57 +00:00
Romuald Conty
e3ff11eb46 Fix warnings "no previous prototype for ..." on bitutils.[hc] 2010-04-20 09:44:27 +00:00
Romuald Conty
2ab522950f Remove uart_cts() since the function is defined but never used. Fix Issue 71 2010-04-20 08:48:41 +00:00
Romain Tartiere
204130477e (libnfc-less-bitutils-more-ponies) MFT 2010-04-17 13:45:00 +00:00
Romain Tartiere
be3f152d3c Fix a few more warnings. 2010-04-17 13:42:08 +00:00
Romain Tartiere
086e24c407 (libnfc-less-bitutils-more-ponies) Fix build on windows:
- do not depends on byte swapping functions / macros;
  - add basic err.h functionalities.
2010-04-16 22:38:45 +00:00
Romain Tartiere
3e8e1c8844 Fix build on Windows (using cmake and nmake). 2010-04-16 20:39:56 +00:00
Romain Tartiere
3820c34f28 (libnfc-less-bitutils-more-ponies) MFT 2010-04-16 19:27:49 +00:00
Romain Tartiere
0e6719908b (libnfc-less-bitutils-more-ponies) Update CMakeLists.txt. 2010-04-16 17:42:00 +00:00
Romain Tartiere
5e452dbb13 Fix cmake breakage introduced in r352:
error: 'for' loop initial declaration used outside C99 mode
2010-04-16 17:10:08 +00:00
Romain Tartiere
10baef235f (libnfc-less-bitutils-more-ponies) Get rid of bitutils.[hc] (part 1).
- New API function append_iso14443a_crc();
  - Add a PRINT_HEX macro for driver debugging (replaces print_hex function from bitutils.c);
  - Move bit-mirroring related functions to libnfc/mirror-subr.[hc];
  - Move iso14443 related functions to libnfc/iso14443-subr.c;
  - Move libnfc/bitutils.c hex-dumping code to examples/nfc-utils.c;
  - Replace calls to swap_endian32() and swap_endian64() functions with calls to bswap32() and bswap64 provided by endian.h.

And while I am here:
  - Fix the DBG macro so that it does not throw warning at compile time.
2010-04-16 16:38:57 +00:00
Romain Tartiere
0b301d8ff6 Add missing documentation lines. 2010-04-16 13:00:33 +00:00
Romuald Conty
b55400a0d5 configure.ac rework
- Put libusb and PC/SC check in m4 macros.
- Suppress --disable-pcsclite and --disable-libusb
- Add --with-drivers option: we now could choose which driver to build. without this option a default set is build (ATM all drivers except PN532_UART)
2010-04-15 14:41:13 +00:00
Romuald Conty
b747573dc7 PN532_UART readers could now poll using PN532 hardware feature. This commit should fix Issue 56 too. 2010-04-14 13:28:24 +00:00
Romuald Conty
064b7c4b41 Revert libnfc/drivers.h (from r371), this file should not have been commited (in r372).
Second pointy hat to: me again
2010-04-14 10:44:12 +00:00
Romuald Conty
0a08ef00c2 Fix recently changed wakeup function for pn532_uart driver.
Pointy hat to: me ;)
2010-04-14 10:39:18 +00:00
Romuald Conty
a3f68b566d Raise up timeout value in UART, this is tricky (ugly?) hack to allow low speed UART device to run nfc-emulate. 2010-04-13 14:36:02 +00:00
Romuald Conty
2766cd8822 ARYGON readers could now poll using PN532 hardware feature. 2010-04-13 14:11:10 +00:00
Romuald Conty
24e7b20d04 Add debug output when pnd->pdc->tranceive() failed. 2010-04-13 12:48:52 +00:00
Romuald Conty
29fad31ee5 Update ARYGON driver, it now support probing as PN532_UART. Communication should be faster (delays removed).
Note: ARYGON APPB2UA33 oem reader now works.
2010-04-12 14:51:50 +00:00
Romuald Conty
a4d1c53ed3 Add wake up function for PN532 UART and run a communication test to know if device correctly respond. 2010-04-12 14:48:03 +00:00
Romuald Conty
1ba436041b Report found device number in debug mode. 2010-04-12 14:43:19 +00:00
Romuald Conty
c9370e6fac Prevent from running polling on hardware that does not support it. 2010-04-09 23:11:20 +00:00
Romuald Conty
71341b871e Minor comments added. 2010-04-09 23:09:20 +00:00
Romain Tartiere
ee3715e267 Add convenience library infrastructure and move the print_nfc_iso14443a_info() function away from bitutils. 2010-04-09 21:57:03 +00:00
Romuald Conty
40f230d6f0 New API function (experimental): nfc_initiator_poll_targets() which allow to use hardware polling function. Warning: ATM, it only support ISO14443a targets. 2010-04-09 16:20:47 +00:00
Romuald Conty
4128b23f86 Add new function pn53x_decode_target_data() that fill nfc_target_info_t with TargetData byte stream. 2010-04-09 16:18:42 +00:00
Romuald Conty
af9f744390 Add a simple function to print nfc_iso14443a_info_t structure. 2010-04-09 16:11:21 +00:00
Romuald Conty
e9451f71f2 Add details on nfc_initiator_select_dep_target() fct params (enhance documentation). 2010-04-09 15:11:42 +00:00
Romuald Conty
25b49f7879 Fix mis-initialized ATS field when filling-in nfc_target_info_t structure (wrong source address in memcpy()) 2010-04-08 16:20:03 +00:00
Romuald Conty
ab028ab4e2 Add FIXME related to Issue 61. 2010-04-08 16:13:12 +00:00
Romuald Conty
9c43e75691 Redo r336. (Missed at r340) 2010-04-07 16:30:16 +00:00
Romain Tartiere
5473befa13 Fix a brunch of -Wextra warnings:
- 'static' is not at beginning of declaration;
  - unused parameter;
  - comparison between signed and unsigned.
2010-04-07 15:08:04 +00:00
Romuald Conty
3a0d05d15a Minor headers ajustments. 2010-04-07 14:47:53 +00:00
Romain Tartiere
c7d77d7664 Rearrange source code. 2010-04-07 14:37:19 +00:00