This commit is contained in:
Josh Stewart 2020-01-13 16:38:50 +10:00
commit 9e0053e958
2 changed files with 24 additions and 22 deletions

View File

@ -23,7 +23,7 @@ void canCommand()
switch (currentcanCommand)
{
case 'A': // sends the bytes of realtime values from the OLD CAN list
sendcanValues(0, CAN_PACKET_SIZE, 0x30, 1); //send values to serial3
sendcanValues(0, CAN_PACKET_SIZE, 0x31, 1); //send values to serial3
break;
case 'G': // this is the reply command sent by the Can interface
@ -87,7 +87,7 @@ void canCommand()
break;
case 'n': // sends the bytes of realtime values from the NEW CAN list
sendcanValues(0, NEW_CAN_PACKET_SIZE, 0x31, 1); //send values to serial3
sendcanValues(0, NEW_CAN_PACKET_SIZE, 0x32, 1); //send values to serial3
break;
case 'r': //New format for the optimised OutputChannels
@ -144,20 +144,21 @@ void sendcanValues(uint16_t offset, uint16_t packetLength, byte cmd, byte portTy
//CAN serial
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)|| defined(CORE_STM32) || defined (CORE_TEENSY) //ATmega2561 does not have Serial3
if (offset == 0)
{
if (cmd == 0x30) {CANSerial.write("A");} // confirm command type
else
{
CANSerial.write("n"); // confirm command type
CANSerial.write(NEW_CAN_PACKET_SIZE); // send the packet size the receiving device should expect.
}
}
else
{
CANSerial.write("r"); //confirm cmd type
CANSerial.write(cmd);
}
if (cmd == 0x30)
{
CANSerial.write("r"); //confirm cmd type
CANSerial.write(cmd);
}
else if (cmd == 0x31)
{
CANSerial.write("A"); // confirm command type
}
else if (cmd == 0x32)
{
CANSerial.write("n"); // confirm command type
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
currentStatus.spark ^= (-currentStatus.hasSync ^ currentStatus.spark) & (1U << BIT_SPARK_SYNC); //Set the sync bit of the Spark variable to match the hasSync variable

View File

@ -40,7 +40,7 @@ void command()
break;
case 'A': // send x bytes of realtime values
sendValues(0, LOG_ENTRY_SIZE, 0x30, 0); //send values to serial0
sendValues(0, LOG_ENTRY_SIZE, 0x31, 0); //send values to serial0
break;
@ -502,14 +502,15 @@ void sendValues(uint16_t offset, uint16_t packetLength, byte cmd, byte portNum)
{
//CAN serial
#if defined(USE_SERIAL3)
if (offset == 0)
{
CANSerial.write("A"); //confirm cmd type
}
else
if (cmd == 30)
{
CANSerial.write("r"); //confirm cmd type
CANSerial.write(cmd);
}
else if (cmd == 31)
{
CANSerial.write("A"); //confirm cmd type
}
#endif
}