Ahoy !
When you have maintain the same message structures with different languages, it sometimes is advantageous to GENERATE CODE ! rather than write it.
MrlComm has messages we want to be encoded and decoded in both Java & Arduino C++, and perhaps more languages or encodings.
So we make "One Document To Control It All" -> arduinoMsgs.schema
This file documents all messages to and from the Arduino in our binary protocol. This file controls the messaging and serialization between Arduino MrlComm library and MRL's Arduino Java Service. It does this by generating code which calls appropriate messages after serializing and deserializing data over the serial COM line. That way developers only need to worry about the business logic in MrlComm or their MrlDevice, and all the nitty gritty dirty and boring business of remote procedure calls and data-type conversion is left to the generated code.
Because Different Languages have different datatypes our schema document must be able to translate. Here is the table of conversions and the keywords for our document.
Schema | Arduino C++ | Java | Range |
(none) | byte/unsigned char | int (cuz Java bytes bite!) | 0 to 255 |
boolean | boolean | boolean | 0 to 1 |
b16 | int | int (short) | 2 bytes -32,768 to 32,767 |
b32 | long | int | 4 bytes -2,147,483,648 to 2,147,483,647 |
bu32 | unsigned long | long | 0 to 4,294,967,295 |
float | float 4 bytes | float | 3.4028235E+38 to -3.4028235E+38 |
str | char*, size | String | variable length |
[] | byte[], size | int[] | variable length |
# Arduino Diagnostics and Status< publishMRLCommError/str errorMsg> getBoardInfo< publishBoardInfo/version/boardType/b16 microsPerLoop/b16 sram/activePins/[] deviceSummary# removed - for simplicity, merged data into BoardInfo# < publishBoardStatus/b16 microsPerLoop/b16 sram/[] deviceSummary# > enableBoardInfo/bool enabled # simplified - just goes to Arduino-Javaland now> enablePin/address/type/b16 rate> setDebug/bool enabled> setSerialRate/b32 rate> softReset
# is a comment,
> is a message which goes from the Service to the Arduino board
< is a message which is sent from the Arduino board to the Service
# set ARef> setAref/b16 type
ArduinoMsgGenerator() { // add your keywords keywords.add("pinMode"); keywords.add("digitalWrite"); keywords.add("analogWrite"); keywords.add("analogReference");
Wahoo thank for your review
Wahoo thank for your review and those precious informations. I was thinking arduinoMsgs.schema was a documentation file. Now I understand. I think I I took the computer's job :)