[libnfc] push by yob...@gmail.com - Better list of supported modulations & baud rates... on 2014-03-11 23:00 GMT

11 views
Skip to first unread message

lib...@googlecode.com

unread,
Mar 11, 2014, 7:00:33 PM3/11/14
to libnfc-...@googlegroups.com
Revision: e57dc8a746d5
Author: Philippe Teuwen <yob...@gmail.com>
Date: Tue Mar 11 22:52:47 2014 UTC
Log: 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:

http://code.google.com/p/libnfc/source/detail?r=e57dc8a746d5

Modified:
/NEWS
/include/nfc/nfc.h
/libnfc/chips/pn53x.c
/libnfc/chips/pn53x.h
/libnfc/drivers/pn53x_usb.c
/libnfc/nfc-internal.h
/libnfc/nfc.c

=======================================
--- /NEWS Mon Feb 24 14:55:41 2014 UTC
+++ /NEWS Tue Mar 11 22:52:47 2014 UTC
@@ -1,3 +1,9 @@
+New in 1.7.x:
+
+API Changes:
+
+ * nfc_device_get_supported_baud_rate() now takes also "mode" as argument
+
New in 1.7.1:

API Changes:
=======================================
--- /include/nfc/nfc.h Mon Aug 19 12:55:27 2013 UTC
+++ /include/nfc/nfc.h Tue Mar 11 22:52:47 2014 UTC
@@ -126,7 +126,7 @@
NFC_EXPORT const char *nfc_device_get_name(nfc_device *pnd);
NFC_EXPORT const char *nfc_device_get_connstring(nfc_device *pnd);
NFC_EXPORT int nfc_device_get_supported_modulation(nfc_device *pnd, const
nfc_mode mode, const nfc_modulation_type **const supported_mt);
-NFC_EXPORT int nfc_device_get_supported_baud_rate(nfc_device *pnd, const
nfc_modulation_type nmt, const nfc_baud_rate **const supported_br);
+NFC_EXPORT int nfc_device_get_supported_baud_rate(nfc_device *pnd, const
nfc_mode mode, const nfc_modulation_type nmt, const nfc_baud_rate **const
supported_br);

