Skip to content

Commit dea37cb

Browse files
committed
code review from paul,don addressed:compilers fixed
1 parent c509af3 commit dea37cb

File tree

11 files changed

+98
-125
lines changed

11 files changed

+98
-125
lines changed

TEST_APPS/device/nfcapp/mbed_app.json

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,28 @@
11
{
22
"config": {
3-
"TEST_NDEF_MSG_MAX" : 1024
3+
"TEST_NDEF_MSG_MAX": {
4+
"help": "NFC-Driver buffer (EEPROM and Controller) maximum MAX Size of NFC message(s) driver buffer",
5+
"value": 4096
6+
}
47
},
58
"target_overrides": {
69
"DISCO_L475VG_IOT01A": {
710
"target.extra_labels_add": ["M24SR"],
8-
"MBED_NFC_M24SR.nfceeprom": true
11+
"MBED_NFC_M24SR.nfceeprom": true
912
},
1013
"NUCLEO_F401RE": {
11-
"target.extra_labels_add": ["PN512"]
14+
"target.extra_labels_add": ["PN512"],
15+
"MBED_NFC_M24SR.nfceeprom": false
1216
},
1317
"NUCLEO_F746ZG": {
1418
"target.extra_labels_add": ["M24SR"],
1519
"MBED_NFC_M24SR.X_NUCLEO_NFC01A1": true,
1620
"MBED_NFC_M24SR.nfceeprom": true
21+
},
22+
"NUCLEO_F429ZI": {
23+
"target.extra_labels_add": ["M24SR"],
24+
"MBED_NFC_M24SR.X_NUCLEO_NFC01A1": true,
25+
"MBED_NFC_M24SR.nfceeprom": true
1726
}
1827
}
1928
}

TEST_APPS/device/nfcapp/nfccommands.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <vector>
1818
#include <stdarg.h>
1919
#include <stdlib.h>
20+
#include <ctype.h>
2021
#include "mbed_events.h"
2122
#include "mbed-client-cli/ns_cmdline.h"
2223
#include "rtos\Thread.h"

TEST_APPS/device/nfcapp/nfcprocessEeprom.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <stdarg.h>
1818
#include <cstring>
1919
#include <string.h>
20+
#include <stdlib.h>
2021
#include "mbed_events.h"
2122
#include "mbed-client-cli/ns_cmdline.h"
2223

@@ -98,6 +99,7 @@ void NFCProcessEEPROM::on_ndef_message_written(nfc_err_t result)
9899
}
99100
// complete the async test method here
100101
cmd_ready(CMDLINE_RETCODE_SUCCESS);
102+
free(long_string); // free buffer allocated by the command class now
101103
}
102104

103105
void NFCProcessEEPROM::on_ndef_message_read(nfc_err_t result)

