@@ -159,6 +159,28 @@ void FirmataMarshaller::end(void)
159
159
// * Output Stream Handling
160
160
// ******************************************************************************
161
161
162
+ /* *
163
+ * Query the target's firmware name and version
164
+ */
165
+ void FirmataMarshaller::queryFirmwareVersion (void )
166
+ const
167
+ {
168
+ if ( (Stream *)NULL == FirmataStream ) { return ; }
169
+ FirmataStream->write (START_SYSEX);
170
+ FirmataStream->write (REPORT_FIRMWARE);
171
+ FirmataStream->write (END_SYSEX);
172
+ }
173
+
174
+ /* *
175
+ * Query the target's Firmata protocol version
176
+ */
177
+ void FirmataMarshaller::queryVersion (void )
178
+ const
179
+ {
180
+ if ( (Stream *)NULL == FirmataStream ) { return ; }
181
+ FirmataStream->write (REPORT_VERSION);
182
+ }
183
+
162
184
/* *
163
185
* Halt the stream of analog readings from the Firmata host application. The range of pins is
164
186
* limited to [0..15] when using the REPORT_ANALOG. The maximum result of the REPORT_ANALOG is limited to 14 bits
@@ -224,7 +246,6 @@ void FirmataMarshaller::sendAnalog(uint8_t pin, uint16_t value)
224
246
const
225
247
{
226
248
if ( (Stream *)NULL == FirmataStream ) { return ; }
227
-
228
249
if ( (0xF >= pin) && (0x3FFF >= value) ) {
229
250
FirmataStream->write (ANALOG_MESSAGE|pin);
230
251
transformByteStreamToMessageBytes (sizeof (value), reinterpret_cast <uint8_t *>(&value), sizeof (value));
@@ -285,7 +306,43 @@ const
285
306
FirmataStream->write (DIGITAL_MESSAGE | (portNumber & 0xF ));
286
307
// Tx bits 0-6 (protocol v1 and higher)
287
308
// Tx bits 7-13 (bit 7 only for protocol v2 and higher)
288
- transformByteStreamToMessageBytes (sizeof (portData), reinterpret_cast <uint8_t *>(&portData), 2 );
309
+ transformByteStreamToMessageBytes (sizeof (portData), reinterpret_cast <uint8_t *>(&portData), sizeof (portData));
310
+ }
311
+
312
+ /* *
313
+ * Sends the firmware name and version to the Firmata host application.
314
+ * @param major The major verison number
315
+ * @param minor The minor version number
316
+ * @param bytec The length of the firmware name
317
+ * @param bytev The firmware name array
318
+ */
319
+ void FirmataMarshaller::sendFirmwareVersion (uint8_t major, uint8_t minor, size_t bytec, uint8_t *bytev)
320
+ const
321
+ {
322
+ if ( (Stream *)NULL == FirmataStream ) { return ; }
323
+ size_t i;
324
+ FirmataStream->write (START_SYSEX);
325
+ FirmataStream->write (REPORT_FIRMWARE);
326
+ FirmataStream->write (major);
327
+ FirmataStream->write (minor);
328
+ for (i = 0 ; i < bytec; ++i) {
329
+ transformByteStreamToMessageBytes (sizeof (bytev[i]), reinterpret_cast <uint8_t *>(&bytev[i]), sizeof (bytev[i]));
330
+ }
331
+ FirmataStream->write (END_SYSEX);
332
+ }
333
+
334
+ /* *
335
+ * Send the Firmata protocol version to the Firmata host application.
336
+ * @param major The major verison number
337
+ * @param minor The minor version number
338
+ */
339
+ void FirmataMarshaller::sendVersion (uint8_t major, uint8_t minor)
340
+ const
341
+ {
342
+ if ( (Stream *)NULL == FirmataStream ) { return ; }
343
+ FirmataStream->write (REPORT_VERSION);
344
+ FirmataStream->write (major);
345
+ FirmataStream->write (minor);
289
346
}
290
347
291
348
/* *
@@ -336,7 +393,7 @@ const
336
393
FirmataStream->write (START_SYSEX);
337
394
FirmataStream->write (command);
338
395
for (i = 0 ; i < bytec; ++i) {
339
- transformByteStreamToMessageBytes (sizeof (bytev[i]), reinterpret_cast <uint8_t *>(&bytev[i]), 2 );
396
+ transformByteStreamToMessageBytes (sizeof (bytev[i]), reinterpret_cast <uint8_t *>(&bytev[i]), sizeof (bytev[i]) );
340
397
}
341
398
FirmataStream->write (END_SYSEX);
342
399
}
@@ -361,3 +418,14 @@ const
361
418
{
362
419
sendSysex (SAMPLING_INTERVAL, sizeof (interval_ms), reinterpret_cast <uint8_t *>(&interval_ms));
363
420
}
421
+
422
+ /* *
423
+ * Perform a software reset on the target. For example, StandardFirmata.ino will initialize
424
+ * everything to a known state and reset the parsing buffer.
425
+ */
426
+ void FirmataMarshaller::systemReset (void )
427
+ const
428
+ {
429
+ if ( (Stream *)NULL == FirmataStream ) { return ; }
430
+ FirmataStream->write (SYSTEM_RESET);
431
+ }
0 commit comments