/* Properties accessors */
NFC_EXPORT int nfc_device_set_property_int(nfc_device *pnd, const
nfc_property property, const int value);
=======================================
--- /libnfc/chips/pn53x.c Mon Mar 10 23:25:33 2014 UTC
+++ /libnfc/chips/pn53x.c Tue Mar 11 22:52:47 2014 UTC
@@ -52,7 +52,8 @@
const uint8_t pn53x_ack_frame[] = { 0x00, 0x00, 0xff, 0x00, 0xff, 0x00 };
const uint8_t pn53x_nack_frame[] = { 0x00, 0x00, 0xff, 0xff, 0x00, 0x00 };
static const uint8_t pn53x_error_frame[] = { 0x00, 0x00, 0xff, 0x01, 0xff,
0x7f, 0x81, 0x00 };
-const nfc_baud_rate pn53x_iso14443a_supported_baud_rates[] = { NBR_106, 0
};
+const nfc_baud_rate pn532_iso14443a_supported_baud_rates[] = { NBR_424,
NBR_212, NBR_106, 0 };
+const nfc_baud_rate pn533_iso14443a_supported_baud_rates[] = { NBR_847,
NBR_424, NBR_212, NBR_106, 0 };
const nfc_baud_rate pn53x_felica_supported_baud_rates[] = { NBR_424,
NBR_212, 0 };
const nfc_baud_rate pn53x_dep_supported_baud_rates[] = { NBR_424, NBR_212,
NBR_106, 0 };
const nfc_baud_rate pn53x_jewel_supported_baud_rates[] = { NBR_106, 0 };
@@ -96,6 +97,12 @@
if (pnd->btSupportByte & SUPPORT_ISO14443B) {

CHIP_DATA(pnd)->supported_modulation_as_initiator[nbSupportedModulation] =
NMT_ISO14443B;
nbSupportedModulation++;
+
CHIP_DATA(pnd)->supported_modulation_as_initiator[nbSupportedModulation] =
NMT_ISO14443BI;
+ nbSupportedModulation++;
+
CHIP_DATA(pnd)->supported_modulation_as_initiator[nbSupportedModulation] =
NMT_ISO14443B2SR;
+ nbSupportedModulation++;
+
CHIP_DATA(pnd)->supported_modulation_as_initiator[nbSupportedModulation] =
NMT_ISO14443B2CT;
+ nbSupportedModulation++;
}
if (CHIP_DATA(pnd)->type != PN531) {

CHIP_DATA(pnd)->supported_modulation_as_initiator[nbSupportedModulation] =
NMT_JEWEL;
@@ -1158,7 +1165,7 @@
if ((res = pn53x_decode_target_data(abtTargetsData + 1, szTargetsData
- 1, CHIP_DATA(pnd)->type, nm.nmt, &(nttmp.nti))) < 0) {
return res;
}
- if (nm.nbr != NBR_106) {
+ if ((nm.nmt == NMT_ISO14443A) && (nm.nbr != NBR_106)) {
uint8_t pncmd_inpsl[4] = { InPSL, 0x01 };
pncmd_inpsl[2] = nm.nbr - 1;
pncmd_inpsl[3] = nm.nbr - 1;
@@ -3265,19 +3272,21 @@
}

int
-pn53x_get_supported_baud_rate(nfc_device *pnd, const nfc_modulation_type
nmt, const nfc_baud_rate **const supported_br)
+pn53x_get_supported_baud_rate(nfc_device *pnd, const nfc_mode mode, const
nfc_modulation_type nmt, const nfc_baud_rate **const supported_br)
{
switch (nmt) {
case NMT_FELICA:
*supported_br = (nfc_baud_rate *)pn53x_felica_supported_baud_rates;
break;
- case NMT_ISO14443A:
- *supported_br = (nfc_baud_rate
*)pn53x_iso14443a_supported_baud_rates;
- break;
- case NMT_ISO14443B:
- case NMT_ISO14443BI:
- case NMT_ISO14443B2SR:
- case NMT_ISO14443B2CT: {
+ case NMT_ISO14443A: {
+ if ((CHIP_DATA(pnd)->type != PN533) || (mode == N_TARGET)) {
+ *supported_br = (nfc_baud_rate
*)pn532_iso14443a_supported_baud_rates;
+ } else {
+ *supported_br = (nfc_baud_rate
*)pn533_iso14443a_supported_baud_rates;
+ }
+ }
+ break;
+ case NMT_ISO14443B: {
if ((CHIP_DATA(pnd)->type != PN533)) {
*supported_br = (nfc_baud_rate
*)pn532_iso14443b_supported_baud_rates;
} else {
@@ -3285,6 +3294,11 @@
}
}
break;
+ case NMT_ISO14443BI:
+ case NMT_ISO14443B2SR:
+ case NMT_ISO14443B2CT:
+ *supported_br = (nfc_baud_rate
*)pn532_iso14443b_supported_baud_rates;
+ break;
case NMT_JEWEL:
*supported_br = (nfc_baud_rate *)pn53x_jewel_supported_baud_rates;
break;
@@ -3347,7 +3361,7 @@
}
buflen -= res;
const nfc_baud_rate *nbr;
- if ((res = nfc_device_get_supported_baud_rate(pnd, nmt[i], &nbr)) < 0)
{
+ if ((res = nfc_device_get_supported_baud_rate(pnd, N_INITIATOR,
nmt[i], &nbr)) < 0) {
free(*pbuf);
return res;
}
@@ -3400,7 +3414,6 @@
free(*pbuf);
return res;
}
-
for (int i = 0; nmt[i]; i++) {
if ((res = snprintf(buf, buflen, "%s%s (", (i == 0) ? "" : ", ",
str_nfc_modulation_type(nmt[i]))) < 0) {
free(*pbuf);
@@ -3413,7 +3426,7 @@
}
buflen -= res;
const nfc_baud_rate *nbr;
- if ((res = nfc_device_get_supported_baud_rate(pnd, nmt[i], &nbr)) < 0)
{
+ if ((res = nfc_device_get_supported_baud_rate(pnd, N_TARGET, nmt[i],
&nbr)) < 0) {
free(*pbuf);
return res;
}
=======================================
--- /libnfc/chips/pn53x.h Wed Jul 17 11:57:56 2013 UTC
+++ /libnfc/chips/pn53x.h Tue Mar 11 22:52:47 2014 UTC
@@ -392,7 +392,7 @@
int pn53x_check_error_frame(struct nfc_device *pnd, const uint8_t
*pbtRxFrame, const size_t szRxFrameLen);
int pn53x_build_frame(uint8_t *pbtFrame, size_t *pszFrame, const
uint8_t *pbtData, const size_t szData);
int pn53x_get_supported_modulation(nfc_device *pnd, const nfc_mode
mode, const nfc_modulation_type **const supported_mt);
-int pn53x_get_supported_baud_rate(nfc_device *pnd, const
nfc_modulation_type nmt, const nfc_baud_rate **const supported_br);
+int pn53x_get_supported_baud_rate(nfc_device *pnd, const nfc_mode mode,
const nfc_modulation_type nmt, const nfc_baud_rate **const supported_br);
int pn53x_get_information_about(nfc_device *pnd, char **pbuf);

void *pn53x_data_new(struct nfc_device *pnd, const struct pn53x_io *io);
=======================================
--- /libnfc/drivers/pn53x_usb.c Sun Sep 22 01:31:50 2013 UTC
+++ /libnfc/drivers/pn53x_usb.c Tue Mar 11 22:52:47 2014 UTC
@@ -60,6 +60,8 @@

#define DRIVER_DATA(pnd) ((struct pn53x_usb_data*)(pnd->driver_data))

+const nfc_modulation_type no_target_support[] = {0};
+
typedef enum {
UNKNOWN,
NXP_PN531,
@@ -708,6 +710,16 @@
DRIVER_DATA(pnd)->abort_flag = true;
return NFC_SUCCESS;
}
+
+static int
+pn53x_usb_get_supported_modulation(nfc_device *pnd, const nfc_mode mode,
const nfc_modulation_type **const supported_mt)
+{
+ if ((DRIVER_DATA(pnd)->model != ASK_LOGO) || (mode != N_TARGET))
+ return pn53x_get_supported_modulation(pnd, mode, supported_mt);
+ else // ASK_LOGO has no N_TARGET support
+ *supported_mt = no_target_support;
+ return NFC_SUCCESS;
+}

const struct pn53x_io pn53x_usb_io = {
.send = pn53x_usb_send,
@@ -742,7 +754,7 @@

.device_set_property_bool = pn53x_usb_set_property_bool,
.device_set_property_int = pn53x_set_property_int,
- .get_supported_modulation = pn53x_get_supported_modulation,
+ .get_supported_modulation = pn53x_usb_get_supported_modulation,
.get_supported_baud_rate = pn53x_get_supported_baud_rate,
.device_get_information_about = pn53x_get_information_about,

=======================================
--- /libnfc/nfc-internal.h Sat Feb 1 01:01:10 2014 UTC
+++ /libnfc/nfc-internal.h Tue Mar 11 22:52:47 2014 UTC
@@ -148,7 +148,7 @@
int (*device_set_property_bool)(struct nfc_device *pnd, const
nfc_property property, const bool bEnable);
int (*device_set_property_int)(struct nfc_device *pnd, const
nfc_property property, const int value);
int (*get_supported_modulation)(struct nfc_device *pnd, const nfc_mode
mode, const nfc_modulation_type **const supported_mt);
- int (*get_supported_baud_rate)(struct nfc_device *pnd, const
nfc_modulation_type nmt, const nfc_baud_rate **const supported_br);
+ int (*get_supported_baud_rate)(struct nfc_device *pnd, const nfc_mode
mode, const nfc_modulation_type nmt, const nfc_baud_rate **const
supported_br);
int (*device_get_information_about)(struct nfc_device *pnd, char **buf);

int (*abort_command)(struct nfc_device *pnd);
=======================================
--- /libnfc/nfc.c Tue Mar 4 00:27:01 2014 UTC
+++ /libnfc/nfc.c Tue Mar 11 22:52:47 2014 UTC
@@ -1196,14 +1196,15 @@
* @brief Get supported baud rates.
* @return Returns 0 on success, otherwise returns libnfc's error code
(negative value)
* @param pnd \a nfc_device struct pointer that represent currently used
device
+ * @param mode \a nfc_mode.
* @param nmt \a nfc_modulation_type.
* @param supported_br pointer of \a nfc_baud_rate array.
*
*/
int
-nfc_device_get_supported_baud_rate(nfc_device *pnd, const
nfc_modulation_type nmt, const nfc_baud_rate **const supported_br)
+nfc_device_get_supported_baud_rate(nfc_device *pnd, const nfc_mode mode,
const nfc_modulation_type nmt, const nfc_baud_rate **const supported_br)
{
- HAL(get_supported_baud_rate, pnd, nmt, supported_br);
+ HAL(get_supported_baud_rate, pnd, mode, nmt, supported_br);
}

/* Misc. functions */
Reply all
Reply to author
Forward
0 new messages