Commit graph

256 commits

Author SHA1 Message Date
Audrey Diacre
0f5cc5683d nfc_initiator_poll_target() function returns now libnfc error code. 2011-12-20 15:46:35 +00:00
Audrey Diacre
103485518c nfc_initiator_select_passive_target() function returns now libnfc error code. 2011-12-19 16:27:50 +00:00
Audrey Diacre
ba2a7cfe2e nfc_target_init() function returns now 0 on succes and libnfc error code on failure. 2011-12-19 15:35:37 +00:00
Audrey Diacre
145cc4b2ad nfc_initiator_transceive_bytesfunction now returns libnfc error code on failure and received bytes count on success. 2011-12-19 14:37:22 +00:00
Romuald Conty
bf7c36d9bb less structs and defines publicly exposed
- nfc_device is now an opaque type;
 - PN53x specific errors are not public anymore;
 - nfc_device_name() renamed to nfc_device_get_name() for the sake of consistency;
 - examples/*, utils/* uses the new nfc_device_get_name() function instead of access directly to struct's content;
 - new error defined: NFC_ERFTRANS for notifying about RF transmission error, its used by mifare.c to detect permissions error on mifare;
 - drivers initiator_transceive_bytes() function now returns libnfc's error code on failure (<0), and received bytes count on success (>=0);
 - remove some unused errors.
2011-12-19 00:23:21 +00:00
Romuald Conty
9bdc20353c nfc_device struct is not exposed as public API anymore (partial commit)
- split libnfc's errors and chip's errors
 - fix nfc_property enum
2011-12-15 16:02:38 +00:00
Audrey Diacre
98355d36a7 nfc_initiator_init returns now error code and nfc_initiator_list_passive_targets returns now the number of targets found or error code. 2011-12-15 11:46:14 +00:00
Audrey Diacre
a615d969fd nfc_properties replace now nfc_options and nfc_configure is replaced by nfc_device_set_property_bool which returns error code. 2011-12-14 16:01:00 +00:00
Romuald Conty
26b9c28f48 new properties to tune timeouts:
- add nfc_properties (will replace nfc_options)
 - introduce some error codes
 - rework functions to use the new timeout_command value
2011-12-14 13:27:11 +00:00
Romuald Conty
c286eec920 DEP enhancements:
- Add timeout on InJumpForDEP (pn53x) and initiator_select_dep (libnfc API)
- test_dep now works again (except 424Kbps)
- Fix ndi.ndm feeling when select a DEP target
Important: test_dep does not work on PN53x_USB devices after running previous tests
2011-12-06 10:05:35 +00:00
Audrey Diacre
5a9a778879 Remove whitespace after star symbol for pointers 2011-11-25 13:32:29 +00:00
Audrey Diacre
5c7454a2f7 Timeout is now integer. 2011-11-25 11:37:30 +00:00
Audrey Diacre
784a2f86a2 Change byte_t type to uint8_t (Fixes Issue 147) 2011-11-24 10:54:42 +00:00
Audrey Diacre
c718fafee7 Massive code clean up: (Fixes Issue 161)
- Remove typedef from internal structs
- Remove _t suffix from types
- Fix tests using connstrings
2011-11-23 15:55:40 +00:00
Anugrah Redja Kusuma
136cfdf48d Implement driver for ACR122S device 2011-11-23 03:05:12 +00:00
Romuald Conty
55daa29a7c Allow to connect to a device using a connection string:
- Provide a nfc_get_default_device() that allow to grab the connstring stored
   in LIBNFC_DEFAULT_DEVICE environnement variable or returns the first
   available device if not set;
 - nfc_connect(NULL) now takes the default device (see
   nfc_get_default_device());
 - Removes nfc_driver_desc_t from public types
 - Defines nfc_connstring as char[1024]
 - examples/*: use nfc_connstring
 - examples/nfc-poll: now uses only the default device (instead of all devices
   availables)
 - Removes parse_args() from nfc-utils.[hc]
2011-10-17 13:03:56 +00:00
Romuald Conty
dccfd65c80 Add software polling for non-PN532 equipped device (Fixes Issue 136) 2011-10-03 11:19:08 +00:00
Romuald Conty
590e3910de Document new timeout parameter 2011-09-29 09:49:08 +00:00
Romain Tartiere
481fb4943f - Add timeout capablities to nfc_initiator_transceive_bytes(), nfc_target_send_bytes() and nfc_target_receive_bytes();
- Bump version to 1.5.1.
2011-09-22 13:03:47 +00:00
Romuald Conty
e8eec583ed Enhance logging system:
* Removes internal DBG/WARN/ERR macros (but keep them in examples);
 * Removes almost all DEBUG define references;
 * Uses the flexible log4c library to log all messages.
2011-09-12 14:50:01 +00:00
Romain Tartiere
84918fd075 Fix invalid memory access when a new driver is probing for hardware and the number of requested devices was already reached.
The probing functions assume that at least one device should be found and
passed to the caller, and only after finding such a device they will check that
they should eventually stop looking for more devices.  While we could make each
probing function capable of handling the special-case of finding 0 devices, it
is much more consistent to perform the check from the calling function.
2011-06-30 13:35:40 +00:00
Romuald Conty
fd19773c21 drivers/pn53x_usb: Make valgrind more happy :) 2011-06-28 14:05:40 +00:00
Romuald Conty
699e9008d1 Move ISO14443-3 UID cascading in a dedicated function. 2011-06-27 10:19:00 +00:00
Romain Tartiere
a8394caed5 Fix comparison between signed and unsigned. 2011-06-13 21:46:01 +00:00
Philippe Teuwen
80a5ad1fd6 More attempt to support Sony S360 reader
Initialisation of RC-S360 in mode 0
Better generic nfc-list, does not rely only on DeSelect to avoid duplicates
Restore SetParameters for RC-S360
Handle Diagnose communication test properly

Tested:
    - nfc-list          => ok except for B' & 3B
    - nfc-anticol       => fails to send raw frames before select
    - nfc-mfultralight  => ok
    - nfc-mfclassic     => ok
    - pn53x-tamashell   => ok
    - pn53x-diagnose    => ok
    - nfc-dep-initiator => ok
    - nfc-dep-target    => fails in InitAsTarget
    - nfc-emulate-*     => fails in InitAsTarget

Commands momentarily disabled for RC-S330:
    - InDeselect
    - InRelease
    - select_passive_target for B'& 3B
2011-06-07 20:36:20 +00:00
Romuald Conty
17c63aebb5 pn53x_usb: continue to search a available device on usb errors (r1092 reverted then issue fixed). 2011-05-25 12:08:42 +00:00
Romuald Conty
78ce62e7b6 Fix ISO/IEC 14443-4 hardware emulation.
NDO_AUTO_ISO14443_4 is now set to _true_ by default with nfc_target_init();
nfc_emulate_target() now fails (return _false_) when emulator->state_machine->io() failed;
Initialize nfc_device_t variables to _false_ in order to send correctly (see notes in nfc-device.c);
nfc_emulate_forum_tag4 prints error when nfc_emulate_target() failed.
2011-05-24 17:10:13 +00:00
Romuald Conty
975cd275d1 minor fixes 2011-05-20 16:09:00 +00:00
Philippe Teuwen
ff7696fffb nfc.c: reformulate comments of prev commit in chip-agnostic way. BTW there is more to do... 2011-05-12 20:51:44 +00:00
Philippe Teuwen
e5601e562f _timed(): now allows indirect control of intern prescaler via max expected cycles count 2011-05-12 20:33:00 +00:00
Philippe Teuwen
ab54a37678 list_targets support for ASK CTS512B (no anticol support yet) 2011-05-11 23:00:54 +00:00
Philippe Teuwen
53f1acfdcb _timed() fcts: allow 32b cycles counter & prescaler!=0 2011-05-11 20:56:09 +00:00
Philippe Teuwen
21dfe81d0b Some optimisations in initialisation of registers 2011-05-10 23:44:27 +00:00
Romuald Conty
be0f0b0828 New function nfc_idle() to set the NFC device in idle mode.
nfc_disconnect() now switch NFC device into idle before disconnecting;
pn53x_data now have a operating_mode enum to know the current running mode (initiator, target or idle);
new pn53x_PowerDown wrapper for PowerDown (PN532) command;

Note: ARYGON idle mode now to be implemented and ACR122 does not support this mode.
2011-05-09 10:09:40 +00:00
Romuald Conty
3a9327d1be document nfc_abort_command() 2011-05-06 23:25:41 +00:00
Philippe Teuwen
d834860965 Add partial support (list) for ISO14443B-3 ST SRx & ASK CTx cards 2011-05-06 19:11:03 +00:00
Romuald Conty
cd6946e751 Add ISO/IEC 14443 B' aka Type B' modulation partial support 2011-05-06 14:14:06 +00:00
Philippe Teuwen
e276d3e6ba nfc_target_init: drop explicitely the field 2011-05-05 14:58:26 +00:00
Philippe Teuwen
8dd8d25ef7 LoGO progressive field: remove hacks, unneeded with revised initializations 2011-05-05 12:45:56 +00:00
Romuald Conty
008f2a8d4c Minor returns fixes. 2011-05-05 11:46:12 +00:00
Philippe Teuwen
4124dc662d Cleanup of initializations 2011-05-05 10:12:26 +00:00
Romuald Conty
0265515a0c Abort mecanism is now implemented in driver layer:
iAbortFd file descriptor array have been removed from nfc_device_t;
nfc_abort_command() can now failed (return false);
nfc_abort_command() now call abort_command pointer from drivers;
pn532_uart and arygon drivers use a pipe-based mecanism (similar from previous one);
pn53x_usb driver use a boolean flag-based mecanism (the previous one does not work as expected);
pn53x_usb now print smarter messages on error at usb connection;
pn53x_usb now handle a strange case: sometimes, the first sent command is not ACKed by PN53x USB device, a dummy command is now sent.
2011-05-05 09:27:17 +00:00
Philippe Teuwen
f2cb0eaa6e list_passive_targets: fixed for TypeB on LoGO 2011-05-03 19:22:28 +00:00
Philippe Teuwen
7f2b300dde support crc auto-handling in ...transceive_bytes_timed 2011-04-04 22:23:38 +00:00
Philippe Teuwen
fb398c387f pn53x: add timed versions of transceive_bytes/bits 2011-04-04 14:16:36 +00:00
Romuald Conty
5db8be908b Windows support contribution:
- Move CMake modules from cmake_modules/ to cmake/modules/
 - CMake now use cmake/config_windows.h.cmake to create config.h on Windows platform
 - contrib/windows.h header is automagically included by config.h
 - Put missing NFC_EXPORT macro on front of emulation API
 - nfc-mfclassic and nfc-mfcultralight examples are now compiled under Windows
Many thanks to Glenn Ergeerts which provide the initial patch.
2011-03-31 13:38:49 +00:00
Romain Tartiere
605a5f2db3 Fix nfc_pick_device() when called from nfc_connect with NULL nfc_device_desc_t parameter (Fixes Issue 156) 2011-03-09 13:49:33 +00:00
Romain Tartiere
61fa081cfe Unbreak support of ACR122.
Only tested w/ a touchatag.
@yobibe: _NO_ LED support yet (OMG!)
2011-03-08 14:33:32 +00:00
Romain Tartiere
f1f31d1b4c Unbreak and merge PN53x USB drivers.
While here fix some includes that would not work if SRCDIR != BUILDDIR.
2011-03-05 19:54:52 +00:00
Romuald Conty
0efa47880b Hardware abstraction layer for libnfc:
Suppress any PN53x references in nfc.c
Improve nfc_driver_t struct to embedded HAL API
Merge macros from nfc-messages.h into nfc-internal.h
Remove useless files: nfc-messages.h, buses.h and chips.h
Implement HAL for ARYGON driver
Move send/receive callbacks from nfc_driver_t to internal chip io callbacks (since there are dedicated to pn53x framing)
2011-03-05 10:06:52 +00:00
Romain Tartiere
4b6060aeeb Enable aborting blocking commands (e.g. TgInitAsTarget) and refactor
*_check_communication() as pn53x_check_communication().
2011-03-04 19:59:49 +00:00
Romain Tartiere
4d65868208 Only call pn53x_init() from the drivers initialization functions. 2011-03-04 11:23:20 +00:00
Romain Tartiere
b1521a3bb1 If the current driver name does not match what we are looking for, move to the
next one before retrying.
2011-03-04 11:18:47 +00:00
Romuald Conty
f81138b3c7 ARYGON driver works again and PN532_UART improved :)
drivers/pn532_uart: code clean up
chips/pn53x: new fonction to build frames
drivers/arygon: use the new way to drive UART (its far more stable)
2011-03-04 09:28:25 +00:00
Romuald Conty
5af845cdfc Broke whole the libnfc :-)
use a new way to handle drivers
use absolute include path instead of relative ones
move some nfc_device_t members in a better place
nfc_device_t now embeddeds driver data and chip data pointers (useful to be more generic)
use more readable variables instead of strange coding convention
move PRINT_HEX macro into nfc-internal.h
silent warnings with more strict CFLAGS
chips/pn53x: use the powerful C99 writing to construct PN53x commands
chips/pn53x: remove almost all memcpy()
chips/pn53x: WriteRegister, ReadRegister and SetParameters command wrappers are correctly named
chips/pn53x: introduce chip state (SLEEP, NORMAL or EXECUTE)
chips/pn53x: add SAMConfiguration command wrapper (need to be improved)
chips/pn53x: remove almost all const arrays
chips/pn53x: use human readable defines for commands instead of hex values
chips/pn53x: in debug mode, the PN53x command is shown in human-readable string, awesome isn't it? ;-)
drivers: split transceive() into send() and receive() to be able to handle more cases (differed replies, abort commands, etc) later
drivers: use a const structure of functions instead of -dirty- callbacks array
drivers/pn532_uart: major improvement of UART handling
drivers/pn532_uart: check PN53x frames when received
buses/uart: receive() is now based on expected bytes instead of calculated timeouts..
buses/uart: use a smart way to determine available ports on POSIX systems (tested on Linux and FreeBSD)
2011-03-02 15:00:44 +00:00
Romuald Conty
58ad2a5760 Add new supported device: ASK / LoGO. (Thanks to ASK for sending one sample of this device) 2011-02-01 21:20:48 +00:00
Romuald Conty
58dcf63e7c MERGE: libnfc-mingw-cross merge with trunk (r805-821) 2010-11-17 08:29:41 +00:00
Philippe Teuwen
f75d2d3582 Typo 2010-10-18 16:17:01 +00:00
Romuald Conty
bfb49b594f Clean the way to retrieve firmware 2010-10-18 13:19:30 +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
Romuald Conty
7c76e1bf32 nfc_target_init() now update nfc_target_t baud rate 2010-10-14 16:27:50 +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
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
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
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
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
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
Romuald Conty
4d880e6ce8 Enhance documentation and fix typo. 2010-09-29 14:26:06 +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
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
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
Romuald Conty
5dbdabcec2 Be sure that NDO_AUTO_ISO14443_4 is activated by default. 2010-09-06 11:16:24 +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
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
Romain Tartiere
5b0589c381 Merge r551-563 from trunk. 2010-08-20 10:41:30 +00:00
Romuald Conty
8f19b078ff Add configuration option to enable/disable auto iso14443-4 mode. 2010-08-19 10:58:15 +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
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
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
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
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
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
d11e7a1320 Prevent from segfault when nfc_disconnect() on NULL pointer 2010-08-11 16:38:22 +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
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
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
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
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
Romain Tartiere
9984e1bdcb Start of work on error handling. 2010-07-26 12:41:46 +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
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
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
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
Romain Tartiere
be3f152d3c Fix a few more warnings. 2010-04-17 13:42:08 +00:00
Romain Tartiere
3e8e1c8844 Fix build on Windows (using cmake and nmake). 2010-04-16 20:39:56 +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
0b301d8ff6 Add missing documentation lines. 2010-04-16 13:00:33 +00:00
Romuald Conty
24e7b20d04 Add debug output when pnd->pdc->tranceive() failed. 2010-04-13 12:48:52 +00:00