@@ -60,25 +60,21 @@ static void greentea_notify_completion(const int);
60
60
static void greentea_notify_version ();
61
61
static void greentea_write_string (const char *str);
62
62
63
- /* * \brief Handshake with host and send setup data (timeout and host test name)
64
- * \details This function will send preamble to master.
65
- * After host test name is received master will invoke host test script
66
- * and add hos test's callback handlers to main event loop
67
- * This function is blocking.
68
- */
69
- void GREENTEA_SETUP (const int timeout, const char *host_test_name) {
63
+
64
+ void _GREENTEA_SETUP_COMMON (const int timeout, const char *host_test_name, char *buffer, size_t size) {
70
65
greentea_metrics_setup ();
71
66
// Key-value protocol handshake function. Waits for {{__sync;...}} message
72
67
// Sync preamble: "{{__sync;0dad4a9d-59a3-4aec-810d-d5fb09d852c1}}"
73
68
// Example value of sync_uuid == "0dad4a9d-59a3-4aec-810d-d5fb09d852c1"
74
- char _key[8 ] = {0 };
75
- char _value[48 ] = {0 };
76
- while (1 ) {
77
- greentea_parse_kv (_key, _value, sizeof (_key), sizeof (_value));
69
+
70
+ char _key[8 ] = {0 };
71
+
72
+ while (1 ) {
73
+ greentea_parse_kv (_key, buffer, sizeof (_key), size);
78
74
greentea_write_string (" mbedmbedmbedmbedmbedmbedmbedmbed\r\n " );
79
75
if (strcmp (_key, GREENTEA_TEST_ENV_SYNC) == 0 ) {
80
76
// Found correct __sunc message
81
- greentea_send_kv (_key, _value );
77
+ greentea_send_kv (_key, buffer );
82
78
break ;
83
79
}
84
80
}
@@ -88,6 +84,27 @@ void GREENTEA_SETUP(const int timeout, const char *host_test_name) {
88
84
greentea_notify_hosttest (host_test_name);
89
85
}
90
86
87
+ /* * \brief Handshake with host and send setup data (timeout and host test name)
88
+ * \details This function will send preamble to master.
89
+ * After host test name is received master will invoke host test script
90
+ * and add hos test's callback handlers to main event loop
91
+ * This function is blocking.
92
+ */
93
+ void GREENTEA_SETUP (const int timeout, const char *host_test_name) {
94
+ char _value[48 ] = {0 };
95
+ _GREENTEA_SETUP_COMMON (timeout, host_test_name, _value, 48 );
96
+ }
97
+
98
+ /* * \brief Handshake with host and send setup data (timeout and host test name)
99
+ * \details This function will send preamble to master.
100
+ * After host test name is received master will invoke host test script
101
+ * and add hos test's callback handlers to main event loop
102
+ * This function is blocking.
103
+ */
104
+ void GREENTEA_SETUP_UUID (const int timeout, const char *host_test_name, char *buffer, size_t size) {
105
+ _GREENTEA_SETUP_COMMON (timeout, host_test_name, buffer, size);
106
+ }
107
+
91
108
/* * \brief Notify host (__exit message) side that test suite execution was complete
92
109
* \result Test suite result
93
110
* \details If __exit is not received by host side we will assume TIMEOUT
@@ -194,15 +211,15 @@ inline void greentea_write_preamble()
194
211
greentea_serial->putc (' {' );
195
212
greentea_serial->putc (' {' );
196
213
}
197
-
214
+
198
215
/* *
199
216
* \brief Write the postamble characters to the serial port
200
217
*
201
218
* This function writes the postamble "{{\n" which is required
202
219
* for key-value comunication between the target and the host.
203
220
* This uses a Rawserial object, greentea_serial, which provides
204
221
* a direct interface to the USBTX and USBRX serial pins and allows
205
- * the direct writing of characters using the putc() method.
222
+ * the direct writing of characters using the putc() method.
206
223
* This suite of functions are provided to allow for serial communication
207
224
* to the host from within a thread/ISR.
208
225
*
@@ -238,8 +255,8 @@ inline void greentea_write_string(const char *str)
238
255
* \brief Write an int to the serial port
239
256
*
240
257
* This function writes an integer value from the target
241
- * to the host. The integer value is converted to a string and
242
- * and then written character by character directly to the serial
258
+ * to the host. The integer value is converted to a string and
259
+ * and then written character by character directly to the serial
243
260
* port using the greentea_serial, Rawserial object.
244
261
* sprintf() is used to convert the int to a string. Sprintf if
245
262
* inherently thread safe so can be used.
@@ -302,7 +319,7 @@ void greentea_send_kv(const char *key, const int val) {
302
319
greentea_write_postamble ();
303
320
}
304
321
}
305
-
322
+
306
323
/* *
307
324
* \brief Encapsulate and send key-value-value message from DUT to host
308
325
*
@@ -367,10 +384,10 @@ void greentea_send_kv(const char *key, const char *val, const int passes, const
367
384
/* *
368
385
* \brief Encapsulate and send key-value-value message from DUT to host
369
386
*
370
- * This function uses underlying functions to write directly
371
- * to the serial port, (USBTX). This allows key-value-value to be used
387
+ * This function uses underlying functions to write directly
388
+ * to the serial port, (USBTX). This allows key-value-value to be used
372
389
* from within interrupt context.
373
- * Both values are integers to avoid integer to string conversion
390
+ * Both values are integers to avoid integer to string conversion
374
391
* made by the user.
375
392
*
376
393
* Names of the parameters: this function is used to send number
0 commit comments