diff --git a/sufst-controller/.idea/misc.xml b/sufst-controller/.idea/misc.xml deleted file mode 100644 index 28a804d8932aba40f168fd757a74cb718a955a1a..0000000000000000000000000000000000000000 --- a/sufst-controller/.idea/misc.xml +++ /dev/null @@ -1,6 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project version="4"> - <component name="JavaScriptSettings"> - <option name="languageLevel" value="ES6" /> - </component> -</project> \ No newline at end of file diff --git a/sufst-controller/.idea/modules.xml b/sufst-controller/.idea/modules.xml deleted file mode 100644 index 19b1b163c9fd6aa8fc57e045aecc49c26dac8fce..0000000000000000000000000000000000000000 --- a/sufst-controller/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project version="4"> - <component name="ProjectModuleManager"> - <modules> - <module fileurl="file://$PROJECT_DIR$/.idea/sufst-controller.iml" filepath="$PROJECT_DIR$/.idea/sufst-controller.iml" /> - </modules> - </component> -</project> \ No newline at end of file diff --git a/sufst-controller/.idea/sufst-controller.iml b/sufst-controller/.idea/sufst-controller.iml deleted file mode 100644 index bc2cd87409057301f546d83bd548111b9a241cb1..0000000000000000000000000000000000000000 --- a/sufst-controller/.idea/sufst-controller.iml +++ /dev/null @@ -1,8 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<module type="CPP_MODULE" version="4"> - <component name="NewModuleRootManager"> - <content url="file://$MODULE_DIR$" /> - <orderEntry type="inheritedJdk" /> - <orderEntry type="sourceFolder" forTests="false" /> - </component> -</module> \ No newline at end of file diff --git a/sufst-controller/.idea/vcs.xml b/sufst-controller/.idea/vcs.xml deleted file mode 100644 index 6c0b8635858dc7ad44b93df54b762707ce49eefc..0000000000000000000000000000000000000000 --- a/sufst-controller/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project version="4"> - <component name="VcsDirectoryMappings"> - <mapping directory="$PROJECT_DIR$/.." vcs="Git" /> - </component> -</project> \ No newline at end of file diff --git a/sufst-controller/.idea/workspace.xml b/sufst-controller/.idea/workspace.xml deleted file mode 100644 index 8cff62cde00745a317063f28798e85aee94a5600..0000000000000000000000000000000000000000 --- a/sufst-controller/.idea/workspace.xml +++ /dev/null @@ -1,407 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project version="4"> - <component name="CMakeRunConfigurationManager" shouldGenerate="true" shouldDeleteObsolete="true"> - <generated /> - </component> - <component name="CMakeSettings"> - <configurations> - <configuration PROFILE_NAME="Debug" CONFIG_NAME="Debug" /> - </configurations> - </component> - <component name="ChangeListManager"> - <list default="true" id="2070e8be-2952-4d02-bba6-112a351189c8" name="Default Changelist" comment=""> - <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> - <change beforePath="$PROJECT_DIR$/can.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/can.cpp" afterDir="false" /> - <change beforePath="$PROJECT_DIR$/can.h" beforeDir="false" afterPath="$PROJECT_DIR$/can.h" afterDir="false" /> - <change beforePath="$PROJECT_DIR$/daq.h" beforeDir="false" afterPath="$PROJECT_DIR$/daq.h" afterDir="false" /> - <change beforePath="$PROJECT_DIR$/ecuCan.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/ecuCan.cpp" afterDir="false" /> - <change beforePath="$PROJECT_DIR$/sd.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/sd.cpp" afterDir="false" /> - <change beforePath="$PROJECT_DIR$/sufst-controller.ino" beforeDir="false" afterPath="$PROJECT_DIR$/sufst-controller.ino" afterDir="false" /> - <change beforePath="$PROJECT_DIR$/../sufst-dash/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/../sufst-dash/.idea/workspace.xml" afterDir="false" /> - <change beforePath="$PROJECT_DIR$/../sufst-dash/sufst-dash.ino" beforeDir="false" afterPath="$PROJECT_DIR$/../sufst-dash/sufst-dash.ino" afterDir="false" /> - </list> - <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" /> - <option name="SHOW_DIALOG" value="false" /> - <option name="HIGHLIGHT_CONFLICTS" value="true" /> - <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" /> - <option name="LAST_RESOLUTION" value="IGNORE" /> - </component> - <component name="ClangdSettings"> - <option name="formatViaClangd" value="false" /> - </component> - <component name="FileEditorManager"> - <leaf SIDE_TABS_SIZE_LIMIT_KEY="300"> - <file pinned="false" current-in-tab="true"> - <entry file="file://$PROJECT_DIR$/ecuCan.cpp"> - <provider selected="true" editor-type-id="text-editor"> - <state relative-caret-position="221"> - <caret line="30" column="29" selection-start-line="30" selection-start-column="29" selection-end-line="30" selection-end-column="29" /> - <folding> - <element signature="e#39#58#0" expanded="true" /> - </folding> - </state> - </provider> - </entry> - </file> - <file pinned="false" current-in-tab="false"> - <entry file="file://$PROJECT_DIR$/dashController.cpp"> - <provider selected="true" editor-type-id="text-editor"> - <state relative-caret-position="80"> - <caret line="34" lean-forward="true" selection-start-line="34" selection-end-line="34" /> - <folding> - <element signature="e#40#67#0" expanded="true" /> - </folding> - </state> - </provider> - </entry> - </file> - <file pinned="false" current-in-tab="false"> - <entry file="file://$PROJECT_DIR$/evoScann-p.cpp"> - <provider selected="true" editor-type-id="text-editor"> - <state relative-caret-position="-597"> - <caret line="36" column="33" lean-forward="true" selection-start-line="36" selection-start-column="33" selection-end-line="36" selection-end-column="33" /> - <folding> - <element signature="e#40#63#0" expanded="true" /> - </folding> - </state> - </provider> - </entry> - </file> - <file pinned="false" current-in-tab="false"> - <entry file="file://$PROJECT_DIR$/evoScann-p.h"> - <provider selected="true" editor-type-id="text-editor" /> - </entry> - </file> - <file pinned="false" current-in-tab="false"> - <entry file="file://$PROJECT_DIR$/can.h"> - <provider selected="true" editor-type-id="text-editor"> - <state relative-caret-position="272"> - <caret line="16" column="32" lean-forward="true" selection-start-line="16" selection-start-column="32" selection-end-line="16" selection-end-column="32" /> - </state> - </provider> - </entry> - </file> - <file pinned="false" current-in-tab="false"> - <entry file="file://$PROJECT_DIR$/sd.cpp"> - <provider selected="true" editor-type-id="text-editor"> - <state relative-caret-position="1049"> - <caret line="72" lean-forward="true" selection-start-line="72" selection-end-line="72" /> - </state> - </provider> - </entry> - </file> - <file pinned="false" current-in-tab="false"> - <entry file="file://$PROJECT_DIR$/can.cpp"> - <provider selected="true" editor-type-id="text-editor"> - <state relative-caret-position="323"> - <caret line="193" column="1" lean-forward="true" selection-start-line="193" selection-start-column="1" selection-end-line="193" selection-end-column="1" /> - </state> - </provider> - </entry> - </file> - <file pinned="false" current-in-tab="false"> - <entry file="file://$PROJECT_DIR$/wireless.cpp"> - <provider selected="true" editor-type-id="text-editor"> - <state relative-caret-position="884"> - <caret line="52" column="1" lean-forward="true" selection-start-line="52" selection-start-column="1" selection-end-line="52" selection-end-column="1" /> - </state> - </provider> - </entry> - </file> - <file pinned="false" current-in-tab="false"> - <entry file="file://$PROJECT_DIR$/wireless.h"> - <provider selected="true" editor-type-id="text-editor"> - <state relative-caret-position="238"> - <caret line="14" lean-forward="true" selection-start-line="14" selection-end-line="14" /> - </state> - </provider> - </entry> - </file> - <file pinned="false" current-in-tab="false"> - <entry file="file://$PROJECT_DIR$/sufst-controller.ino"> - <provider selected="true" editor-type-id="text-editor"> - <state relative-caret-position="221"> - <caret line="25" column="22" lean-forward="true" selection-start-line="25" selection-start-column="22" selection-end-line="25" selection-end-column="22" /> - <folding> - <element signature="e#57#72#0" expanded="true" /> - </folding> - </state> - </provider> - </entry> - </file> - </leaf> - </component> - <component name="FindInProjectRecents"> - <findStrings> - <find>Serial.print</find> - <find>Se</find> - <find>EcuDataOpenlogger</find> - <find>EcuDataStruct</find> - <find>ecuOpenloggerSave</find> - </findStrings> - <replaceStrings> - <replace>EcuDataStruct</replace> - <replace>EcuDataSaveFormat</replace> - <replace>daqEcuWrite</replace> - </replaceStrings> - </component> - <component name="Git.Settings"> - <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$/.." /> - </component> - <component name="IdeDocumentHistory"> - <option name="CHANGED_PATHS"> - <list> - <option value="$PROJECT_DIR$/../sufst-dash/sufst-dash.ino" /> - <option value="$PROJECT_DIR$/sdTags.h" /> - <option value="$PROJECT_DIR$/sdParserTags.h" /> - <option value="$PROJECT_DIR$/dataTags.h" /> - <option value="$PROJECT_DIR$/dashController.cpp" /> - <option value="$PROJECT_DIR$/crc8.c" /> - <option value="$PROJECT_DIR$/checksum.h" /> - <option value="$PROJECT_DIR$/wireless.h" /> - <option value="$PROJECT_DIR$/wireless.cpp" /> - <option value="$PROJECT_DIR$/sd.h" /> - <option value="$PROJECT_DIR$/daq.cpp" /> - <option value="$PROJECT_DIR$/daq.h" /> - <option value="$PROJECT_DIR$/can.cpp" /> - <option value="$PROJECT_DIR$/sd.cpp" /> - <option value="$PROJECT_DIR$/can.h" /> - <option value="$PROJECT_DIR$/sufst-controller.ino" /> - <option value="$PROJECT_DIR$/ecuCan.cpp" /> - </list> - </option> - </component> - <component name="ProjectFrameBounds"> - <option name="x" value="588" /> - <option name="width" value="1339" /> - <option name="height" value="1038" /> - </component> - <component name="ProjectLevelVcsManager" settingsEditedManually="true" /> - <component name="ProjectView"> - <navigator proportions="" version="1"> - <foldersAlwaysOnTop value="true" /> - </navigator> - <panes> - <pane id="Scope" /> - <pane id="ProjectPane"> - <subPane> - <expand> - <path> - <item name="sufst-controller" type="b2602c69:ProjectViewProjectNode" /> - <item name="sufst-controller" type="462c0819:PsiDirectoryNode" /> - </path> - </expand> - <select /> - </subPane> - </pane> - </panes> - </component> - <component name="PropertiesComponent"> - <property name="ASKED_SHARE_PROJECT_CONFIGURATION_FILES" value="true" /> - <property name="SHARE_PROJECT_CONFIGURATION_FILES" value="true" /> - <property name="WebServerToolWindowFactoryState" value="false" /> - <property name="node.js.detected.package.eslint" value="true" /> - <property name="node.js.detected.package.tslint" value="true" /> - <property name="node.js.path.for.package.eslint" value="project" /> - <property name="node.js.path.for.package.tslint" value="project" /> - <property name="node.js.selected.package.eslint" value="(autodetect)" /> - <property name="node.js.selected.package.tslint" value="(autodetect)" /> - <property name="nodejs_interpreter_path.stuck_in_default_project" value="undefined stuck path" /> - <property name="nodejs_npm_path_reset_for_default_project" value="true" /> - <property name="settings.editor.selected.configurable" value="preferences.sourceCode.C/C++" /> - </component> - <component name="RunDashboard"> - <option name="ruleStates"> - <list> - <RuleState> - <option name="name" value="ConfigurationTypeDashboardGroupingRule" /> - </RuleState> - <RuleState> - <option name="name" value="StatusDashboardGroupingRule" /> - </RuleState> - </list> - </option> - </component> - <component name="SvnConfiguration"> - <configuration /> - </component> - <component name="TaskManager"> - <task active="true" id="Default" summary="Default task"> - <changelist id="2070e8be-2952-4d02-bba6-112a351189c8" name="Default Changelist" comment="" /> - <created>1563993769139</created> - <option name="number" value="Default" /> - <option name="presentableId" value="Default" /> - <updated>1563993769139</updated> - <workItem from="1563993770477" duration="2408000" /> - <workItem from="1564136548177" duration="6195000" /> - <workItem from="1564440384294" duration="8566000" /> - </task> - <servers /> - </component> - <component name="TimeTrackingManager"> - <option name="totallyTimeSpent" value="17169000" /> - </component> - <component name="ToolWindowManager"> - <frame x="471" y="0" width="1071" height="830" extended-state="0" /> - <editor active="true" /> - <layout> - <window_info active="true" content_ui="combo" id="Project" order="0" visible="true" weight="0.29871413" /> - <window_info id="Structure" order="1" side_tool="true" weight="0.25" /> - <window_info id="Favorites" order="2" side_tool="true" /> - <window_info anchor="bottom" id="Message" order="0" /> - <window_info anchor="bottom" id="Find" order="1" /> - <window_info anchor="bottom" id="Run" order="2" /> - <window_info anchor="bottom" id="Debug" order="3" weight="0.4" /> - <window_info anchor="bottom" id="Cvs" order="4" weight="0.25" /> - <window_info anchor="bottom" id="Inspection" order="5" weight="0.4" /> - <window_info anchor="bottom" id="TODO" order="6" /> - <window_info anchor="bottom" id="Database Changes" order="7" /> - <window_info anchor="bottom" id="Version Control" order="8" visible="true" weight="0.24212034" /> - <window_info anchor="bottom" id="Terminal" order="9" weight="0.3295129" /> - <window_info anchor="bottom" id="Event Log" order="10" side_tool="true" /> - <window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" /> - <window_info anchor="right" id="Ant Build" order="1" weight="0.25" /> - <window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" /> - <window_info anchor="right" id="Database" order="3" /> - </layout> - </component> - <component name="TypeScriptGeneratedFilesManager"> - <option name="version" value="1" /> - </component> - <component name="editorHistoryManager"> - <entry file="file://$PROJECT_DIR$/../sufst-dash/sufst-dash.ino"> - <provider selected="true" editor-type-id="text-editor"> - <state relative-caret-position="238"> - <caret line="20" column="35" selection-start-line="20" selection-start-column="35" selection-end-line="20" selection-end-column="35" /> - </state> - </provider> - </entry> - <entry file="file://$PROJECT_DIR$/openLoggerController.h" /> - <entry file="file://$PROJECT_DIR$/dashController.h"> - <provider selected="true" editor-type-id="text-editor" /> - </entry> - <entry file="file://$PROJECT_DIR$/checksum.h"> - <provider selected="true" editor-type-id="text-editor"> - <state relative-caret-position="51"> - <caret line="3" column="24" selection-start-line="3" selection-start-column="24" selection-end-line="3" selection-end-column="24" /> - <folding> - <element signature="e#1532#1544#0" expanded="true" /> - <element signature="e#1926#1927#0" expanded="true" /> - </folding> - </state> - </provider> - </entry> - <entry file="file://$PROJECT_DIR$/crc8.c"> - <provider selected="true" editor-type-id="text-editor"> - <state relative-caret-position="733"> - <caret line="91" selection-start-line="91" selection-end-line="91" /> - </state> - </provider> - </entry> - <entry file="file://$PROJECT_DIR$/ecuCan.h"> - <provider selected="true" editor-type-id="text-editor" /> - </entry> - <entry file="file://$PROJECT_DIR$/sd.h"> - <provider selected="true" editor-type-id="text-editor"> - <state relative-caret-position="357"> - <caret line="21" lean-forward="true" selection-start-line="21" selection-end-line="21" /> - </state> - </provider> - </entry> - <entry file="file://$PROJECT_DIR$/daq.h"> - <provider selected="true" editor-type-id="text-editor"> - <state relative-caret-position="102"> - <caret line="21" column="18" lean-forward="true" selection-start-line="21" selection-start-column="18" selection-end-line="21" selection-end-column="18" /> - </state> - </provider> - </entry> - <entry file="file://$PROJECT_DIR$/daq.cpp"> - <provider selected="true" editor-type-id="text-editor"> - <state relative-caret-position="360"> - <caret line="29" column="1" selection-start-line="29" selection-start-column="1" selection-end-line="29" selection-end-column="1" /> - <folding> - <element signature="e#40#56#0" expanded="true" /> - </folding> - </state> - </provider> - </entry> - <entry file="file://$PROJECT_DIR$/wireless.cpp"> - <provider selected="true" editor-type-id="text-editor"> - <state relative-caret-position="884"> - <caret line="52" column="1" lean-forward="true" selection-start-line="52" selection-start-column="1" selection-end-line="52" selection-end-column="1" /> - </state> - </provider> - </entry> - <entry file="file://$PROJECT_DIR$/wireless.h"> - <provider selected="true" editor-type-id="text-editor"> - <state relative-caret-position="238"> - <caret line="14" lean-forward="true" selection-start-line="14" selection-end-line="14" /> - </state> - </provider> - </entry> - <entry file="file://$PROJECT_DIR$/can.cpp"> - <provider selected="true" editor-type-id="text-editor"> - <state relative-caret-position="323"> - <caret line="193" column="1" lean-forward="true" selection-start-line="193" selection-start-column="1" selection-end-line="193" selection-end-column="1" /> - </state> - </provider> - </entry> - <entry file="file://$PROJECT_DIR$/evoScann-p.cpp"> - <provider selected="true" editor-type-id="text-editor"> - <state relative-caret-position="-597"> - <caret line="36" column="33" lean-forward="true" selection-start-line="36" selection-start-column="33" selection-end-line="36" selection-end-column="33" /> - <folding> - <element signature="e#40#63#0" expanded="true" /> - </folding> - </state> - </provider> - </entry> - <entry file="file://$PROJECT_DIR$/evoScann-p.h"> - <provider selected="true" editor-type-id="text-editor" /> - </entry> - <entry file="file://$PROJECT_DIR$/sd.cpp"> - <provider selected="true" editor-type-id="text-editor"> - <state relative-caret-position="1049"> - <caret line="72" lean-forward="true" selection-start-line="72" selection-end-line="72" /> - </state> - </provider> - </entry> - <entry file="file://$PROJECT_DIR$/dashController.cpp"> - <provider selected="true" editor-type-id="text-editor"> - <state relative-caret-position="80"> - <caret line="34" lean-forward="true" selection-start-line="34" selection-end-line="34" /> - <folding> - <element signature="e#40#67#0" expanded="true" /> - </folding> - </state> - </provider> - </entry> - <entry file="file://$PROJECT_DIR$/can.h"> - <provider selected="true" editor-type-id="text-editor"> - <state relative-caret-position="272"> - <caret line="16" column="32" lean-forward="true" selection-start-line="16" selection-start-column="32" selection-end-line="16" selection-end-column="32" /> - </state> - </provider> - </entry> - <entry file="file://$PROJECT_DIR$/sufst-controller.ino"> - <provider selected="true" editor-type-id="text-editor"> - <state relative-caret-position="221"> - <caret line="25" column="22" lean-forward="true" selection-start-line="25" selection-start-column="22" selection-end-line="25" selection-end-column="22" /> - <folding> - <element signature="e#57#72#0" expanded="true" /> - </folding> - </state> - </provider> - </entry> - <entry file="file://$PROJECT_DIR$/ecuCan.cpp"> - <provider selected="true" editor-type-id="text-editor"> - <state relative-caret-position="221"> - <caret line="30" column="29" selection-start-line="30" selection-start-column="29" selection-end-line="30" selection-end-column="29" /> - <folding> - <element signature="e#39#58#0" expanded="true" /> - </folding> - </state> - </provider> - </entry> - </component> -</project> \ No newline at end of file diff --git a/sufst-controller/can.cpp b/sufst-controller/can.cpp index e947d17ce791083f15dfcf4ba3395af419138876..c589acd217d359659fbca9226a07676028a40ceb 100644 --- a/sufst-controller/can.cpp +++ b/sufst-controller/can.cpp @@ -188,9 +188,9 @@ void canParseRxMsg(CanMsgTemplate *canMsg) // This removes the need for a long if statement giving significant performance boosts (*ecuCanFuncPtrs[canMsg->idByte[0]])(canMsg); } -// else if (canMsg->id == 0x487) { -// evoScannNonMux(canMsg); -// } + else if (canMsg->id == 0x487) { + evoScannNonMux(canMsg); + } } void canProcessRx() diff --git a/sufst-controller/can.h b/sufst-controller/can.h index 744123542ddbd638a7a89474e29b2bf690b96def..d107146dca6df470e63bae5210b1fc39d8058e21 100644 --- a/sufst-controller/can.h +++ b/sufst-controller/can.h @@ -9,7 +9,7 @@ // CAN_INT_PIN MUST BE 2 #define CAN_INT_PIN 2 -#define CAN_CS_PIN 10 +#define CAN_CS_PIN 9 #define CAN_RX_BUFFER_LEN 32 #define CAN_TX_BUFFER_LEN 32 diff --git a/sufst-controller/daq.cpp b/sufst-controller/daq.cpp index 1a86715c2c12acc7a9095439dfad9c8f9fceadb8..44ac176ffa6c145d039aace3e3905ac63a2f8f54 100644 --- a/sufst-controller/daq.cpp +++ b/sufst-controller/daq.cpp @@ -25,6 +25,4 @@ void daqEcuWrite(CanMsgTemplate *canMsg, uint8_t index) daqEcuFormat.endTag = ecuParamterTag; sdWrite(&daqEcuFormat, sizeof(DaqEcuFormat)); - - wirelessWrite(&daqEcuFormat, sizeof(DaqEcuFormat)); } \ No newline at end of file diff --git a/sufst-controller/dashController.cpp b/sufst-controller/dashController.cpp index 3bdd070832f9bcf4c4ac17b2856a2623430ec79a..9ba25c8653209df3299405ab9710c8347ccfaf6c 100644 --- a/sufst-controller/dashController.cpp +++ b/sufst-controller/dashController.cpp @@ -13,7 +13,7 @@ uint16_t gWaterTemp = 0; void dashBegin() { - Serial2.begin(57600); + DASH_SERIAL.begin(DASH_SERIAL_BAUD_RATE); } void dashEcuSetRpm(uint16_t rpm) @@ -45,6 +45,6 @@ void dashControllerProcess() serialPayload[5] = crc_8(&(serialPayload[1]), 4); - Serial2.write(serialPayload, 6); + DASH_SERIAL.write(serialPayload, 6); } } diff --git a/sufst-controller/dashController.h b/sufst-controller/dashController.h index 9cf21a55c94e9eba5e4e42db396023e20ef8f28b..eac89a5ce94c3bb244cc612c002dc07d4e9ffba8 100644 --- a/sufst-controller/dashController.h +++ b/sufst-controller/dashController.h @@ -8,6 +8,8 @@ #include "Arduino.h" #define DASH_REFRESH_MS 20 +#define DASH_SERIAL Serial2 +#define DASH_SERIAL_BAUD_RATE 57600 void dashBegin(); void dashEcuSetRpm(uint16_t rpm); diff --git a/sufst-controller/ecuCan.cpp b/sufst-controller/ecuCan.cpp index b59efee256005b7c5b95ca1b63aedbfb3ce20145..7ce5c44855ae0f75f433f2424f4707bece95f00a 100644 --- a/sufst-controller/ecuCan.cpp +++ b/sufst-controller/ecuCan.cpp @@ -26,9 +26,9 @@ void ecuCanMsg0x2000(CanMsgTemplate *canMsg) uint16_t waterTempC = canMsg->data16[2]; uint16_t airTempC = canMsg->data16[3]; -// daqEcuWrite(canMsg, 0); -// daqEcuWrite(canMsg, 1); -// daqEcuWrite(canMsg, 2); + daqEcuWrite(canMsg, 0); + daqEcuWrite(canMsg, 1); + daqEcuWrite(canMsg, 2); dashEcuSetRpm(rpm); dashEcuSetWaterTemp(waterTempC); @@ -54,7 +54,8 @@ void ecuCanMsg0x2001(CanMsgTemplate *canMsg) uint16_t speedKphx10 = canMsg->data16[2]; uint16_t oilPressKpa = canMsg->data16[3]; -// daqEcuWrite(canMsg, 1); + daqEcuWrite(canMsg, 1); + daqEcuWrite(canMsg, 2); } void ecuCanMsg0x2002(CanMsgTemplate *canMsg) @@ -77,7 +78,7 @@ void ecuCanMsg0x2002(CanMsgTemplate *canMsg) uint16_t batteryVx10 = canMsg->data16[2]; uint16_t fuelComsumLpHrx10 = canMsg->data16[3]; -// daqEcuWrite(canMsg, 2); + daqEcuWrite(canMsg, 2); // Serial.println((float)(batteryVx10 / 10.0)); } @@ -102,7 +103,8 @@ void ecuCanMsg0x2003(CanMsgTemplate *canMsg) uint16_t injectionTimeMsx100 = canMsg->data16[2]; uint16_t fuelComsumLp100kMx10 = canMsg->data16[3]; -// daqEcuWrite(canMsg, 1); + daqEcuWrite(canMsg, 1); + daqEcuWrite(canMsg, 2); } void ecuCanMsg0x2004(CanMsgTemplate *canMsg) @@ -125,7 +127,7 @@ void ecuCanMsg0x2004(CanMsgTemplate *canMsg) uint16_t ana3mV = canMsg->data16[2]; uint16_t camAdvanceDegx10 = canMsg->data16[3]; -// daqEcuWrite(canMsg, 3); + daqEcuWrite(canMsg, 3); } void ecuCanMsg0x2005(CanMsgTemplate *canMsg) @@ -148,7 +150,10 @@ void ecuCanMsg0x2005(CanMsgTemplate *canMsg) uint16_t crankErrorsNr = canMsg->data16[2]; uint16_t camErrorsNr = canMsg->data16[3]; -// daqEcuWrite(canMsg, 0); + daqEcuWrite(canMsg, 0); + daqEcuWrite(canMsg, 1); + daqEcuWrite(canMsg, 2); + daqEcuWrite(canMsg, 3); } void ecuCanMsg0x2006(CanMsgTemplate *canMsg) @@ -191,10 +196,10 @@ void ecuCanMsg0x2007(CanMsgTemplate *canMsg) uint16_t lambdaPidTargPercx10 = canMsg->data16[1]; uint16_t lambdaPidAdjPercx10 = canMsg->data16[2]; uint16_t ecuSwitchesBitField = canMsg->data16[3]; -// -// daqEcuWrite(canMsg, 0); -// daqEcuWrite(canMsg, 1); -// daqEcuWrite(canMsg, 2); + + daqEcuWrite(canMsg, 0); + daqEcuWrite(canMsg, 1); + daqEcuWrite(canMsg, 2); } void ecuCanMsg0x2008(CanMsgTemplate *canMsg) diff --git a/sufst-controller/ecuCan.h b/sufst-controller/ecuCan.h index 3e0f98577cbe551131f608da0cd846dffa8ffbb4..99d2fac185234c11352bbf175b5a0c383365a7fb 100644 --- a/sufst-controller/ecuCan.h +++ b/sufst-controller/ecuCan.h @@ -8,6 +8,9 @@ #include "Arduino.h" #include "can.h" +#define DEBUG_ECU_CAN 0 +#define DEBUG_ECU_CAN_MINIMAL 0 + /* * These are called from can.cpp when their corresponding can msg id is seen. * So functions name *must* ecuCanMsg0x200N. diff --git a/sufst-controller/sd.cpp b/sufst-controller/sd.cpp index fa5ed62e2902fdbd63134a1a4010677add78b31b..c4a12574d97224fe5fa49fee6a185a52075781d4 100644 --- a/sufst-controller/sd.cpp +++ b/sufst-controller/sd.cpp @@ -6,7 +6,8 @@ #include "buffer.h" #include "SdFat.h" -enum SdState { +enum SdState +{ stopped = 0, writing, }; @@ -23,35 +24,49 @@ CirBuffer sdCirBuffer; uint8_t sdBegin() { - if (!cirBufferBegin(&sdCirBuffer, sdBuffer, SD_BUFFER_LEN, sizeof(uint8_t))) { + const uint8_t SD_BASE_NAME_SIZE = sizeof(SD_BASE_FILE_NAME) - 1; + char fileName[13] = SD_BASE_FILE_NAME "00.bin"; + + if (!sd.begin(SD_CS_PIN, SD_SCK_MHZ(50))) { sdState = stopped; + Serial.println("SD: BEGIN ERR"); + return 0; } - if (!sd.begin(SD_CS_PIN, SD_SCK_MHZ(10))) { + while (sd.exists(fileName)) { + if (fileName[SD_BASE_NAME_SIZE + 1] != '9') { + fileName[SD_BASE_NAME_SIZE + 1]++; + } + else if (fileName[SD_BASE_NAME_SIZE] != '9') { + fileName[SD_BASE_NAME_SIZE + 1] = '0'; + fileName[SD_BASE_NAME_SIZE]++; + } + else { + sdState = stopped; + + Serial.println("SD: NAME ERR"); + } + } + + if (!file.open(fileName, O_WRITE | O_CREAT)) { sdState = stopped; + Serial.println("SD: FILE ERR"); + return 0; } - if (sd.exists(SD_FILE_NAME)) { - if (!file.open(SD_FILE_NAME, O_WRITE | O_APPEND)) { - - sdState = stopped; + if (!cirBufferBegin(&sdCirBuffer, sdBuffer, SD_BUFFER_LEN, sizeof(uint8_t))) { - return 0; - } - } - else { - if (!file.open(SD_FILE_NAME, O_WRITE | O_CREAT)) { + sdState = stopped; - sdState = stopped; + Serial.println("SD: BUFF ERR"); - return 0; - } + return 0; } sdState = writing; @@ -70,32 +85,29 @@ void sdProcess() { static uint8_t sdPayload[SD_WRITE_LEN]; static uint8_t sdWritesCntBeforeFlush = 0; + if (sdState == writing) { + if (cirBufferAvailable(&sdCirBuffer) >= SD_WRITE_LEN) { - if (sdState != writing) { - uint32_t currentMs = millis(); - static uint32_t lastTryMs = 0; + cirBufferReadBytes(&sdCirBuffer, sdPayload, SD_WRITE_LEN); - if ((currentMs - lastTryMs) >= SD_START_TRY_AGAIN_MS) { - sdBegin(); + if (!file.write(sdPayload, SD_WRITE_LEN)) { - lastTryMs = millis(); - } - } - else if (cirBufferAvailable(&sdCirBuffer) >= SD_WRITE_LEN) { + sdState = stopped; + } - cirBufferReadBytes(&sdCirBuffer, sdPayload, SD_WRITE_LEN); + sdWritesCntBeforeFlush++; - if (!file.write(sdPayload, SD_WRITE_LEN)) { + if (sdWritesCntBeforeFlush >= SD_WRITES_BEFORE_FLUSH) { + if (!file.sync() || file.getWriteError()) { + Serial.println("SD: WRITE ERR"); - sdState = stopped; - } - - sdWritesCntBeforeFlush++; + sdState = stopped; - if (sdWritesCntBeforeFlush >= SD_WRITES_BEFORE_FLUSH) { - file.flush(); + sdBegin(); + } - sdWritesCntBeforeFlush = 0; + sdWritesCntBeforeFlush = 0; + } } } -} \ No newline at end of file +} diff --git a/sufst-controller/sd.h b/sufst-controller/sd.h index 7fdfc9eaedef89afe4c81d3dbb95562143d1dc90..6ebeccbe734ddd480680cb9e84d879e8957f73ef 100644 --- a/sufst-controller/sd.h +++ b/sufst-controller/sd.h @@ -16,7 +16,7 @@ #define SD_FILE_NAME "DATA.BIN" #define SD_WRITES_BEFORE_FLUSH 2 -#define SD_START_TRY_AGAIN_MS 1000 +#define SD_BASE_FILE_NAME "DATA" uint8_t sdBegin(); diff --git a/sufst-controller/sufst-controller.ino b/sufst-controller/sufst-controller.ino index 34633d4f0cbe9d590a46da82a792a72aafb9829a..86917b7ccbad2c6c4fe5e37b26d996f4456de544 100644 --- a/sufst-controller/sufst-controller.ino +++ b/sufst-controller/sufst-controller.ino @@ -1,6 +1,3 @@ -#define DEBUG_ECU_CAN 0 -#define DEBUG_ECU_CAN_MINIMAL 0 - #include "sd.h" #include "ecuCan.h" #include "can.h" @@ -19,11 +16,9 @@ void setup() dashBegin(); - //sdBegin(); + sdBegin(); canBegin(); - - //wirelessBegin(); } void loop() @@ -33,10 +28,9 @@ void loop() /* * ALL PROCESSES *MUST* BE NON BLOCKING */ - + canProcessRx(); dashControllerProcess(); - //sdProcess(); - //wirelessProcess(); + sdProcess(); //canProcessTx(); } \ No newline at end of file