fix for serial0 and serial3 errors (#301)

* fix to serial0 and serial3 when offset is 0 uses wrong command

* fix to serial0 and serial3 when offset is 0 uses wrong command

* fix hex num
This commit is contained in:
Autohome2 2020-01-13 02:16:12 +00:00 committed by Josh Stewart
parent 106b75509d
commit 57bfc36348
2 changed files with 24 additions and 22 deletions

View File

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

@ -39,7 +39,7 @@ void command()
break; break;
case 'A': // send x bytes of realtime values 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; break;
@ -501,14 +501,15 @@ void sendValues(uint16_t offset, uint16_t packetLength, byte cmd, byte portNum)
{ {
//CAN serial //CAN serial
#if defined(USE_SERIAL3) #if defined(USE_SERIAL3)
if (offset == 0) if (cmd == 30)
{
CANSerial.write("A"); //confirm cmd type
}
else
{ {
CANSerial.write("r"); //confirm cmd type CANSerial.write("r"); //confirm cmd type
CANSerial.write(cmd); CANSerial.write(cmd);
}
else if (cmd == 31)
{
CANSerial.write("A"); //confirm cmd type
} }
#endif #endif
} }