@@ -61,7 +61,7 @@ FirmataParser::FirmataParser(uint8_t * const dataBuffer, size_t dataBufferSize)
61
61
currentStringCallback((stringCallbackFunction)NULL),
62
62
currentSysexCallback((sysexCallbackFunction)NULL),
63
63
currentReportFirmwareCallback((versionCallbackFunction)NULL),
64
- currentReportVersionCallback((systemCallbackFunction )NULL),
64
+ currentReportVersionCallback((versionCallbackFunction )NULL),
65
65
currentSystemResetCallback((systemCallbackFunction)NULL)
66
66
{
67
67
allowBufferUpdate = ((uint8_t *)NULL == dataBuffer);
@@ -130,6 +130,9 @@ void FirmataParser::parse(uint8_t inputData)
130
130
if (currentReportDigitalCallback)
131
131
(*currentReportDigitalCallback)(currentReportDigitalCallbackContext, multiByteChannel, dataBuffer[0 ]);
132
132
break ;
133
+ case REPORT_VERSION:
134
+ if (currentReportVersionCallback)
135
+ (*currentReportVersionCallback)(currentReportVersionCallbackContext, dataBuffer[0 ], dataBuffer[1 ], (const char *)NULL );
133
136
}
134
137
executeMultiByteCommand = 0 ;
135
138
}
@@ -163,8 +166,8 @@ void FirmataParser::parse(uint8_t inputData)
163
166
systemReset ();
164
167
break ;
165
168
case REPORT_VERSION:
166
- if (currentReportVersionCallback)
167
- (*currentReportVersionCallback)(currentReportVersionCallbackContext) ;
169
+ waitForData = 2 ; // two data bytes needed
170
+ executeMultiByteCommand = command ;
168
171
break ;
169
172
}
170
173
}
@@ -244,12 +247,13 @@ void FirmataParser::attach(uint8_t command, callbackFunction newFunction, void *
244
247
}
245
248
246
249
/* *
247
- * Attach a version callback function (supported option : REPORT_FIRMWARE).
250
+ * Attach a version callback function (supported options are : REPORT_FIRMWARE, REPORT_VERSION ).
248
251
* @param command The ID of the command to attach a callback function to.
249
252
* @param newFunction A reference to the callback function to attach.
250
253
* @param context An optional context to be provided to the callback function (NULL by default).
251
254
* @note The context parameter is provided so you can pass a parameter, by reference, to
252
255
* your callback function.
256
+ * @note The description value in the REPORT_VERSION callback will always be NULL
253
257
*/
254
258
void FirmataParser::attach (uint8_t command, versionCallbackFunction newFunction, void * context)
255
259
{
@@ -258,11 +262,15 @@ void FirmataParser::attach(uint8_t command, versionCallbackFunction newFunction,
258
262
currentReportFirmwareCallback = newFunction;
259
263
currentReportFirmwareCallbackContext = context;
260
264
break ;
265
+ case REPORT_VERSION:
266
+ currentReportVersionCallback = newFunction;
267
+ currentReportVersionCallbackContext = context;
268
+ break ;
261
269
}
262
270
}
263
271
264
272
/* *
265
- * Attach a system callback function (supported options are : SYSTEM_RESET, REPORT_VERSION ).
273
+ * Attach a system callback function (supported option : SYSTEM_RESET).
266
274
* @param command The ID of the command to attach a callback function to.
267
275
* @param newFunction A reference to the callback function to attach.
268
276
* @param context An optional context to be provided to the callback function (NULL by default).
@@ -272,10 +280,6 @@ void FirmataParser::attach(uint8_t command, versionCallbackFunction newFunction,
272
280
void FirmataParser::attach (uint8_t command, systemCallbackFunction newFunction, void * context)
273
281
{
274
282
switch (command) {
275
- case REPORT_VERSION:
276
- currentReportVersionCallback = newFunction;
277
- currentReportVersionCallbackContext = context;
278
- break ;
279
283
case SYSTEM_RESET:
280
284
currentSystemResetCallback = newFunction;
281
285
currentSystemResetCallbackContext = context;
@@ -341,6 +345,8 @@ void FirmataParser::detach(uint8_t command)
341
345
attach (command, (versionCallbackFunction)NULL , NULL );
342
346
break ;
343
347
case REPORT_VERSION:
348
+ attach (command, (versionCallbackFunction)NULL , NULL );
349
+ break ;
344
350
case SYSTEM_RESET:
345
351
attach (command, (systemCallbackFunction)NULL , NULL );
346
352
break ;
0 commit comments