diff --git a/reference/Speeduino base tune.msq b/reference/Speeduino base tune.msq index 39e40999..97f2da6a 100644 --- a/reference/Speeduino base tune.msq +++ b/reference/Speeduino base tune.msq @@ -1,7 +1,7 @@ - - + + "CAN ID 0" @@ -216,7 +216,7 @@ "No" 25.5 3200.0 --21.0 +-5.814 38.0 2.0 "Dwell control" @@ -247,17 +247,17 @@ 74.0 85.0 - - -40.0 - -26.0 - -8.0 - 9.0 - 26.0 - 38.0 - 49.0 - 60.0 - 69.0 - 80.0 + + -40.014 + -14.814 + 17.586 + 48.186 + 78.786 + 100.386 + 120.186 + 139.986 + 156.186 + 175.986 8.0 @@ -268,13 +268,13 @@ 91.0 85.0 - - 58.0 - 82.0 - 93.0 - 104.0 - 116.0 - 140.0 + + 136.386 + 179.586 + 199.386 + 219.186 + 240.786 + 283.986 0.0 @@ -356,7 +356,7 @@ 100.0 20.0 0.0 -70.0 +157.986 16.0 1.0 15.0 @@ -387,16 +387,16 @@ 100.0 98.0 - - -40.0 - -20.0 - 0.0 - 20.0 - 35.0 - 50.0 - 60.0 - 90.0 - 120.0 + + -40.014 + -4.014 + 31.986 + 67.986 + 94.986 + 121.986 + 139.986 + 193.986 + 247.986 126.0 @@ -474,17 +474,17 @@ 16.0 9.0 - - -38.0 - -19.0 - 1.0 - 17.0 - 34.0 - 50.0 - 63.0 - 79.0 - 98.0 - 143.0 + + -36.414 + -2.214 + 33.786 + 62.586 + 93.186 + 121.986 + 145.386 + 174.186 + 208.386 + 289.386 123.0 @@ -498,30 +498,30 @@ 44.0 60.0 - - -28.0 - 6.0 - 44.0 - 76.0 + + -18.414 + 42.786 + 111.186 + 168.786 "None" "3" "1" "Normal" -20.0 +67.986 240.0 4.0 "No" "Off" "Board Default" -75.0 -2.0 +166.986 +36.0 6.0 - - 60.0 - -20.0 - -40.0 - 158.0 + + 139.986 + -4.014 + -40.014 + 316.386 @@ -713,6 +713,14 @@ "8" "8" "8" +"1" +"1" +"1" +"1" +"1" +"1" +"1" +"1" 255.0 255.0 255.0 @@ -772,6 +780,7 @@ 255.0 255.0 255.0 +"CAN ID 0" 255.0 255.0 255.0 @@ -799,9 +808,9 @@ + - diff --git a/reference/speeduino.ini b/reference/speeduino.ini index b4d142c8..d7958f07 100644 --- a/reference/speeduino.ini +++ b/reference/speeduino.ini @@ -738,9 +738,9 @@ page = 10 defaultValue = boostMaxDuty,100 defaultValue = sparkDur, 1.0 defaultValue = speeduino_tsCanId, 0 - ;defaultValue = true_address, 0 - ;defaultValue = realtime_base_address, 0 - ;defaultValue = obd_address, 0 + ; defaultValue = true_address, 0 + ; defaultValue = realtime_base_address, 0 + ; defaultValue = obd_address, 0 ;Default pins defaultValue = fanPin, 0 @@ -949,9 +949,9 @@ menuDialog = main #else enable_canbus = "This Enables the IO on the secondary serial port. This is serial3 on mega2560 processor, and Serial2 on STM32 and Teensy processor " #endif - speeduino_tsCanId = "This is the TsCanId that the Speeduino ECU will respond to. This should match the main controller CAN ID in project properties if it is connected directy to TunerStudio, Otherwise the device ID if connected via CAN passthrough" - true_address = "This is the 11bit Can address of the Speeduino ECU " - obd_address = "The 11bit Can address that the Speeduino ECU responds to for OBD2 diagnostic requests" + ;speeduino_tsCanId = "This is the TsCanId that the Speeduino ECU will respond to. This should match the main controller CAN ID in project properties if it is connected directy to TunerStudio, Otherwise the device ID if connected via CAN passthrough" + ;true_address = "This is the 11bit Can address of the Speeduino ECU " + ;obd_address = "The 11bit Can address that the Speeduino ECU responds to for OBD2 diagnostic requests" caninput_sel1 = "This Enables CAN data input channel 1 " caninput_sel2 = "This Enables CAN data input channel 2 " caninput_sel3 = "This Enables CAN data input channel 3 " @@ -1588,9 +1588,9 @@ menuDialog = main dialog = can_serial3IO, "CanBus/Serial3 IO interface" topicHelp = "http://speeduino.com/wiki/index.php/Secondary_Serial_IO_interface" field = "Enable CanBus/Second Serial", enable_canbus - field = "Speeduino TsCanId", speeduino_tsCanId - field = "Realtime Data Base Can Address", realtime_base_address - field = "Speeduino OBD address", obd_address + ; field = "Speeduino TsCanId", speeduino_tsCanId + ; field = "Realtime Data Base Can Address", realtime_base_address + ; field = "Speeduino OBD address", obd_address dialog = serial3IO, "Serial3 IO interface" topicHelp = "http://speeduino.com/wiki/index.php/Serial3_IO_interface" diff --git a/speeduino/cancomms.ino b/speeduino/cancomms.ino index cac44fdc..77902ed4 100644 --- a/speeduino/cancomms.ino +++ b/speeduino/cancomms.ino @@ -18,7 +18,7 @@ void canCommand() switch (currentcanCommand) { case 'A': // sends the bytes of realtime values - sendValues(0, packetSize,3); //send values to serial3 + sendValues(0, packetSize,0x30,3); //send values to serial3 break; case 'G': // this is the reply command sent by the Can interface @@ -86,23 +86,22 @@ void canCommand() break; case 'r': //New format for the optimised OutputChannels - byte cmd; - + byte Cmd; if (CANSerial.available() >= 6) { CANSerial.read(); //Read the $tsCanId - cmd = CANSerial.read(); + Cmd = CANSerial.read(); uint16_t offset, length; - if(cmd == 0x30) //Send output channels command 0x30 is 48dec + if((Cmd == 0x30) || (Cmd >= 0x40 && Cmd <0x50) ) //Send output channels command 0x30 is 48dec, 0x40(64dec)-0x4F are external can request { byte tmp; tmp = CANSerial.read(); offset = word(CANSerial.read(), tmp); tmp = CANSerial.read(); length = word(CANSerial.read(), tmp); + sendValues(offset, length,Cmd, 3); - sendValues(offset, length, 3); } else { diff --git a/speeduino/comms.h b/speeduino/comms.h index 81e1016e..223333dc 100644 --- a/speeduino/comms.h +++ b/speeduino/comms.h @@ -40,7 +40,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 offset, uint16_t packetlength, byte portnum); +void sendValues(uint16_t offset, uint16_t packetlength,byte cmd, byte portnum); void receiveValue(int offset, byte newValue); void saveConfig(); void sendPage(bool useChar); diff --git a/speeduino/comms.ino b/speeduino/comms.ino index f81df42d..48ebd4c8 100644 --- a/speeduino/comms.ino +++ b/speeduino/comms.ino @@ -21,7 +21,7 @@ void command() { case 'A': // send x bytes of realtime values - sendValues(0, packetSize, 0); //send values to serial0 + sendValues(0, packetSize,0x30, 0); //send values to serial0 break; @@ -190,7 +190,7 @@ void command() offset = word(Serial.read(), tmp); tmp = Serial.read(); length = word(Serial.read(), tmp); - sendValues(offset, length, 0); + sendValues(offset, length,cmd, 0); } else { @@ -244,33 +244,23 @@ void command() This function returns the current values of a fixed group of variables */ //void sendValues(int packetlength, byte portNum) -void sendValues(uint16_t offset, uint16_t packetLength, byte portNum) +void sendValues(uint16_t offset, uint16_t packetLength, byte cmd, byte portNum) { byte fullStatus[packetSize]; if (portNum == 3) { //CAN serial - #if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) //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) { - Serial3.write("A"); //confirm cmd type + CANSerial.write("A"); //confirm cmd type } else { - Serial3.write("r"); //confirm cmd type + CANSerial.write("r"); //confirm cmd type + CANSerial.write(cmd); } - Serial3.write(packetLength); //confirm no of byte to be sent - #elif defined(CORE_STM32) || defined (CORE_TEENSY) - if (offset == 0) - { - Serial2.write("A"); //confirm cmd type - } - else - { - Serial2.write("r"); //confirm cmd type - } - Serial2.write(packetLength); //confirm no of byte to be sent #endif } else @@ -350,7 +340,14 @@ void sendValues(uint16_t offset, uint16_t packetLength, byte portNum) for(byte x=0; x SERIAL_BUFFER_THRESHOLD) ) + if ( ((mainLoopCount & 31) == 1) or (CANSerial.available() > SERIAL_BUFFER_THRESHOLD) ) { - if (Serial3.available() > 0) + if (CANSerial.available() > 0) { canCommand(); }