rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
Data Structures | Typedefs | Enumerations | Functions
can.h File Reference

Detailed Description

Date
Mar 19, 2020
Author
Matthew Kennedy, (c) 2020

Definition in file can.h.

Data Structures

class  CanWrite
 
class  CanCycle
 

Typedefs

using CI = CanInterval
 

Enumerations

enum class  CanInterval : uint16_t {
  None = 0 , _5ms = 1 << 0 , _10ms = 1 << 1 , _20ms = 1 << 2 ,
  _50ms = 1 << 3 , _100ms = 1 << 4 , _200ms = 1 << 5 , _250ms = 1 << 6 ,
  _500ms = 1 << 7 , _1000ms = 1 << 8 , _MAX_Cycle = _1000ms
}
 

Functions

void resetCanWriteCycle ()
 
void processCanRxMessage (const size_t busIndex, const CANRxFrame &msg, efitick_t nowNt)
 
void registerCanListener (CanListener &listener)
 
void unregisterCanListener (CanListener &listener)
 
void registerCanSensor (CanSensorBase &sensor)
 
constexpr CI operator| (CI lhs, CI rhs)
 
constexpr CI operator& (CI lhs, CI rhs)
 
constexpr CIoperator|= (CI &lhs, CI rhs)
 

Typedef Documentation

◆ CI

using CI = CanInterval

Definition at line 68 of file can.h.

Enumeration Type Documentation

◆ CanInterval

enum class CanInterval : uint16_t
strong
Enumerator
None 
_5ms 
_10ms 
_20ms 
_50ms 
_100ms 
_200ms 
_250ms 
_500ms 
_1000ms 
_MAX_Cycle 

Definition at line 29 of file can.h.

29 : uint16_t {
30 None = 0,
31 _5ms = 1 << 0,
32 _10ms = 1 << 1,
33 _20ms = 1 << 2,
34 _50ms = 1 << 3,
35 _100ms = 1 << 4,
36 _200ms = 1 << 5,
37 _250ms = 1 << 6,
38 _500ms = 1 << 7,
39 _1000ms = 1 << 8,
41};

Function Documentation

◆ operator&()

constexpr CI operator& ( CI  lhs,
CI  rhs 
)
constexpr

Definition at line 76 of file can.h.

76 {
77 using T = std::underlying_type_t<CI>;
78 return static_cast<CI>(static_cast<T>(lhs) & static_cast<T>(rhs));
79}
CanInterval
Definition can.h:29

◆ operator|()

constexpr CI operator| ( CI  lhs,
CI  rhs 
)
constexpr

Definition at line 71 of file can.h.

71 {
72 using T = std::underlying_type_t<CI>;
73 return static_cast<CI>(static_cast<T>(lhs) | static_cast<T>(rhs));
74}

◆ operator|=()

constexpr CI & operator|= ( CI lhs,
CI  rhs 
)
constexpr

Definition at line 81 of file can.h.

81 {
82 lhs = lhs | rhs;
83 return lhs;
84}

◆ processCanRxMessage()

void processCanRxMessage ( const size_t  busIndex,
const CANRxFrame msg,
efitick_t  nowNt 
)

Definition at line 227 of file can_rx.cpp.

227 {
228 if (verboseRxCan ||
229 (engineConfiguration->verboseCan && busIndex == 0) ||
230 (engineConfiguration->verboseCan2 && busIndex == 1) ||
231#if (EFI_CAN_BUS_COUNT >= 3)
232 (engineConfiguration->verboseCan3 && busIndex == 2) ||
233#endif
234 0) {
235 printCANRxFrame(busIndex, frame);
236 }
237
238 // TODO use call_board_override
239 if (custom_board_can_rx.has_value()) {
240 custom_board_can_rx.value()(busIndex, frame, nowNt);
241 }
242
243 // see AemXSeriesWideband as an example of CanSensorBase/CanListener
244 serviceCanSubscribers(busIndex, frame, nowNt);
245
246 // todo: convert to CanListener or not?
247 //Vss is configurable, should we handle it here:
248 processCanRxVss(frame, nowNt);
249
251 // todo: convert to CanListener or not?
252 processCanRxImu(frame);
253 }
254
255/*
256static Timer dashAliveTimer;
257
258 if (CAN_EID(frame) == (int)bench_test_packet_ids_e::DASH_ALIVE) {
259 // todo: add an indicator that dash is connected?
260 dashAliveTimer.reset();
261 }
262*/
263
266
267 processLuaCan(busIndex, frame);
268
269 {
270 obdOnCanPacketRx(frame, busIndex);
271 }
272
273#if EFI_ENGINE_CONTROL
274 if (CAN_EID(frame) == GDI4_BASE_ADDRESS && frame.data8[7] == GDI4_MAGIC) {
275// efiPrintf("CAN GDI4 says hi");
277 }
278#endif // EFI_ENGINE_CONTROL
279
280 handleWidebandCan(busIndex, frame);
281#if EFI_USE_OPENBLT
282#include "openblt/efi_blt_ids.h"
283 if ((CAN_SID(frame) == BOOT_COM_CAN_RX_MSG_ID) && (frame.DLC == 2)) {
284 /* TODO: gracefull shutdown? */
285 if (((busIndex == 0) && (engineConfiguration->canOpenBLT)) ||
286 ((busIndex == 1) && (engineConfiguration->can2OpenBLT))) {
288 }
289 }
290#endif
291}
void jump_to_openblt()
void processCanEcuControl(const CANRxFrame &frame)
void processCanQcBenchTest(const CANRxFrame &frame)
std::optional< board_can_rx_type > custom_board_can_rx
Definition can_rx.cpp:225
static void processCanRxImu(const CANRxFrame &frame)
Definition can_rx.cpp:184
bool verboseRxCan
Definition settings.cpp:364
void printCANRxFrame(const size_t busIndex, const CANRxFrame &rx)
Definition can_rx.cpp:29
void serviceCanSubscribers(const size_t busIndex, const CANRxFrame &frame, efitick_t nowNt)
Definition can_rx.cpp:71
void processCanRxVss(const CANRxFrame &frame, efitick_t nowNt)
Definition can_vss.cpp:177
Timer externalGdiCanBusComms
LimpManager * getLimpManager()
Definition engine.cpp:608
static constexpr engine_configuration_s * engineConfiguration
void processLuaCan(const size_t busIndex, const CANRxFrame &frame)
void obdOnCanPacketRx(const CANRxFrame &rx, size_t busIndex)
Definition obd2.cpp:210
void handleWidebandCan(const size_t busIndex, const CANRxFrame &frame)
Here is the call graph for this function:

◆ registerCanListener()

void registerCanListener ( CanListener listener)

Definition at line 86 of file can_rx.cpp.

86 {
87 // Do this under lock?
88
89 // If the listener already has a next, it's already registered
90 if (!listener.getNext()) {
91 listener.setNext(canListeners_head);
92 canListeners_head = &listener;
93 }
94}
CanListener * canListeners_head
Definition can_rx.cpp:69
CanListener * getNext() const
void setNext(CanListener *next)

Referenced by CanTransport::init(), initCanGpioMsiobox(), IsoTpRx::IsoTpRx(), and registerCanSensor().

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

◆ registerCanSensor()

void registerCanSensor ( CanSensorBase sensor)

Definition at line 116 of file can_rx.cpp.

116 {
119}
void registerCanListener(CanListener &listener)
Definition can_rx.cpp:86
bool Register()
Definition sensor.cpp:131
static Lps25Sensor sensor(device)

Referenced by initCanSensors(), initEgt(), and initLambda().

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

◆ resetCanWriteCycle()

void resetCanWriteCycle ( )

Definition at line 45 of file can_tx.cpp.

45 {
46 m_cycleCount = 0;
47}
static uint16_t m_cycleCount
Definition can_tx.cpp:43

◆ unregisterCanListener()

void unregisterCanListener ( CanListener listener)

Definition at line 96 of file can_rx.cpp.

96 {
97 // Do this under lock?
98
99 // listener is at head of list...
100 if (canListeners_head == &listener) {
101 canListeners_head = listener.getNext();
102 } else {
104
105 while (current->getNext() && (current->getNext() != &listener)) {
106 current = current->getNext();
107 }
108 if (current->getNext()) {
109 current->setNext(listener.getNext());
110 }
111 }
112
113 listener.setNext(nullptr);
114}

Referenced by IsoTpRx::~IsoTpRx().

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

Go to the source code of this file.