From 2d9069c3a34afe3e8ddf014aff2877750e2e6221 Mon Sep 17 00:00:00 2001 From: Bruno Bousquet Date: Mon, 18 Feb 2019 22:25:02 -0500 Subject: [PATCH] first draft of answer to serial request 'a' --- speeduino/comms.h | 1 + speeduino/comms.ino | 71 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+) diff --git a/speeduino/comms.h b/speeduino/comms.h index 5fbcbc29..f1606ac9 100644 --- a/speeduino/comms.h +++ b/speeduino/comms.h @@ -44,6 +44,7 @@ const char pageTitles[] PROGMEM //This is being stored in the avr flash instead void command();//This is the heart of the Command Line Interpeter. All that needed to be done was to make it human readable. void sendValues(uint16_t, uint16_t,byte, byte); +void sendValuesLegacy(); void receiveValue(int, byte); void saveConfig(); void sendPage(bool); diff --git a/speeduino/comms.ino b/speeduino/comms.ino index 3a16e80e..a56ea88c 100644 --- a/speeduino/comms.ino +++ b/speeduino/comms.ino @@ -26,6 +26,18 @@ void command() switch (currentCommand) { + case 'a': + cmdPending = true; + + if (Serial.available() >= 2) + { + Serial.read(); //Ignore the first value, it's always 0 + Serial.read(); //Ignore the second value, it's always 6 + sendValuesLegacy(); + cmdPending = false; + } + break; + case 'A': // send x bytes of realtime values sendValues(0, SERIAL_PACKET_SIZE, 0x30, 0); //send values to serial0 break; @@ -570,6 +582,65 @@ void sendValues(uint16_t offset, uint16_t packetLength, byte cmd, byte portNum) } +void sendValuesLegacy() +{ + uint16_t temp; + int bytestosend = 112; + + bytestosend -= Serial.write(currentStatus.secl>>8); + bytestosend -= Serial.write(currentStatus.secl); + bytestosend -= Serial.write(currentStatus.PW1>>8); + bytestosend -= Serial.write(currentStatus.PW1); + bytestosend -= Serial.write(currentStatus.PW2>>8); + bytestosend -= Serial.write(currentStatus.PW2); + bytestosend -= Serial.write(currentStatus.RPM>>8); + bytestosend -= Serial.write(currentStatus.RPM); + + temp = currentStatus.advance * 10; + bytestosend -= Serial.write(temp>>8); + bytestosend -= Serial.write(temp); + + bytestosend -= Serial.write(currentStatus.nSquirts); + bytestosend -= Serial.write(currentStatus.engine); + bytestosend -= Serial.write(currentStatus.afrTarget); + bytestosend -= Serial.write(currentStatus.afrTarget); // send twice so afrtgt1 == afrtgt2 + bytestosend -= Serial.write(255); // send dummy data as we don't have wbo2_en1 + bytestosend -= Serial.write(255); // send dummy data as we don't have wbo2_en2 + + temp = currentStatus.baro * 10; + bytestosend -= Serial.write(temp>>8); + bytestosend -= Serial.write(temp); + + temp = currentStatus.MAP * 10; + bytestosend -= Serial.write(temp>>8); + bytestosend -= Serial.write(temp); + + temp = currentStatus.IAT * 10; + bytestosend -= Serial.write(temp>>8); + bytestosend -= Serial.write(temp); + + temp = currentStatus.coolant * 10; + bytestosend -= Serial.write(temp>>8); + bytestosend -= Serial.write(temp); + + temp = currentStatus.TPS * 10; + bytestosend -= Serial.write(temp>>8); + bytestosend -= Serial.write(temp); + + bytestosend -= Serial.write(currentStatus.battery10>>8); + bytestosend -= Serial.write(currentStatus.battery10); + bytestosend -= Serial.write(currentStatus.O2>>8); + bytestosend -= Serial.write(currentStatus.O2); + bytestosend -= Serial.write(currentStatus.O2_2>>8); + bytestosend -= Serial.write(currentStatus.O2_2); + + for(int i = 0; i < bytestosend; i++) + { + // send dummy data to fill remote's buffer + Serial.write(i+1); + } +} + void receiveValue(int valueOffset, byte newValue) {