rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes
CanSensor< TStorage, TScale > Class Template Reference

#include <can_sensor.h>

Inheritance diagram for CanSensor< TStorage, TScale >:
Inheritance graph
[legend]
Collaboration diagram for CanSensor< TStorage, TScale >:
Collaboration graph
[legend]

Public Member Functions

 CanSensor (uint32_t eid, uint8_t offset, SensorType type, efidur_t timeout)
 
void decodeFrame (const CANRxFrame &frame, efitick_t nowNt) override
 
- Public Member Functions inherited from CanSensorBase
 CanSensorBase (uint32_t eid, SensorType type, efidur_t timeout)
 
void showInfo (const char *sensorName) const override
 
- Public Member Functions inherited from StoredValueSensor
SensorResult get () const final override
 
 StoredValueSensor (SensorType type, efidur_t timeoutNt)
 
void invalidate ()
 
void invalidate (UnexpectedCode why)
 
void setValidValue (float value, efitick_t timestamp)
 
void showInfo (const char *sensorName) const override
 
virtual void setTimeout (int timeoutMs)
 
- Public Member Functions inherited from Sensor
bool Register ()
 
const chargetSensorName () const
 
virtual bool hasSensor () const
 
virtual float getRaw () const
 
virtual bool isRedundant () const
 
void unregister ()
 
SensorType type () const
 
- Public Member Functions inherited from CanListener
 CanListener (uint32_t id)
 
CanListenerprocessFrame (const size_t busIndex, const CANRxFrame &frame, efitick_t nowNt)
 
uint32_t getId ()
 
void setNext (CanListener *next)
 
virtual CanListenerrequest ()
 
bool hasNext () const
 
virtual bool acceptFrame (const size_t busIndex, const CANRxFrame &frame) const
 

Private Attributes

const uint8_t m_offset
 

Additional Inherited Members

- Static Public Member Functions inherited from Sensor
static void showAllSensorInfo ()
 
static void showInfo (SensorType type)
 
static void resetRegistry ()
 
static const SensorgetSensorOfType (SensorType type)
 
static SensorResult get (SensorType type)
 
static float getOrZero (SensorType type)
 
static float getRaw (SensorType type)
 
static bool isRedundant (SensorType type)
 
static bool hasSensor (SensorType type)
 
static void setMockValue (SensorType type, float value, bool mockRedundant=false)
 
static void setInvalidMockValue (SensorType type)
 
static void resetMockValue (SensorType type)
 
static void resetAllMocks ()
 
static void inhibitTimeouts (bool inhibit)
 
static const chargetSensorName (SensorType type)
 
- Protected Member Functions inherited from Sensor
 Sensor (SensorType type)
 
- Static Protected Attributes inherited from Sensor
static bool s_inhibitSensorTimeouts = false
 

Detailed Description

template<typename TStorage, int TScale>
class CanSensor< TStorage, TScale >

Definition at line 32 of file can_sensor.h.

Constructor & Destructor Documentation

◆ CanSensor()

template<typename TStorage , int TScale>
CanSensor< TStorage, TScale >::CanSensor ( uint32_t  eid,
uint8_t  offset,
SensorType  type,
efidur_t  timeout 
)
inline

Definition at line 34 of file can_sensor.h.

35 : CanSensorBase(eid, type, timeout)
37 {
38 }
const uint8_t m_offset
Definition can_sensor.h:53
SensorType type() const
Definition sensor.h:162
uint16_t offset
Definition tunerstudio.h:0

Member Function Documentation

◆ decodeFrame()

template<typename TStorage , int TScale>
void CanSensor< TStorage, TScale >::decodeFrame ( const CANRxFrame frame,
efitick_t  nowNt 
)
inlineoverridevirtual

Implements CanListener.

Definition at line 40 of file can_sensor.h.

40 {
41 // Compute the location of our data within the frame
42 const uint8_t* dataLocation = &frame.data8[m_offset];
43
44 // Reinterpret as a scaled_channel - it already has the logic for decoding a scaled integer to a float
45 const auto scaler = reinterpret_cast<const scaled_channel<TStorage, TScale>*>(dataLocation);
46
47 // Actually do the conversion
48 float value = *scaler;
49 setValidValue(value, nowNt);
50 }
void setValidValue(float value, efitick_t timestamp)
uint8_t data8[8]
Frame data.
Definition can_mocks.h:55
Here is the call graph for this function:

Field Documentation

◆ m_offset

template<typename TStorage , int TScale>
const uint8_t CanSensor< TStorage, TScale >::m_offset
private

Definition at line 53 of file can_sensor.h.

Referenced by CanSensor< TStorage, TScale >::decodeFrame().


The documentation for this class was generated from the following file: