diff --git a/speeduino/cancomms.ino b/speeduino/cancomms.ino index b74b9d70..c029936e 100644 --- a/speeduino/cancomms.ino +++ b/speeduino/cancomms.ino @@ -58,7 +58,7 @@ void secondserial_Command(void) case 'A': // sends a fixed 75 bytes of data. Used by Real Dash (Among others) //sendcanValues(0, CAN_PACKET_SIZE, 0x31, 1); //send values to serial3 - sendValues(0, CAN_PACKET_SIZE, 0x31, CANSerial); //send values to serial3 + sendValues(0, CAN_PACKET_SIZE, 0x31, CANSerial, serialSecondaryStatusFlag); //send values to serial3 break; case 'b': // New EEPROM burn command to only burn a single page at a time @@ -137,7 +137,7 @@ void secondserial_Command(void) break; case 'n': // sends the bytes of realtime values from the NEW CAN list - sendValues(0, NEW_CAN_PACKET_SIZE, 0x32, CANSerial); //send values to serial3 + sendValues(0, NEW_CAN_PACKET_SIZE, 0x32, CANSerial, serialSecondaryStatusFlag); //send values to serial3 break; case 'p': diff --git a/speeduino/comms.cpp b/speeduino/comms.cpp index 9b99f316..14221e78 100644 --- a/speeduino/comms.cpp +++ b/speeduino/comms.cpp @@ -527,7 +527,7 @@ void serialTransmit(void) switch (serialStatusFlag) { case SERIAL_TRANSMIT_INPROGRESS_LEGACY: - sendValues(logItemsTransmitted, inProgressLength, SEND_OUTPUT_CHANNELS, Serial); + sendValues(logItemsTransmitted, inProgressLength, SEND_OUTPUT_CHANNELS, Serial, serialStatusFlag); break; case SERIAL_TRANSMIT_TOOTH_INPROGRESS: diff --git a/speeduino/comms_legacy.cpp b/speeduino/comms_legacy.cpp index fff73439..77315f94 100644 --- a/speeduino/comms_legacy.cpp +++ b/speeduino/comms_legacy.cpp @@ -67,7 +67,7 @@ void legacySerialCommand(void) break; case 'A': // send x bytes of realtime values - sendValues(0, LOG_ENTRY_SIZE, 0x31, Serial); //send values to serial0 + sendValues(0, LOG_ENTRY_SIZE, 0x31, Serial, serialStatusFlag); //send values to serial0 firstCommsRequest = false; break; @@ -294,7 +294,7 @@ void legacySerialCommand(void) if(cmd == 0x30) //Send output channels command 0x30 is 48dec { - sendValues(offset, length, cmd, Serial); + sendValues(offset, length, cmd, Serial, serialStatusFlag); } else { @@ -640,7 +640,7 @@ void legacySerialHandler(byte cmd, Stream &targetPort, SerialStatus &targetStatu if(cmd == 0x30) //Send output channels command 0x30 is 48dec { - sendValues(offset, length, cmd, targetPort); + sendValues(offset, length, cmd, targetPort, targetStatusFlag); } else { @@ -660,19 +660,19 @@ void legacySerialHandler(byte cmd, Stream &targetPort, SerialStatus &targetStatu * @param offset - Start field number * @param packetLength - Length of actual message (after possible ack/confirm headers) * @param cmd - ??? - Will be used as some kind of ack on CANSerial - * @param portNum - Port number (0=Serial, 3=CANSerial) + * @param targetPort - The HardwareSerial device that will be transmitted to + * @param targetStatusFlag - The status flag that will be set to indicate the status of the transmission * E.g. tuning sw command 'A' (Send all values) will send data from field number 0, LOG_ENTRY_SIZE fields. * @return the current values of a fixed group of variables */ -void sendValues(uint16_t offset, uint16_t packetLength, byte cmd, Stream &targetPort) +void sendValues(uint16_t offset, uint16_t packetLength, byte cmd, Stream &targetPort, SerialStatus &targetStatusFlag) { + #if defined(CANSerial_AVAILABLE) if (&targetPort == &CANSerial) { - serialSecondaryStatusFlag = SERIAL_TRANSMIT_INPROGRESS_LEGACY; //CAN serial if( (configPage9.secondarySerialProtocol == SECONDARY_SERIAL_PROTO_GENERIC) || (configPage9.secondarySerialProtocol == SECONDARY_SERIAL_PROTO_REALDASH)) { - #if defined(CANSerial_AVAILABLE) if (cmd == 0x30) { CANSerial.write("r"); //confirm cmd type @@ -688,12 +688,11 @@ void sendValues(uint16_t offset, uint16_t packetLength, byte cmd, Stream &target CANSerial.write(cmd); // send command type , 0x32 (dec50) is ascii '0' CANSerial.write(NEW_CAN_PACKET_SIZE); // send the packet size the receiving device should expect. } - #endif } } else + #endif { - serialStatusFlag = SERIAL_TRANSMIT_INPROGRESS_LEGACY; if(firstCommsRequest) { firstCommsRequest = false; @@ -702,6 +701,7 @@ void sendValues(uint16_t offset, uint16_t packetLength, byte cmd, Stream &target } // + targetStatusFlag = SERIAL_TRANSMIT_INPROGRESS_LEGACY; currentStatus.spark ^= (-currentStatus.hasSync ^ currentStatus.spark) & (1U << BIT_SPARK_SYNC); //Set the sync bit of the Spark variable to match the hasSync variable for(byte x=0; x