rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
Functions
can_bench_test.h File Reference

Functions

void processCanQcBenchTest (const CANRxFrame &frame)
 
void sendQcBenchEventCounters (size_t bus=0)
 
void sendQcBenchButtonCounters ()
 
void sendQcBenchAuxDigitalCounters ()
 
void sendQcBenchRawAnalogValues (size_t bus=0)
 
void sendQcBenchBoardStatus (size_t bus=0)
 
void initQcBenchControls ()
 

Function Documentation

◆ initQcBenchControls()

void initQcBenchControls ( )

Definition at line 341 of file can_bench_test.cpp.

341 {
342#if EFI_CAN_SUPPORT && EFI_PROD_CODE
343 addConsoleActionII("qc_etb", [](int index, int direction) {
344 qcSetEtbState(index, direction);
345 });
346
347 addConsoleActionI("qc_output", [](int index) {
348 Gpio* boardOutputs = getBoardMetaOutputs();
349 criticalAssertVoid(boardOutputs != nullptr, "outputs not defined");
350 Gpio pin = boardOutputs[index];
351 efiSetPadModeWithoutOwnershipAcquisition("qc_output", pin, PAL_MODE_OUTPUT_PUSHPULL);
352
353 int physicalValue = palReadPad(getHwPort("read", pin), getHwPin("read", pin));
354 efiPrintf("original pin %s value %d", hwPortname(pin), physicalValue);
355 palWritePad(getHwPort("write", pin), getHwPin("write", pin), 1 - physicalValue);
356 sendManualPinTest(index);
357 });
358#endif // EFI_PROD_CODE
359}
static void sendManualPinTest(int id)
static void qcSetEtbState(uint8_t dcIndex, uint8_t direction)
void addConsoleActionII(const char *token, VoidIntInt callback)
Register a console command with two Integer parameters.
void addConsoleActionI(const char *token, VoidInt callback)
Register a console command with one Integer parameter.
ioportid_t getHwPort(const char *msg, brain_pin_e brainPin)
ioportmask_t getHwPin(const char *msg, brain_pin_e brainPin)
Gpio * getBoardMetaOutputs()
void efiSetPadModeWithoutOwnershipAcquisition(const char *msg, brain_pin_e brainPin, iomode_t mode)
Definition io_pins.cpp:61
const char * hwPortname(brain_pin_e brainPin)
brain_pin_e pin
Definition stm32_adc.cpp:15

Referenced by commonEarlyInit().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ processCanQcBenchTest()

void processCanQcBenchTest ( const CANRxFrame frame)

file can_bench_test.h

Definition at line 298 of file can_bench_test.cpp.

298 {
299 if (CAN_EID(frame) != (int)bench_test_packet_ids_e::HW_QC_IO_CONTROL) {
300 return;
301 }
302 if (frame.data8[0] != (int)bench_test_magic_numbers_e::BENCH_HEADER) {
303 return;
304 }
305 setHwQcMode();
306 bench_test_io_control_e command = (bench_test_io_control_e)frame.data8[1];
307 if (command == bench_test_io_control_e::CAN_BENCH_GET_COUNT) {
309 } else if (command == bench_test_io_control_e::CAN_QC_OUTPUT_CONTROL_SET) {
310 // see also "bench_setpin" console command
311 setPin(frame, 1);
312 } else if (command == bench_test_io_control_e::CAN_QC_OUTPUT_CONTROL_CLEAR) {
313 setPin(frame, 0);
314 } else if (command == bench_test_io_control_e::CAN_QC_ETB) {
315 uint8_t dcIndex = frame.data8[2];
316 uint8_t direction = frame.data8[3];
317 qcSetEtbState(dcIndex, direction);
318 } else if (command == bench_test_io_control_e::CAN_BENCH_SET_ENGINE_TYPE) {
319 int eType = frame.data8[2];
320 // todo: fix firmware for 'false' to be possible - i.e. more of properties should be applied on the fly
321 setEngineType(eType, true);
322#if EFI_PROD_CODE
324#endif // EFI_PROD_CODE
325} else if (command == bench_test_io_control_e::CAN_BENCH_START_PIN_TEST) {
326 bench_mode_e benchModePinIdx = (bench_mode_e)frame.data8[2];
327 // ignore previous pin state and stats
328 resetPinStats(benchModePinIdx);
329 } else if (command == bench_test_io_control_e::CAN_BENCH_END_PIN_TEST) {
331 } else if (command == bench_test_io_control_e::CAN_BENCH_EXECUTE_BENCH_TEST) {
332 int benchCommandIdx = frame.data8[2];
333 handleBenchCategory(benchCommandIdx);
334 } else if (command == bench_test_io_control_e::CAN_BENCH_QUERY_PIN_STATE) {
335 bench_mode_e benchModePinIdx = (bench_mode_e)frame.data8[2];
336 sendPinStatePackets(benchModePinIdx);
337 }
338}
void handleBenchCategory(uint16_t index)
static void setPin(const CANRxFrame &frame, int value)
static void sendSavedBenchStatePackets()
void setHwQcMode()
static void resetPinStats(bench_mode_e benchModePinIdx)
static void sendOutBoardMeta(size_t bus)
static void sendPinStatePackets(int pinToggleCounter, uint32_t durationsInStateMs[2])
void scheduleReboot()
Definition rusefi.cpp:158
bench_mode_e
void setEngineType(int value, bool isWriteToFlash)
Definition settings.cpp:735
uint8_t data8[8]
Frame data.
Definition can_mocks.h:55

Referenced by processCanRxMessage().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sendQcBenchAuxDigitalCounters()

void sendQcBenchAuxDigitalCounters ( )

Definition at line 155 of file can_bench_test.cpp.

155 {
156 CanTxMessage msg(CanCategory::BENCH_TEST, (int)bench_test_packet_ids_e::AUX_DIGITAL_COUNTERS, 8, /*bus*/0, /*isExtended*/true);
157 for (int i =0;i<LUA_DIGITAL_INPUT_COUNT;i++) {
158 msg[i] = TRUNCATE_TO_BYTE(engine->luaDigitalInputState[i].state.getCounter());
159 }
160}
SimpleSwitchedState luaDigitalInputState[LUA_DIGITAL_INPUT_COUNT]
Definition engine.h:217
uint16_t getCounter() const
static EngineAccessor engine
Definition engine.h:413
SwitchedState state
Definition efi_output.h:36

Referenced by CanWrite::PeriodicTask().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sendQcBenchBoardStatus()

void sendQcBenchBoardStatus ( size_t  bus = 0)

Definition at line 232 of file can_bench_test.cpp.

232 {
233#if EFI_PROD_CODE
234 CanTxMessage msg(CanCategory::BENCH_TEST, (int)bench_test_packet_ids_e::BOARD_STATUS, 8, bus, /*isExtended*/true);
235
236 int boardId = getBoardId();
237 msg[0] = TRUNCATE_TO_BYTE(boardId >> 8);
238 msg[1] = TRUNCATE_TO_BYTE(boardId);
239
240 int numSecondsSinceReset = getTimeNowS();
241 msg[2] = TRUNCATE_TO_BYTE(numSecondsSinceReset >> 16);
242 msg[3] = TRUNCATE_TO_BYTE(numSecondsSinceReset >> 8);
243 msg[4] = TRUNCATE_TO_BYTE(numSecondsSinceReset);
244
245 int engineType = (int) engineConfiguration->engineType;
246 msg[5] = engineType >> 8;
247 msg[6] = engineType;
248 sendOutBoardMeta(bus);
249#endif // EFI_PROD_CODE
250}
board_id_t getBoardId()
Definition board_id.cpp:15
efitimesec_t getTimeNowS()
Current system time in seconds (32 bits)
Definition efitime.cpp:42
static constexpr engine_configuration_s * engineConfiguration

Referenced by CanWrite::PeriodicTask().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sendQcBenchButtonCounters()

void sendQcBenchButtonCounters ( )

Definition at line 147 of file can_bench_test.cpp.

147 {
148 CanTxMessage msg(CanCategory::BENCH_TEST, (int)bench_test_packet_ids_e::BUTTON_COUNTERS, 8, /*bus*/0, /*isExtended*/true);
149 msg[0] = TRUNCATE_TO_BYTE(engine->brakePedalSwitchedState.getCounter());
150 msg[1] = TRUNCATE_TO_BYTE(engine->clutchUpSwitchedState.getCounter());
151 msg[2] = TRUNCATE_TO_BYTE(engine->acButtonSwitchedState.getCounter());
152 // todo: start button
153}
SwitchedState brakePedalSwitchedState
Definition engine.h:215
SwitchedState clutchUpSwitchedState
Definition engine.h:214
SwitchedState acButtonSwitchedState
Definition engine.h:216

Referenced by CanWrite::PeriodicTask().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sendQcBenchEventCounters()

void sendQcBenchEventCounters ( size_t  bus = 0)

Definition at line 120 of file can_bench_test.cpp.

120 {
121#if EFI_SHAFT_POSITION_INPUT
122 CanTxMessage msg(CanCategory::BENCH_TEST, (int)bench_test_packet_ids_e::EVENT_COUNTERS, 8, bus, /*isExtended*/true);
123
128
129 msg[0] = TRUNCATE_TO_BYTE(primaryRise + primaryFall);
130 msg[1] = TRUNCATE_TO_BYTE(secondaryRise + secondaryFall);
131
132 for (int camIdx = 0; camIdx < 4; camIdx++) {
133 int vvtRise = 0, vvtFall = 0;
134 if (camIdx < CAM_INPUTS_COUNT) {
135 vvtRise = engine->triggerCentral.vvtEventRiseCounter[camIdx];
136 vvtFall = engine->triggerCentral.vvtEventFallCounter[camIdx];
137 }
138
139 msg[2 + camIdx] = TRUNCATE_TO_BYTE(vvtRise + vvtFall);
140 }
141
143 msg[6] = TRUNCATE_TO_BYTE(vehicleSpeedSensor.eventCounter);
144#endif // EFI_SHAFT_POSITION_INPUT
145}
TriggerCentral triggerCentral
Definition engine.h:318
int getHwEventCounter(int index) const
FrequencySensor vehicleSpeedSensor(SensorType::VehicleSpeed, MS2NT(500))
@ SHAFT_SECONDARY_RISING
@ SHAFT_SECONDARY_FALLING
@ SHAFT_PRIMARY_FALLING
@ SHAFT_PRIMARY_RISING
uint16_t vvtEventRiseCounter[CAM_INPUTS_COUNT]
uint16_t vvtEventFallCounter[CAM_INPUTS_COUNT]

Referenced by CanWrite::PeriodicTask().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sendQcBenchRawAnalogValues()

void sendQcBenchRawAnalogValues ( size_t  bus = 0)

Definition at line 162 of file can_bench_test.cpp.

162 {
163 const float values_1[] = {
172 };
173
174 const float values_2[] = {
183 };
184 const float lua_values_1[] = {
193 };
194 static_assert(efi::size(values_1) <= 8);
195 static_assert(efi::size(values_2) <= 8);
196 static_assert(efi::size(lua_values_1) <= 8);
197
198
199 // send the first packet
200 {
201 CanTxMessage msg(CanCategory::BENCH_TEST, (int)bench_test_packet_ids_e::RAW_ANALOG_1, 8, bus, /*isExtended*/true);
202 for (size_t valueIdx = 0; valueIdx < efi::size(values_1); valueIdx++) {
203 msg[valueIdx] = RAW_TO_BYTE(values_1[valueIdx]);
204 }
205 }
206 {
207 CanTxMessage msg(CanCategory::BENCH_TEST, (int)bench_test_packet_ids_e::RAW_ANALOG_2, 8, bus, /*isExtended*/true);
208 for (size_t valueIdx = 0; valueIdx < efi::size(values_2); valueIdx++) {
209 msg[valueIdx] = RAW_TO_BYTE(values_2[valueIdx]);
210 }
211 }
212 // todo: time to extract method already?
213 {
214 CanTxMessage msg(CanCategory::BENCH_TEST, (int)bench_test_packet_ids_e::RAW_LUA_ANALOG_1, 8, bus, /*isExtended*/true);
215 for (size_t valueIdx = 0; valueIdx < efi::size(lua_values_1); valueIdx++) {
216 msg[valueIdx] = RAW_TO_BYTE(lua_values_1[valueIdx]);
217 }
218 }
219}
virtual float getRaw() const
Definition sensor.h:148
@ AcceleratorPedalPrimary
@ AcceleratorPedalSecondary

Referenced by CanWrite::PeriodicTask().

Here is the call graph for this function:
Here is the caller graph for this function:

Go to the source code of this file.