Skip to content

Commit

Permalink
Update project and readme
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielMartensson committed Jul 16, 2023
1 parent d134576 commit 5c9dea9
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 12 deletions.
11 changes: 4 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ That's the debugging mode for internal CAN feedback.
- Step 1: Download this repository
- Step 2: Go to `Hardware -> Hardware.h` and select your processor, if it's not available, please write code for it and send me a pull request
- Step 3: Copy over the `Src` folder to your project folder inside your IDE. Rename `Src` to for example `Open SAE J1939`. That's a good name.
- Step 4: Use the `Examples -> Open SAE J1939 -> Startup.txt` example as your initial starting code for a SAE J1939 project.
- Step 4: Use the `Examples -> Open SAE J1939 -> Main.txt` example as your initial starting code for a SAE J1939 project.

```c
/*
Expand All @@ -54,7 +54,7 @@ That's the debugging mode for internal CAN feedback.
void Callback_Function_Send(uint32_t ID, uint8_t DLC, uint8_t data[]) {
/* Apply your transmit layer here, e.g:
* uint32_t TxMailbox;
* static CAN_HandleTypeDef can_handler;
* static CAN_HandleTypeDef can_handler;
* This function transmit ID, DLC and data[] as the CAN-message.
* HardWareLayerCAN_TX(&can_handler, ID, DLC, data, &TxMailbox);
*
Expand Down Expand Up @@ -124,11 +124,8 @@ int main() {

}

/* Save the Information_this_ECU struct */
uint32_t ECU_information_length = sizeof(Information_this_ECU);
uint8_t dataJ1939[sizeof(Information_this_ECU)];
memcpy(dataJ1939, &j1939.information_this_ECU, ECU_information_length);
Save_Struct(dataJ1939, ECU_information_length, (char*)INFORMATION_THIS_ECU);
/* Save your ECU information */
Open_SAE_J1939_Closedown_ECU(&j1939);

return 0;
}
Expand Down
13 changes: 9 additions & 4 deletions Src/Main.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
void Callback_Function_Send(uint32_t ID, uint8_t DLC, uint8_t data[]) {
/* Apply your transmit layer here, e.g:
* uint32_t TxMailbox;
* static CAN_HandleTypeDef can_handler;
* static CAN_HandleTypeDef can_handler;
* This function transmit ID, DLC and data[] as the CAN-message.
* HardWareLayerCAN_TX(&can_handler, ID, DLC, data, &TxMailbox);
*
*
* You can use TCP/IP, USB, CAN etc. as hardware layers for SAE J1939
*/
}
Expand All @@ -32,7 +32,7 @@ void Callback_Function_Read(uint32_t* ID, uint8_t data[], bool* is_new_data) {
* if (HardWareLayerCAN_RX(can_handler, &rxHeader, ID, data) == STATUS_OK){
* *is_new_data = true;
* }
*
*
* You can use TCP/IP, USB, CAN etc. as hardware layers for SAE J1939
*/
}
Expand Down Expand Up @@ -76,13 +76,18 @@ int main() {
/* Load your ECU information */
Open_SAE_J1939_Startup_ECU(&j1939);

while (1) {
/* SAE J1939 process */
bool run = true;
while (run) {
/* Read incoming messages */
Open_SAE_J1939_Listen_For_Messages(&j1939);

/* Your application code here */

}

/* Save your ECU information */
Open_SAE_J1939_Closedown_ECU(&j1939);

return 0;
}
3 changes: 2 additions & 1 deletion Src/Open-SAE-J1939.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
<ClCompile Include="ISO_11783\ISO_11783-7_Application_Layer\General_Purpose_Valve_Command.c" />
<ClCompile Include="ISO_11783\ISO_11783-7_Application_Layer\General_Purpose_Valve_Estimated_Flow.c" />
<ClCompile Include="Main.c" />
<ClCompile Include="Open_SAE_J1939\Closedown_ECU.c" />
<ClCompile Include="Open_SAE_J1939\Listen_For_Messages.c" />
<ClCompile Include="Open_SAE_J1939\Startup_ECU.c" />
<ClCompile Include="SAE_J1939\SAE_J1939-21_Transport_Layer\Acknowledgement.c" />
Expand Down Expand Up @@ -172,7 +173,7 @@
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
Expand Down
3 changes: 3 additions & 0 deletions Src/Open-SAE-J1939.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@
<ClCompile Include="ISO_11783\ISO_11783-7_Application_Layer\General_Purpose_Valve_Estimated_Flow.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Open_SAE_J1939\Closedown_ECU.c">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Open_SAE_J1939\Open_SAE_J1939.h">
Expand Down

0 comments on commit 5c9dea9

Please sign in to comment.