diff --git a/reference/speeduino.ini b/reference/speeduino.ini index 8f3063d5..530b96a1 100644 --- a/reference/speeduino.ini +++ b/reference/speeduino.ini @@ -524,47 +524,32 @@ page = 9 ;CANBUS control (Page 10) ;-------------------------------------------------- page = 10 - unused10_0 = scalar, U08, 0, "", 1, 0, 0, 255, 0 - unused10_1 = scalar, U08, 1, "", 1, 0, 0, 255, 0 - unused10_2 = scalar, U08, 2, "", 1, 0, 0, 255, 0 - unused10_3 = scalar, U08, 3, "", 1, 0, 0, 255, 0 - unused10_4 = scalar, U08, 4, "", 1, 0, 0, 255, 0 - unused10_5 = scalar, U08, 5, "", 1, 0, 0, 255, 0 - unused10_6 = scalar, U08, 6, "", 1, 0, 0, 255, 0 - unused10_7 = scalar, U08, 7, "", 1, 0, 0, 255, 0 - unused10_8 = scalar, U08, 8, "", 1, 0, 0, 255, 0 - unused10_9 = scalar, U08, 9, "", 1, 0, 0, 255, 0 - unused10_10 = scalar, U08, 10, "", 1, 0, 0, 255, 0 - unused10_11 = scalar, U08, 11, "", 1, 0, 0, 255, 0 - unused10_12 = scalar, U08, 12, "", 1, 0, 0, 255, 0 - unused10_13 = scalar, U08, 13, "", 1, 0, 0, 255, 0 - unused10_14 = scalar, U08, 14, "", 1, 0, 0, 255, 0 - unused10_15 = scalar, U08, 15, "", 1, 0, 0, 255, 0 - unused10_16 = scalar, U08, 16, "", 1, 0, 0, 255, 0 - unused10_17 = scalar, U08, 17, "", 1, 0, 0, 255, 0 - unused10_18 = scalar, U08, 18, "", 1, 0, 0, 255, 0 - unused10_19 = scalar, U08, 19, "", 1, 0, 0, 255, 0 - unused10_20 = scalar, U08, 20, "", 1, 0, 0, 255, 0 - unused10_21 = scalar, U08, 21, "", 1, 0, 0, 255, 0 - unused10_22 = scalar, U08, 22, "", 1, 0, 0, 255, 0 - unused10_23 = scalar, U08, 23, "", 1, 0, 0, 255, 0 - unused10_24 = scalar, U08, 24, "", 1, 0, 0, 255, 0 - unused10_25 = scalar, U08, 25, "", 1, 0, 0, 255, 0 - unused10_26 = scalar, U08, 26, "", 1, 0, 0, 255, 0 - unused10_27 = scalar, U08, 27, "", 1, 0, 0, 255, 0 - unused10_28 = scalar, U08, 28, "", 1, 0, 0, 255, 0 - unused10_29 = scalar, U08, 29, "", 1, 0, 0, 255, 0 - unused10_30 = scalar, U08, 30, "", 1, 0, 0, 255, 0 - unused10_31 = scalar, U08, 31, "", 1, 0, 0, 255, 0 - unused10_32 = scalar, U08, 32, "", 1, 0, 0, 255, 0 - unused10_33 = scalar, U08, 33, "", 1, 0, 0, 255, 0 - unused10_34 = scalar, U08, 34, "", 1, 0, 0, 255, 0 - unused10_35 = scalar, U08, 35, "", 1, 0, 0, 255, 0 - unused10_36 = scalar, U08, 36, "", 1, 0, 0, 255, 0 - unused10_37 = scalar, U08, 37, "", 1, 0, 0, 255, 0 - unused10_38 = scalar, U08, 38, "", 1, 0, 0, 255, 0 - unused10_39 = scalar, U08, 39, "", 1, 0, 0, 255, 0 - unused10_40 = scalar, U08, 40, "", 1, 0, 0, 255, 0 + enable_candata_in = bits, U08, 0, [0:0], "Off", "On" + caninput_sel1 = bits, U08, 1, [0:0], "Off", "On" + caninput_sel2 = bits, U08, 2, [0:0], "Off", "On" + caninput_sel3 = bits, U08, 3, [0:0], "Off", "On" + caninput_sel4 = bits, U08, 4, [0:0], "Off", "On" + caninput_sel5 = bits, U08, 5, [0:0], "Off", "On" + caninput_sel6 = bits, U08, 6, [0:0], "Off", "On" + caninput_sel7 = bits, U08, 7, [0:0], "Off", "On" + caninput_sel8 = bits, U08, 8, [0:0], "Off", "On" + caninput_param_group = array , U16, 9, [ 8], "", 1, 0, 0, 65535, 0 + caninput_param_start_byte1 = bits, U08, 25, [0:2], "1", "2", "3", "4", "5", "6", "7", "8" + caninput_param_start_byte2 = bits, U08, 26, [0:2], "1", "2", "3", "4", "5", "6", "7", "8" + caninput_param_start_byte3 = bits, U08, 27, [0:2], "1", "2", "3", "4", "5", "6", "7", "8" + caninput_param_start_byte4 = bits, U08, 28, [0:2], "1", "2", "3", "4", "5", "6", "7", "8" + caninput_param_start_byte5 = bits, U08, 29, [0:2], "1", "2", "3", "4", "5", "6", "7", "8" + caninput_param_start_byte6 = bits, U08, 30, [0:2], "1", "2", "3", "4", "5", "6", "7", "8" + caninput_param_start_byte7 = bits, U08, 31, [0:2], "1", "2", "3", "4", "5", "6", "7", "8" + caninput_param_start_byte8 = bits, U08, 32, [0:2], "1", "2", "3", "4", "5", "6", "7", "8" + caninput_param_num_bytes1 = bits, U08, 33, [0:1], "INVALID", "1", "2", "INVALID" + caninput_param_num_bytes2 = bits, U08, 34, [0:1], "INVALID", "1", "2", "INVALID" + caninput_param_num_bytes3 = bits, U08, 35, [0:1], "INVALID", "1", "2", "INVALID" + caninput_param_num_bytes4 = bits, U08, 36, [0:1], "INVALID", "1", "2", "INVALID" + caninput_param_num_bytes5 = bits, U08, 37, [0:1], "INVALID", "1", "2", "INVALID" + caninput_param_num_bytes6 = bits, U08, 38, [0:1], "INVALID", "1", "2", "INVALID" + caninput_param_num_bytes7 = bits, U08, 39, [0:1], "INVALID", "1", "2", "INVALID" + caninput_param_num_bytes8 = bits, U08, 40, [0:1], "INVALID", "1", "2", "INVALID" unused10_41 = scalar, U08, 41, "", 1, 0, 0, 255, 0 unused10_42 = scalar, U08, 42, "", 1, 0, 0, 255, 0 unused10_43 = scalar, U08, 43, "", 1, 0, 0, 255, 0 @@ -574,7 +559,7 @@ page = 10 unused10_47 = scalar, U08, 47, "", 1, 0, 0, 255, 0 unused10_48 = scalar, U08, 48, "", 1, 0, 0, 255, 0 unused10_49 = scalar, U08, 49, "", 1, 0, 0, 255, 0 - unused10_50 = scalar, U08, 50, "", 1, 0, 0, 255, 0 + enable_candata_out = bits, U08, 50, [0:0], "Off", "On" unused10_51 = scalar, U08, 51, "", 1, 0, 0, 255, 0 unused10_52 = scalar, U08, 52, "", 1, 0, 0, 255, 0 unused10_53 = scalar, U08, 53, "", 1, 0, 0, 255, 0 @@ -811,8 +796,13 @@ menuDialog = main subMenu = std_separator subMenu = tacho, "Tacho Output" subMenu = std_separator - subMenu = canIO, "Canbus Interface" - + subMenu = canIO, "Serial3 IO Interface" + #if CAN_COMMANDS + subMenu = std_separator + subMenu = Canin_config, "Canbus Input Configuration" + subMenu = std_separator + ;subMenu = Canout_config, "Canbus Output Configuration" + #endif menuDialog = main @@ -911,6 +901,40 @@ menuDialog = main flatSSoftWin= "The number of RPM below the flat shift point where the softlimit will be applied (aka Soft limit window). Recommended values are 200-1000" flatSRetard = "The absolute timing (BTDC) that will be used when within the soft limit window" + canEnable = "This Enables the IO on serial3 on mega2560 processor " + 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 " + caninput_sel4 = "This Enables CAN data input channel 4 " + caninput_sel5 = "This Enables CAN data input channel 5 " + caninput_sel6 = "This Enables CAN data input channel 6 " + caninput_sel7 = "This Enables CAN data input channel 7 " + caninput_sel8 = "This Enables CAN data input channel 8 " + ;caninput_param_group1 = "The ID number of the parameter group of the data for channel 1 " + ;caninput_param_group2 = "The ID number of the parameter group of the data for channel 2" + ;caninput_param_group3 = "The ID number of the parameter group of the data for channel 3" + ;caninput_param_group4 = "The ID number of the parameter group of the data for channel 4" + ;caninput_param_group5 = "The ID number of the parameter group of the data for channel 5" + ;caninput_param_group6 = "The ID number of the parameter group of the data for channel 6" + ;caninput_param_group7 = "The ID number of the parameter group of the data for channel 7" + ;caninput_param_group8 = "The ID number of the parameter group of the data for channel 8" + caninput_param_start_byte1 = "The Starting byte the specific data begins at for channel 1" + caninput_param_start_byte2 = "The Starting byte the specific data begins at for channel 2" + caninput_param_start_byte3 = "The Starting byte the specific data begins at for channel 3" + caninput_param_start_byte4 = "The Starting byte the specific data begins at for channel 4" + caninput_param_start_byte5 = "The Starting byte the specific data begins at for channel 5" + caninput_param_start_byte6 = "The Starting byte the specific data begins at for channel 6" + caninput_param_start_byte7 = "The Starting byte the specific data begins at for channel 7" + caninput_param_start_byte8 = "The Starting byte the specific data begins at for channel 8" + caninput_param_num_bytes1 = "The number of bytes the specific data is made from starting at selected start byte number" + caninput_param_num_bytes2 = "The number of bytes the specific data is made from starting at selected start byte number" + caninput_param_num_bytes3 = "The number of bytes the specific data is made from starting at selected start byte number" + caninput_param_num_bytes4 = "The number of bytes the specific data is made from starting at selected start byte number" + caninput_param_num_bytes5 = "The number of bytes the specific data is made from starting at selected start byte number" + caninput_param_num_bytes6 = "The number of bytes the specific data is made from starting at selected start byte number" + caninput_param_num_bytes7 = "The number of bytes the specific data is made from starting at selected start byte number" + caninput_param_num_bytes8 = "The number of bytes the specific data is made from starting at selected start byte number" + cmdEnableTestMode = "Click this to enable test mode. This will not be available if the engine is running" cmdStopTestMode = "Click this to disable test mode" cmdtestinj150dc = "this will cycle the output at 50% Duty cycle" @@ -1375,6 +1399,75 @@ menuDialog = main panel = outputtest_spark ;panel = outputtest_io2 panel = outputtest_warningmessage + + dialog = caninput_sel, "" + ;CAN inputs + field = "CAN Input Channel on/off" + field = "CAN Input 1", caninput_sel1, { enable_candata_in } + field = "CAN Input 2", caninput_sel2, { enable_candata_in } + field = "CAN Input 3", caninput_sel3, { enable_candata_in } + field = "CAN Input 4", caninput_sel4, { enable_candata_in } + field = "CAN Input 5", caninput_sel5, { enable_candata_in } + field = "CAN Input 6", caninput_sel6, { enable_candata_in } + field = "CAN Input 7", caninput_sel7, { enable_candata_in } + field = "CAN Input 8", caninput_sel8, { enable_candata_in } + + dialog = caninput_parameter_group, "", yAxis + field = "Input Parameter Group" + field = "", caninput_param_group[0], { caninput_sel1 && enable_candata_in } + field = "", caninput_param_group[1], { caninput_sel2 && enable_candata_in } + field = "", caninput_param_group[2], { caninput_sel3 && enable_candata_in } + field = "", caninput_param_group[3], { caninput_sel4 && enable_candata_in } + field = "", caninput_param_group[4], { caninput_sel5 && enable_candata_in } + field = "", caninput_param_group[5], { caninput_sel6 && enable_candata_in } + field = "", caninput_param_group[6], { caninput_sel7 && enable_candata_in } + field = "", caninput_param_group[7], { caninput_sel8 && enable_candata_in } + + dialog = caninput_parameter_start_byte, "", yAxis + field = "Input Parameter Start Byte" + field = "", caninput_param_start_byte1, { caninput_sel1 && enable_candata_in } + field = "", caninput_param_start_byte2, { caninput_sel2 && enable_candata_in } + field = "", caninput_param_start_byte3, { caninput_sel3 && enable_candata_in } + field = "", caninput_param_start_byte4, { caninput_sel4 && enable_candata_in } + field = "", caninput_param_start_byte5, { caninput_sel5 && enable_candata_in } + field = "", caninput_param_start_byte6, { caninput_sel6 && enable_candata_in } + field = "", caninput_param_start_byte7, { caninput_sel7 && enable_candata_in } + field = "", caninput_param_start_byte8, { caninput_sel8 && enable_candata_in } + + dialog = caninput_parameter_num_byte, "", yAxis + field = "Input Parameter Number of Bytes" + field = "", caninput_param_num_bytes1, { caninput_sel1 && enable_candata_in } + field = "", caninput_param_num_bytes2, { caninput_sel2 && enable_candata_in } + field = "", caninput_param_num_bytes3, { caninput_sel3 && enable_candata_in } + field = "", caninput_param_num_bytes4, { caninput_sel4 && enable_candata_in } + field = "", caninput_param_num_bytes5, { caninput_sel5 && enable_candata_in } + field = "", caninput_param_num_bytes6, { caninput_sel6 && enable_candata_in } + field = "", caninput_param_num_bytes7, { caninput_sel7 && enable_candata_in } + field = "", caninput_param_num_bytes8, { caninput_sel8 && enable_candata_in } + + dialog = caninconfig_blank1,"" + field = "" + + dialog = Canin_config1, "", xAxis + panel = caninput_sel + panel = caninconfig_blank1 + panel = caninput_parameter_group + panel = caninconfig_blank1 + panel = caninput_parameter_start_byte + panel = caninconfig_blank1 + panel = caninput_parameter_num_byte + + dialog = Canin_config2, "CAN Data Input" + field = "Enable CanBus data input", enable_candata_in + + dialog = Canin_config, "", border + topicHelp = "file://$getProjectsDirPath()/Docs/speeduino_canbus.txt" + panel = Canin_config2, North + panel = Canin_config1, South + + dialog = Canout_config, "Can Data Out" + field = "Enable CanBus data Output", enable_candata_out + ;------------------------------------------------------------------------------- ; General help text @@ -1719,6 +1812,18 @@ cmdtestspk450dc = "E\x03\x0C" advanceGauge = advance, "Spark Advance", "deg BTDC", 50, -10, 0, 0, 35, 45, 0, 0 flexGauge = flex, "Flex sensor", "%", 0, 100, -1, -1, 999, 999, 0, 0 + #if CAN_COMMANDS + gaugeCategory = "CanBus Inputs" + CanGauge1 = canin_gauge1, "Can In1" "", 0, 1024, -1, -1, 1025, 1025, 0, 0 + CanGauge2 = canin_gauge2, "Can In2" "", 0, 1024, -1, -1, 1025, 1025, 0, 0 + CanGauge3 = canin_gauge3, "Can In3" "", 0, 1024, -1, -1, 1025, 1025, 0, 0 + CanGauge4 = canin_gauge4, "Can In4" "", 0, 1024, -1, -1, 1025, 1025, 0, 0 + CanGauge5 = canin_gauge5, "Can In5" "", 0, 1024, -1, -1, 1025, 1025, 0, 0 + CanGauge6 = canin_gauge6, "Can In6" "", 0, 1024, -1, -1, 1025, 1025, 0, 0 + CanGauge7 = canin_gauge7, "Can In7" "", 0, 1024, -1, -1, 1025, 1025, 0, 0 + CanGauge8 = canin_gauge8, "Can In8" "", 0, 1024, -1, -1, 1025, 1025, 0, 0 +#endif + gaugeCategory = "Other" clockGauge = secl, "Clock", "Seconds", 0, 255, 10, 10, 245, 245, 0, 0 deadGauge = deadValue, "---", "", 0, 1, -1, -1, 2, 2, 0, 0 @@ -1846,7 +1951,7 @@ cmdtestspk450dc = "E\x03\x0C" deadValue = { 0 } ; Convenient unchanging value. ochGetCommand = "A" - ochBlockSize = 41 + ochBlockSize = 57 secl = scalar, U08, 0, "sec", 1.000, 0.000 @@ -1915,7 +2020,15 @@ cmdtestspk450dc = "E\x03\x0C" testoutputs = scalar, U08, 40, "bits", 1.000, 0.000 testenabled = bits, U08, 40, [0:0] testactive = bits, U08, 40, [1:1] - + canin_gauge1 = scalar, U16, 41, "", 1.000, 0.000 + canin_gauge2 = scalar, U16, 43, "", 1.000, 0.000 + canin_gauge3 = scalar, U16, 45, "", 1.000, 0.000 + canin_gauge4 = scalar, U16, 47, "", 1.000, 0.000 + canin_gauge5 = scalar, U16, 49, "", 1.000, 0.000 + canin_gauge6 = scalar, U16, 51, "", 1.000, 0.000 + canin_gauge7 = scalar, U16, 53, "", 1.000, 0.000 + canin_gauge8 = scalar, U16, 55, "", 1.000, 0.000 + ; Computed output channels. See "megatuneExamples.ini" for all the ; pre-defined variables, search for "???" and you'll see them. @@ -2029,6 +2142,14 @@ cmdtestspk450dc = "E\x03\x0C" entry = boostDuty, "Boost Duty", int, "%d", { boostEnabled } entry = boostCutOut , "Boost cut", int, "%d" entry = idleLoad, "IAC value", int, "%d" + entry = canin_gauge1, "CanIn CH1", int, "%d" + entry = canin_gauge2, "CanIn CH2", int, "%d" + entry = canin_gauge3, "CanIn CH3", int, "%d" + entry = canin_gauge4, "CanIn CH4", int, "%d" + entry = canin_gauge5, "CanIn CH5", int, "%d" + entry = canin_gauge6, "CanIn CH6", int, "%d" + entry = canin_gauge7, "CanIn CH7", int, "%d" + entry = canin_gauge8, "CanIn CH8", int, "%d" ; Indicators diff --git a/speeduino/cancomms.h b/speeduino/cancomms.h index bf87ed6c..c3ff62f3 100644 --- a/speeduino/cancomms.h +++ b/speeduino/cancomms.h @@ -9,10 +9,11 @@ uint8_t nCanretry = 0; //no of retrys uint8_t cancmdfail = 0; //command fail yes/no uint8_t canlisten = 0; uint8_t Lbuffer[8]; //8 byte buffer to store incomng can data - +uint8_t Gdata[9]; +uint8_t Glow, Ghigh; void canCommand();//This is the heart of the Command Line Interpeter. All that needed to be done was to make it human readable. -void sendCancommand(uint8_t cmdtype , uint16_t canadddress, uint8_t candata1, uint8_t candata2); +void sendCancommand(uint8_t cmdtype , uint16_t canadddress, uint8_t candata1, uint8_t candata2, uint16_t paramgroup); void testCanComm(); #endif // CANCOMMS_H diff --git a/speeduino/cancomms.ino b/speeduino/cancomms.ino index 594c0727..0395d030 100644 --- a/speeduino/cancomms.ino +++ b/speeduino/cancomms.ino @@ -29,12 +29,41 @@ void canCommand() //uint8_t Gdata; while (Serial3.available() == 0) { } cancmdfail = Serial3.read(); - if (cancmdfail == 0) + if (cancmdfail != 0) { - //command request failed and/or data/device was not available + for (byte Gx = 0; Gx < 8; Gx++) //read all 8 bytes of data + { + while (Serial3.available() == 0) { } + Gdata[Gx] = Serial3.read(); + } + + Glow = Gdata[(configPage10.caninput_param_start_byte[currentStatus.current_caninchannel])]; + if (configPage10.caninput_param_num_bytes[currentStatus.current_caninchannel] == 2) + { + if ((configPage10.caninput_param_start_byte[currentStatus.current_caninchannel]) != 7) //you cant have a 2 byte value starting at byte 7(8 on the list) + { + Ghigh = Gdata[((configPage10.caninput_param_start_byte[currentStatus.current_caninchannel])+1)]; + } + } + else + { + Ghigh = 0; + } + + currentStatus.canin[currentStatus.current_caninchannel] = word(Ghigh, Glow); } - while (Serial3.available() == 0) { } - //Gdata = Serial3.read(); + + else{} //continue as command request failed and/or data/device was not available + + if (currentStatus.current_caninchannel <= 6) // if channel is 0-7 + { + currentStatus.current_caninchannel++; //inc to next channel + } + else + { + currentStatus.current_caninchannel = 0; //reset to start + } + break; case 'L': @@ -76,7 +105,7 @@ void canCommand() } // this routine sends a request(either "0" for a "G" or "1" for a "L" to the Can interface -void sendCancommand(uint8_t cmdtype, uint16_t canaddress, uint8_t candata1, uint8_t candata2) +void sendCancommand(uint8_t cmdtype, uint16_t canaddress, uint8_t candata1, uint8_t candata2, uint16_t paramgroup) { switch (cmdtype) { @@ -91,12 +120,18 @@ void sendCancommand(uint8_t cmdtype, uint16_t canaddress, uint8_t candata1, uint Serial3.print("L"); Serial3.write(canaddress); //11 bit canaddress of device to listen for break; + + case 2: + Serial3.print("R"); + Serial3.write( lowByte(paramgroup) ); //send lsb first + Serial3.write( lowByte(paramgroup >> 8) ); + break; } } #else //Dummy functions for those that can't do Serial3 void canCommand() { return; } -void sendCancommand(uint8_t cmdtype, uint16_t canaddress, uint8_t candata1, uint8_t candata2) { return; } +void sendCancommand(uint8_t cmdtype, uint16_t canaddress, uint8_t candata1, uint8_t candata2, uint16_t paramgroup) { return; } #endif diff --git a/speeduino/globals.h b/speeduino/globals.h index 1a360069..d1153434 100644 --- a/speeduino/globals.h +++ b/speeduino/globals.h @@ -216,7 +216,9 @@ struct statuses { bool testActive; byte boostDuty; byte idleLoad; //Either the current steps or current duty cycle for the idle control. - + int canin[9]; //16bit raw value of selected canin data for channel 1-8 + uint8_t current_caninchannel = 0; //start off at channel 0 + //Helpful bitwise operations: //Useful reference: http://playground.arduino.cc/Code/BitMath // y = (x >> n) & 1; // n=0..15. stores nth bit of x in y. y becomes 0 or 1. @@ -475,47 +477,11 @@ struct config4 { //Page 10 of the config mostly deals with CANBUS control //See ini file for further info (Config Page 10 in the ini) struct config10 { - byte unused10_0; - byte unused10_1; - byte unused10_2; - byte unused10_3; - byte unused10_4; - byte unused10_5; - byte unused10_6; - byte unused10_7; - byte unused10_8; - byte unused10_9; - byte unused10_10; - byte unused10_11; - byte unused10_12; - byte unused10_13; - byte unused10_14; - byte unused10_15; - byte unused10_16; - byte unused10_17; - byte unused10_18; - byte unused10_19; - byte unused10_20; - byte unused10_21; - byte unused10_22; - byte unused10_23; - byte unused10_24; - byte unused10_25; - byte unused10_26; - byte unused10_27; - byte unused10_28; - byte unused10_29; - byte unused10_30; - byte unused10_31; - byte unused10_32; - byte unused10_33; - byte unused10_34; - byte unused10_35; - byte unused10_36; - byte unused10_37; - byte unused10_38; - byte unused10_39; - byte unused10_40; + byte enable_candata_in:1; + byte caninput_sel[8]; + uint16_t caninput_param_group[8]; + uint8_t caninput_param_start_byte[8]; + byte caninput_param_num_bytes[8]; byte unused10_41; byte unused10_42; byte unused10_43; @@ -525,7 +491,7 @@ struct config10 { byte unused10_47; byte unused10_48; byte unused10_49; - byte unused10_50; + byte enable_candata_out : 1; byte unused10_51; byte unused10_52; byte unused10_53; diff --git a/speeduino/speeduino.ino b/speeduino/speeduino.ino index 33a50801..a542be7c 100644 --- a/speeduino/speeduino.ino +++ b/speeduino/speeduino.ino @@ -928,7 +928,30 @@ void loop() readIAT(); readO2(); readBat(); - +#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) //ATmega2561 does not have Serial3 + //if Can interface is enabled then check for serial3 requests. + if (configPage1.canEnable) + { + if (configPage10.enable_candata_in) + { + if (configPage10.caninput_sel[currentStatus.current_caninchannel]) //if current input channel is enabled + { + sendCancommand(2,0,0,0,configPage10.caninput_param_group[currentStatus.current_caninchannel]); //send an R command for data from paramgroup[currentStatus.current_caninchannel] + } + else + { + if (currentStatus.current_caninchannel <= 6) + { + currentStatus.current_caninchannel++; //step to next input channel if under 9 + } + else + { + currentStatus.current_caninchannel = 0; //reset input channel back to 1 + } + } + } + } +#endif vvtControl(); idleControl(); //Perform any idle related actions. Even at higher frequencies, running 4x per second is sufficient. }