diff --git a/firmware/controllers/lua/examples/gdi4-communication.txt b/firmware/controllers/lua/examples/gdi4-communication.txt index 6bdcfe6ceb..b05ca0100e 100644 --- a/firmware/controllers/lua/examples/gdi4-communication.txt +++ b/firmware/controllers/lua/examples/gdi4-communication.txt @@ -50,9 +50,17 @@ function onCanConfiguration(bus, id, dlc, data) print ("HoldCurrent " ..getTwoBytesLSB(data, 6, 0.01) ) end +function onCanVersion(bus, id, dlc, data) + year = data[1] * 100 + data[2] + month = data[3] + day = data[4] + print ("GDI4 FW " .. year .. '/' .. month .. '/' .. day) +end + canRxAdd(GDI4_BASE_ADDRESS, printPacket) canRxAdd(GDI4_BASE_ADDRESS + 1, onCanConfiguration) canRxAdd(GDI4_BASE_ADDRESS + 2, printPacket) +canRxAdd(GDI4_BASE_ADDRESS + 3, onCanVersion) local data_set_voltage = { 0x88, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } @@ -63,22 +71,21 @@ function onTick() boostVoltage = getCalibration("mc33_hvolt") boostCurrent = getCalibration("mc33_i_boost") / 1000.0 peakCurrent = getCalibration("mc33_i_peak") / 1000.0 - print("boostVoltage " .. boostVoltage .." boostCurrent " ..boostCurrent .." peakCurrent " ..peakCurrent) - - holdCurrent = getCalibration("mc33_i_hold") - peakDuration = getCalibration("mc33_t_peak_tot") / 1000.0 - holdDuration = getCalibration("mc33_t_hold_tot") / 1000.0 - print("holdCurrent " .. holdCurrent .. " peakDuration " .. peakDuration .." hold duration " ..holdDuration) + print("To send: boostVoltage " .. boostVoltage .." boostCurrent " ..boostCurrent .." peakCurrent " ..peakCurrent) setTwoBytesLsb(data_set_voltage, 1, boostVoltage * FIXED_POINT) setTwoBytesLsb(data_set_voltage, 3, boostCurrent * FIXED_POINT) setTwoBytesLsb(data_set_voltage, 5, peakCurrent * FIXED_POINT) - print('Sending ' ..arrayToString(data_set_voltage)) - - + print('Will be sending ' ..arrayToString(data_set_voltage)) txCan(1, 0x201, 1, data_set_voltage) + holdCurrent = getCalibration("mc33_i_hold") + peakDuration = getCalibration("mc33_t_peak_tot") / 1000.0 + holdDuration = getCalibration("mc33_t_hold_tot") / 1000.0 + print("To send: holdCurrent " .. holdCurrent .. " peakDuration " .. peakDuration .." hold duration " ..holdDuration) + + end