Skip to content

Commit

Permalink
better Lua template
Browse files Browse the repository at this point in the history
  • Loading branch information
rusefillc committed Nov 18, 2023
1 parent bf5e8e0 commit 8107435
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/main/java/com/rusefi/can/analysis/PerSidDump.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,20 +50,26 @@ public static void handle(String reportDestinationFolder, String simpleFileName,
String middleOutputFileName = filteredDestinationFolder + File.separator + simpleFileName + "_filtered_" + dualSid(sid, "_") + "_middle.txt";
PrintWriter middle = new PrintWriter(new FileOutputStream(middleOutputFileName));

String payloadVariableName = "payload" + middlePacket.getId();
String variableName = "CAN_" + middlePacket.getId() + "_" + Integer.toHexString(middlePacket.getId());
String decAndHex = middlePacket.getId() + "_" + Integer.toHexString(middlePacket.getId());
String payloadVariableName = "payload" + decAndHex;
String variableName = "CAN_" + decAndHex;

StringBuilder payloadLine = middlePacket.asLua(payloadVariableName);

middle.println(variableName + " = " + middlePacket.getId());
middle.println(payloadLine);

String counterVariable = "counter" + decAndHex;

middle.println();
String methodName = "onMotor" + middlePacket.getId();
middle.println(counterVariable + " = 0");
String methodName = "onMotor" + decAndHex;
middle.println("function " + methodName + "(bus, id, dlc, data)");
middle.println("\t" + counterVariable + " = (" + counterVariable + " + 1) % 256");
middle.println("\t" + payloadVariableName + "[x] = " + counterVariable);
//middle.println("\tprint ('MOTOR_" + middlePacket.getId() + "' " ..)

middle.println("\ttxCan(TCU_BUS, " + variableName + ", 0, " + payloadVariableName + ")");
middle.println("\ttxCan(VEHICLE_BUS, " + variableName + ", 0, " + payloadVariableName + ")");

middle.println("end");
middle.println();
Expand Down

0 comments on commit 8107435

Please sign in to comment.