TEST_APPS/device/nfcapp/nfcprocessEeprom.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@
3838
class NFCProcessEEPROM : NFCTestShim, mbed::nfc::NFCEEPROM::Delegate {
3939
public:
4040
NFCProcessEEPROM(events::EventQueue &queue, mbed::nfc::NFCEEPROMDriver &eeprom_driver);
41-
nfc_err_t init();
41+
virtual nfc_err_t init();
4242
void queue_write_call();
4343
void queue_write_long_call();
4444
void queue_read_call();
4545
void queue_erase_call();
46-
void cmd_get_max_ndef();
46+
virtual void cmd_get_max_ndef();
4747

4848

4949
private:

TEST_APPS/device/nfcapp/nfctestshim.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <stdarg.h>
1818
#include <cstring>
1919
#include <string.h>
20+
#include <stdlib.h>
2021
#include "mbed-client-cli/ns_cmdline.h"
2122
#include "nfc/ndef/common/Text.h"
2223
#include "nfc/ndef/common/URI.h"
@@ -41,7 +42,7 @@ using mbed::nfc::nfc_rf_protocols_bitmask_t;
4142

4243
// statics
4344
namespace {
44-
char long_string[MBED_CONF_APP_TEST_NDEF_MSG_MAX];
45+
4546
char const *uri_prefix_string[] = { "",
4647
"http://www.",
4748
"https://www.",
@@ -278,15 +279,15 @@ void NFCTestShim::cmd_erase()
278279

279280
/** \brief Writes a Text T record buffer with really long message - length checks to be done by driver only.
280281
* If an NFC controller, no write to the chip happens, we copy the data into a Controller buffer
281-
* \param uri This method must free the passed in pointer
282-
* \return void An ICETEA error code and NFC error is set asyncronously
282+
* \param text_string This method must free the passed in pointer
283+
* \return void An ICETEA error code and NFC error is set asynchronously
283284
*/
284285
void NFCTestShim::cmd_write_long(char *text_string)
285286
{
286287
MessageBuilder builder(_ndef_poster_message);
287-
strcpy(::long_string, text_string); //max_ndef - header - overheads
288+
long_string = text_string; // copy the pointer and free it when the write completes
288289
Text text(Text::UTF8, span_from_cstr("en-US"),
289-
span_from_cstr((const char *)(::long_string)));
290+
span_from_cstr((const char *)(long_string)));
290291

291292
text.append_as_record(builder, true);
292293
_ndef_write_buffer_used = builder.get_message().size();
@@ -295,12 +296,12 @@ void NFCTestShim::cmd_write_long(char *text_string)
295296
#if MBED_CONF_NFCEEPROM
296297
((NFCProcessEEPROM *)this)->queue_write_call();
297298
#else
298-
// not on a wire, so the caller will store the message in a buffer
299+
// not on a wire, and we just stored the message in _ndef_write_buffer above
299300
set_last_nfc_error(NFC_OK);
300301
cmd_ready(CMDLINE_RETCODE_SUCCESS);
302+
free(long_string); // free buffer allocated by the command class now
301303
#endif
302304
trace_printf("NFCTestShim::write_long() exit\r\n");
303-
free(text_string);
304305
}
305306

306307
/** \brief Write a URI Use case would be to prompt to install an app from the appstore using the tag

TEST_APPS/device/nfcapp/nfctestshim.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ class NFCTestShim {
100100
uint8_t _ndef_buffer[MBED_CONF_APP_TEST_NDEF_MSG_MAX]; // driver I/O buffer
101101
bool _discovery_restart; // default true, restart discovery loop again on remote disconnect
102102
events::EventQueue &_queue;
103+
char *long_string;
103104
};
104105

105106
// forward declare single instance

TEST_APPS/icetea_plugins/nfc_test_parsers.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,17 +110,17 @@ def trace_parser(self, response):
110110
if value is not False:
111111
results['lastnfcerror'] = int(value)
112112
# {{nfcmessage=([0-9a-f\s]*)}}
113+
# message may be split over multiple lines, so we will start a search and wait until we get a }} pair
113114
data = PluginBase.find_one(line, "{{nfcmessage=([0-9a-f\s]*).*")
114115
if data is not False:
115116
started_read_data = True
116117
if started_read_data: # read data until we see a }} pair
117118
values = self.find_all_hex_data(line, "([0-9a-f\s]*)")
118119
if values is not False:
119120
if "{{nfcmessage" in line:
120-
value = values[0]
121+
value = values[0] # first (and possibly only data line)
121122
else:
122-
value = values[0]
123-
#print ("==%s==" % value)
123+
value += values[0] # concatenate (2nd and possibly last data line)
124124
partial_data += value
125125
if PluginBase.find_one(line, ".*(}})") is not False: # search for end marker
126126
started_read_data = False

TEST_APPS/testcases/nfc/nfc_clf_wrapper.py

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,6 @@
2525
"""
2626

2727

28-
# def command_is(string, command):
29-
# return string.split(' ')[0] == command
30-
3128

3229
def debug_nfc_data(key, value):
3330
"""
@@ -55,25 +52,27 @@ def __init__(self):
5552
logger.error("The NFC reader was not detected on any USB port!")
5653
self.clfResponse = None
5754

58-
def clf_response(self):
59-
return self.clfResponse
60-
61-
def connect(self, target_options = ("106A","106B","212F")):
55+
def connect(self):
6256
# note: only supporting type4
57+
time.sleep(0.5)
6358
after5s = lambda: time.time() - started > 5
6459
started = time.time()
60+
6561
tag = self.clf.connect( rdwr={'on-connect': lambda tag: False},
66-
llcp={}, terminate = after5s)
67-
self.clfResponse = tag
62+
terminate = after5s)
6863
if tag: # None if timeout expires
6964
logging.info("NFCReader: connected " + str(tag))
65+
else:
66+
logging.info("NFCReader: warning, no tag detected ")
7067
return tag
7168

7269
def mute(self):
7370
"""turn off the reader radio"""
74-
if self.clf.device:
71+
if (self.clf.device is not None):
7572
logging.info("NFCReader: radio mute" + self.clf.device.product_name)
7673
self.clf.device.mute()
74+
else:
75+
logging.warning("NFCReader: reader not initialized!")
7776

7877
def disconnect(self):
7978
logging.info("NFCReader: close frontend.")
@@ -97,5 +96,3 @@ def __getattr__(self, name):
9796

9897
__nfc_wrapper = None
9998

100-
def clf_response(self):
101-
return self.nfc.clf_response()

TEST_APPS/testcases/nfc/nfc_cli_helper.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
import logging
2323
import icetea_lib.tools.asserts as asserts
2424

25-
# Values > 4 k incur large time costs
26-
STRESS_BUFFLEN = 4096 # Default value for large buffer tests, this value can be read from the target with a command
25+
# Values > 1 k incur large time costs
26+
LARGE_BUFFLEN = 400 # Value for large buffer tests, a maximum value can be read from the target with a command
2727

2828
class CliHelper():
2929
"""

0 commit comments

Comments
 (0)