changes to serial3 protocol and further tidyng with new canserial use
This commit is contained in:
parent
5428715eb4
commit
b62f943bb3
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<msq xmlns="http://www.msefi.com/:msq">
|
||||
<bibliography author="TunerStudio MS(Beta) 3.0.22 - EFI Analytics, Inc." tuneComment="" writeDate="Mon Jun 05 14:40:33 AEST 2017"/>
|
||||
<versionInfo fileFormat="5.0" firmwareInfo="Speeduino+2017.05" nPages="10" signature="speeduino 201705"/>
|
||||
<bibliography author="TunerStudio MS(Beta) 3.0.23 - EFI Analytics, Inc." tuneComment="" writeDate="Sat Jun 10 23:42:28 BST 2017"/>
|
||||
<versionInfo fileFormat="5.0" firmwareInfo="Speeduino+2017.06-dev" nPages="10" signature="speeduino 201706-dev"/>
|
||||
<page>
|
||||
<pcVariable name="tsCanId">"CAN ID 0"</pcVariable>
|
||||
</page>
|
||||
|
@ -216,7 +216,7 @@
|
|||
<constant name="useResync">"No"</constant>
|
||||
<constant digits="1" name="sparkDur" units="ms">25.5</constant>
|
||||
<constant digits="0" name="IdleAdvRPM" units="RPM">3200.0</constant>
|
||||
<constant digits="1" name="IdleAdvCLT" units="C">-21.0</constant>
|
||||
<constant digits="0" name="IdleAdvCLT" units="F">-5.814</constant>
|
||||
<constant digits="0" name="IdleDelayTime" units="sec">38.0</constant>
|
||||
<constant digits="0" name="StgCycles" units="cycles">2.0</constant>
|
||||
<constant name="dwellcont">"Dwell control"</constant>
|
||||
|
@ -247,17 +247,17 @@
|
|||
74.0
|
||||
85.0
|
||||
</constant>
|
||||
<constant cols="1" digits="0" name="wueBins" rows="10" units="C">
|
||||
-40.0
|
||||
-26.0
|
||||
-8.0
|
||||
9.0
|
||||
26.0
|
||||
38.0
|
||||
49.0
|
||||
60.0
|
||||
69.0
|
||||
80.0
|
||||
<constant cols="1" digits="0" name="wueBins" rows="10" units="F">
|
||||
-40.014
|
||||
-14.814
|
||||
17.586
|
||||
48.186
|
||||
78.786
|
||||
100.386
|
||||
120.186
|
||||
139.986
|
||||
156.186
|
||||
175.986
|
||||
</constant>
|
||||
<constant digits="0" name="dwellLim" units="ms">8.0</constant>
|
||||
<constant cols="1" digits="0" name="dwellRates" rows="6" units="%">
|
||||
|
@ -268,13 +268,13 @@
|
|||
91.0
|
||||
85.0
|
||||
</constant>
|
||||
<constant cols="1" digits="0" name="iatRetBins" rows="6" units="C">
|
||||
58.0
|
||||
82.0
|
||||
93.0
|
||||
104.0
|
||||
116.0
|
||||
140.0
|
||||
<constant cols="1" digits="0" name="iatRetBins" rows="6" units="F">
|
||||
136.386
|
||||
179.586
|
||||
199.386
|
||||
219.186
|
||||
240.786
|
||||
283.986
|
||||
</constant>
|
||||
<constant cols="1" digits="0" name="iatRetRates" rows="6" units="deg">
|
||||
0.0
|
||||
|
@ -356,7 +356,7 @@
|
|||
<constant digits="0" name="egoKP" units="%">100.0</constant>
|
||||
<constant digits="0" name="egoKI" units="%">20.0</constant>
|
||||
<constant digits="0" name="egoKD" units="%">0.0</constant>
|
||||
<constant digits="0" name="egoTemp" units="C">70.0</constant>
|
||||
<constant digits="0" name="egoTemp" units="F">157.986</constant>
|
||||
<constant digits="0" name="egoCount">16.0</constant>
|
||||
<constant digits="0" name="egoDelta" units="%">1.0</constant>
|
||||
<constant digits="0" name="egoLimit">15.0</constant>
|
||||
|
@ -387,16 +387,16 @@
|
|||
100.0
|
||||
98.0
|
||||
</constant>
|
||||
<constant cols="1" digits="0" name="airDenBins" rows="9" units="C">
|
||||
-40.0
|
||||
-20.0
|
||||
0.0
|
||||
20.0
|
||||
35.0
|
||||
50.0
|
||||
60.0
|
||||
90.0
|
||||
120.0
|
||||
<constant cols="1" digits="0" name="airDenBins" rows="9" units="F">
|
||||
-40.014
|
||||
-4.014
|
||||
31.986
|
||||
67.986
|
||||
94.986
|
||||
121.986
|
||||
139.986
|
||||
193.986
|
||||
247.986
|
||||
</constant>
|
||||
<constant cols="1" digits="0" name="airDenRates" rows="9" units="%">
|
||||
126.0
|
||||
|
@ -474,17 +474,17 @@
|
|||
16.0
|
||||
9.0
|
||||
</constant>
|
||||
<constant cols="1" digits="0" name="iacBins" rows="10" units="C">
|
||||
-38.0
|
||||
-19.0
|
||||
1.0
|
||||
17.0
|
||||
34.0
|
||||
50.0
|
||||
63.0
|
||||
79.0
|
||||
98.0
|
||||
143.0
|
||||
<constant cols="1" digits="0" name="iacBins" rows="10" units="F">
|
||||
-36.414
|
||||
-2.214
|
||||
33.786
|
||||
62.586
|
||||
93.186
|
||||
121.986
|
||||
145.386
|
||||
174.186
|
||||
208.386
|
||||
289.386
|
||||
</constant>
|
||||
<constant cols="1" digits="0" name="iacCrankSteps" rows="4" units="Steps">
|
||||
123.0
|
||||
|
@ -498,30 +498,30 @@
|
|||
44.0
|
||||
60.0
|
||||
</constant>
|
||||
<constant cols="1" digits="0" name="iacCrankBins" rows="4" units="C">
|
||||
-28.0
|
||||
6.0
|
||||
44.0
|
||||
76.0
|
||||
<constant cols="1" digits="0" name="iacCrankBins" rows="4" units="F">
|
||||
-18.414
|
||||
42.786
|
||||
111.186
|
||||
168.786
|
||||
</constant>
|
||||
<constant name="iacAlgorithm">"None"</constant>
|
||||
<constant name="iacStepTime">"3"</constant>
|
||||
<constant name="iacChannels">"1"</constant>
|
||||
<constant name="iacPWMdir">"Normal"</constant>
|
||||
<constant digits="0" name="iacFastTemp" units="C">20.0</constant>
|
||||
<constant digits="0" name="iacFastTemp" units="F">67.986</constant>
|
||||
<constant digits="0" name="iacStepHome" units="Steps">240.0</constant>
|
||||
<constant digits="0" name="iacStepHyster" units="Steps">4.0</constant>
|
||||
<constant name="fanInv">"No"</constant>
|
||||
<constant name="fanEnable">"Off"</constant>
|
||||
<constant name="fanPin">"Board Default"</constant>
|
||||
<constant digits="0" name="fanSP" units="C">75.0</constant>
|
||||
<constant digits="0" name="fanHyster" units="C">2.0</constant>
|
||||
<constant digits="0" name="fanSP" units="F">166.986</constant>
|
||||
<constant digits="0" name="fanHyster" units="F">36.0</constant>
|
||||
<constant digits="0" name="fanFreq" units="Hz">6.0</constant>
|
||||
<constant cols="1" digits="0" name="fanPWMBins" rows="4" units="C">
|
||||
60.0
|
||||
-20.0
|
||||
-40.0
|
||||
158.0
|
||||
<constant cols="1" digits="0" name="fanPWMBins" rows="4" units="F">
|
||||
139.986
|
||||
-4.014
|
||||
-40.014
|
||||
316.386
|
||||
</constant>
|
||||
</page>
|
||||
<page number="7" size="160">
|
||||
|
@ -713,6 +713,14 @@
|
|||
<constant name="caninput_param_start_byte6">"8"</constant>
|
||||
<constant name="caninput_param_start_byte7">"8"</constant>
|
||||
<constant name="caninput_param_start_byte8">"8"</constant>
|
||||
<constant name="caninput_param_num_bytes1">"1"</constant>
|
||||
<constant name="caninput_param_num_bytes2">"1"</constant>
|
||||
<constant name="caninput_param_num_bytes3">"1"</constant>
|
||||
<constant name="caninput_param_num_bytes4">"1"</constant>
|
||||
<constant name="caninput_param_num_bytes5">"1"</constant>
|
||||
<constant name="caninput_param_num_bytes6">"1"</constant>
|
||||
<constant name="caninput_param_num_bytes7">"1"</constant>
|
||||
<constant name="caninput_param_num_bytes8">"1"</constant>
|
||||
<constant digits="0" name="unused10_41">255.0</constant>
|
||||
<constant digits="0" name="unused10_42">255.0</constant>
|
||||
<constant digits="0" name="unused10_43">255.0</constant>
|
||||
|
@ -772,6 +780,7 @@
|
|||
<constant digits="0" name="unused10_97">255.0</constant>
|
||||
<constant digits="0" name="unused10_98">255.0</constant>
|
||||
<constant digits="0" name="unused10_99">255.0</constant>
|
||||
<constant name="speeduino_tsCanId">"CAN ID 0"</constant>
|
||||
<constant digits="0" name="unused10_101">255.0</constant>
|
||||
<constant digits="0" name="unused10_103">255.0</constant>
|
||||
<constant digits="0" name="unused10_105">255.0</constant>
|
||||
|
@ -799,9 +808,9 @@
|
|||
</page>
|
||||
<settings Comment="These setting are only used if this msq is opened without a project.">
|
||||
<setting name="enablehardware_test_OFF" value="enablehardware_test_OFF"/>
|
||||
<setting name="FAHRENHEIT" value="FAHRENHEIT"/>
|
||||
<setting name="SPEED_DENSITY" value="SPEED_DENSITY"/>
|
||||
<setting name="CAN_COMMANDS_OFF" value="CAN_COMMANDS_OFF"/>
|
||||
<setting name="CELSIUS" value="CELSIUS"/>
|
||||
<setting name="AFR" value="AFR"/>
|
||||
</settings>
|
||||
<userComments Comment="These are user comments that can be related to a particular setting or dialog."/>
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
@ -289,8 +279,8 @@ void sendValues(uint16_t offset, uint16_t packetLength, byte portNum)
|
|||
fullStatus[5] = (byte)(currentStatus.IAT + CALIBRATION_TEMPERATURE_OFFSET); //mat
|
||||
fullStatus[6] = (byte)(currentStatus.coolant + CALIBRATION_TEMPERATURE_OFFSET); //Coolant ADC
|
||||
fullStatus[7] = currentStatus.tpsADC; //TPS (Raw 0-255)
|
||||
fullStatus[8] = currentStatus.battery10; //battery voltage
|
||||
fullStatus[9] = currentStatus.O2; //O2
|
||||
fullStatus[8] = 121;//currentStatus.battery10; //battery voltage
|
||||
fullStatus[9] = 54;//currentStatus.O2; //O2
|
||||
fullStatus[10] = currentStatus.egoCorrection; //Exhaust gas correction (%)
|
||||
fullStatus[11] = currentStatus.iatCorrection; //Air temperature Correction (%)
|
||||
fullStatus[12] = currentStatus.wueCorrection; //Warmup enrichment (%)
|
||||
|
@ -350,7 +340,14 @@ void sendValues(uint16_t offset, uint16_t packetLength, byte portNum)
|
|||
for(byte x=0; x<packetLength; x++)
|
||||
{
|
||||
if (portNum == 0) { Serial.write(fullStatus[offset+x]); }
|
||||
else if (portNum == 3) { CANSerial.write(fullStatus[offset+x]); }
|
||||
else if (portNum == 3){ CANSerial.write(fullStatus[offset+x]); }
|
||||
|
||||
if (portNum == 3) //TESTING USE!
|
||||
{
|
||||
Serial.print("r"); //confirm cmd type
|
||||
Serial.print(cmd);
|
||||
Serial.print(fullStatus[offset+x]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -852,9 +852,9 @@ void loop()
|
|||
//if serial3 interface is enabled then check for serial3 requests.
|
||||
if (configPage10.enable_canbus == 1)
|
||||
{
|
||||
if ( ((mainLoopCount & 31) == 1) or (Serial3.available() > SERIAL_BUFFER_THRESHOLD) )
|
||||
if ( ((mainLoopCount & 31) == 1) or (CANSerial.available() > SERIAL_BUFFER_THRESHOLD) )
|
||||
{
|
||||
if (Serial3.available() > 0)
|
||||
if (CANSerial.available() > 0)
|
||||
{
|
||||
canCommand();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue