rusEFI
The most advanced open source ECU
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 processCanRxMessage (const size_t busIndex, const CANRxFrame &msg, efitick_t nowNt)
 
void registerCanListener (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 66 of file can.h.

Enumeration Type Documentation

◆ CanInterval

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

Definition at line 32 of file can.h.

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

Function Documentation

◆ operator&()

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

Definition at line 74 of file can.h.

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

◆ operator|()

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

Definition at line 69 of file can.h.

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

◆ operator|=()

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

Definition at line 79 of file can.h.

79  {
80  lhs = lhs | rhs;
81  return lhs;
82 }

◆ processCanRxMessage()

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

Definition at line 192 of file can_rx.cpp.

192  {
193  if ((engineConfiguration->verboseCan && busIndex == 0) || verboseRxCan) {
194  printPacket(busIndex, frame);
195  } else if (engineConfiguration->verboseCan2 && busIndex == 1) {
196  printPacket(busIndex, frame);
197  }
198 
199  boardProcessCanRxMessage(busIndex, frame, nowNt);
200 
201  // see AemXSeriesWideband as an example of CanSensorBase/CanListener
202  serviceCanSubscribers(frame, nowNt);
203 
204  // todo: convert to CanListener or not?
205  //Vss is configurable, should we handle it here:
206  processCanRxVss(frame, nowNt);
207 
209  // todo: convert to CanListener or not?
210  processCanRxImu(frame);
211  }
212 
213  processCanQcBenchTest(frame);
214 
215  processLuaCan(busIndex, frame);
216 
217 #if EFI_CANBUS_SLAVE
218  if (CAN_EID(frame) == engineConfiguration->verboseCanBaseAddress + CAN_SENSOR_1_OFFSET) {
219  int16_t mapScaled = *reinterpret_cast<const int16_t*>(&frame.data8[0]);
220  canMap = mapScaled / (1.0 * PACK_MULT_PRESSURE);
221  } else
222 #endif
223  {
224  obdOnCanPacketRx(frame, busIndex);
225  }
226 
227 #if EFI_ENGINE_CONTROL
228  if (CAN_EID(frame) == GDI4_BASE_ADDRESS && frame.data8[7] == GDI4_MAGIC) {
229 // efiPrintf("CAN GDI4 says hi");
230  getLimpManager()->gdiComms.reset();
231  }
232 #endif // EFI_ENGINE_CONTROL
233 
234 #if EFI_WIDEBAND_FIRMWARE_UPDATE
235  // Bootloader acks with address 0x727573 aka ascii "rus"
236  if (CAN_EID(frame) == WB_ACK) {
238  }
239 #endif
240 #if EFI_USE_OPENBLT
241 #include "openblt/efi_blt_ids.h"
242  if ((CAN_SID(frame) == BOOT_COM_CAN_RX_MSG_ID) && (frame.DLC == 2)) {
243  /* TODO: gracefull shutdown? */
244  if (((busIndex == 0) && (engineConfiguration->canOpenBLT)) ||
245  ((busIndex == 1) && (engineConfiguration->can2OpenBLT))) {
246  jump_to_openblt();
247  }
248  }
249 #endif
250 }
void jump_to_openblt()
void processCanQcBenchTest(const CANRxFrame &frame)
void serviceCanSubscribers(const CANRxFrame &frame, efitick_t nowNt)
Definition: can_rx.cpp:76
static void processCanRxImu(const CANRxFrame &frame)
Definition: can_rx.cpp:154
BOARD_WEAK void boardProcessCanRxMessage(const size_t busIndex, const CANRxFrame &frame, efitick_t nowNt)
Definition: can_rx.cpp:190
volatile float canMap
Definition: can_rx.cpp:56
static void printPacket(const size_t busIndex, const CANRxFrame &rx)
Definition: can_rx.cpp:32
bool verboseRxCan
Definition: settings.cpp:547
void processCanRxVss(const CANRxFrame &frame, efitick_t nowNt)
Definition: can_vss.cpp:188
Timer gdiComms
Definition: limp_manager.h:133
LimpManager * getLimpManager()
Definition: engine.cpp:595
void processLuaCan(const size_t busIndex, const CANRxFrame &frame)
Definition: lua_can_rx.cpp:29
void obdOnCanPacketRx(const CANRxFrame &rx, size_t busIndex)
Definition: obd2.cpp:192
engine_configuration_s * engineConfiguration
void handleWidebandBootloaderAck()
Here is the call graph for this function:

◆ registerCanListener()

void registerCanListener ( CanListener listener)

Definition at line 89 of file can_rx.cpp.

89  {
90  // If the listener already has a next, it's already registered
91  if (!listener.hasNext()) {
94  }
95 }
CanListener * canListeners_head
Definition: can_rx.cpp:74
bool hasNext() const
Definition: can_listener.h:39
void setNext(CanListener *next)
Definition: can_listener.h:31
static CanTsListener listener
Definition: serial_can.cpp:35

Referenced by CanStreamer::init(), initCanGpioMsiobox(), 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 97 of file can_rx.cpp.

97  {
99  sensor.Register();
100 }
void registerCanListener(CanListener &listener)
Definition: can_rx.cpp:89
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:

Go to the source code of this file.