mirror of
https://github.com/dalathegreat/Battery-Emulator.git
synced 2025-10-04 10:19:29 +02:00
Add support for CAN-FD
This commit is contained in:
parent
8c44da7070
commit
48e9ba9118
1 changed files with 10 additions and 6 deletions
|
@ -32,11 +32,7 @@ const char get_firmware_info_html[] = R"rawliteral(%X%)rawliteral";
|
||||||
|
|
||||||
String importedLogs = ""; // Store the uploaded file contents in RAM /WARNING THIS MIGHT GO BOOM
|
String importedLogs = ""; // Store the uploaded file contents in RAM /WARNING THIS MIGHT GO BOOM
|
||||||
|
|
||||||
CAN_frame currentFrame = {.FD = false,
|
CAN_frame currentFrame = {.FD = true, .ext_ID = false, .DLC = 64, .ID = 0x12F, .data = {0}};
|
||||||
.ext_ID = false,
|
|
||||||
.DLC = 8,
|
|
||||||
.ID = 0x12F,
|
|
||||||
.data = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}};
|
|
||||||
|
|
||||||
void handleFileUpload(AsyncWebServerRequest* request, String filename, size_t index, uint8_t* data, size_t len,
|
void handleFileUpload(AsyncWebServerRequest* request, String filename, size_t index, uint8_t* data, size_t len,
|
||||||
bool final) {
|
bool final) {
|
||||||
|
@ -183,11 +179,19 @@ void init_webserver() {
|
||||||
// Parse and store data bytes
|
// Parse and store data bytes
|
||||||
int byteIndex = 0;
|
int byteIndex = 0;
|
||||||
char* token = strtok((char*)dataBytes.c_str(), " ");
|
char* token = strtok((char*)dataBytes.c_str(), " ");
|
||||||
while (token != NULL && byteIndex < 8) {
|
while (token != NULL && byteIndex < currentFrame.DLC) { // Use DLC instead of fixed 8
|
||||||
currentFrame.data.u8[byteIndex++] = strtol(token, NULL, 16);
|
currentFrame.data.u8[byteIndex++] = strtol(token, NULL, 16);
|
||||||
token = strtok(NULL, " ");
|
token = strtok(NULL, " ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Apply FD incase interface is set to FD
|
||||||
|
if ((datalayer.system.info.can_replay_interface == CANFD_NATIVE) ||
|
||||||
|
(datalayer.system.info.can_replay_interface == CANFD_ADDON_MCP2518)) {
|
||||||
|
currentFrame.FD = true;
|
||||||
|
} else {
|
||||||
|
currentFrame.FD = false;
|
||||||
|
}
|
||||||
|
|
||||||
// Transmit the CAN frame
|
// Transmit the CAN frame
|
||||||
transmit_can_frame(¤tFrame, datalayer.system.info.can_replay_interface);
|
transmit_can_frame(¤tFrame, datalayer.system.info.can_replay_interface);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue