64#ifndef __FPSDK_COMMON_CAN_HPP__
65#define __FPSDK_COMMON_CAN_HPP__
108 void SetData(
const uint8_t* data,
const std::size_t size);
120 bool RawToFrame(
const uint8_t* data,
const std::size_t size);
135 struct canfd_frame
fd_frame_ = { 0, 0, 0, 0, 0, { 0 } };
174 bool SetFilters(
const std::vector<struct can_filter>& filters);
231 bool ReadFrame(
struct can_frame& frame,
const int timeout = 0);
259 bool ReadFrame(
struct canfd_frame& frame,
const int timeout = 0);
Raw CAN helper class using SocketCAN.
void Close()
Close CAN interface.
bool ReadFrame(struct canfd_frame &frame, const int timeout=0)
Read raw CAN FD frame.
bool Open()
Open CAN interface.
int GetSocket() const
Get socket.
void FlushInput()
Flush all pending input data.
bool SendFrame(const struct canfd_frame &frame)
Send raw CAN FD frame.
bool SendFrame(CanFrame &frame)
Send raw CAN frame (standard, extended and FD, and combinations thereof)
std::string GetStrerror()
Get last error string (strerror)
bool ReadFrame(struct can_frame &frame, const int timeout=0)
Read raw classical CAN frame.
bool IsOpen() const
Check if CAN is open.
bool SendFrame(const struct can_frame &frame)
Send raw classical CAN frame.
std::string device_
Device name.
int sock_
The socket to the CAN inferface.
bool ReadFrame(CanFrame &frame, const int timeout=0)
Read raw CAN frame (standard, extended and FD, and combinations thereof)
int GetErrno() const
Get last error (errno)
int saved_errno_
Saved errno.
bool SetFilters(const std::vector< struct can_filter > &filters)
Set filters.
RawCan(const std::string &device)
Constructor.
Base class to prevent copy or move.
CAN frame abstraction for standard, extended and FD (and combinations thereof) CAN frames.
struct can_frame can_frame_
Classical CAN frame (is_fd_ = false)
void SetData(const uint8_t *data, const std::size_t size)
Set data (data_len_ and data_ fields)
bool is_eff_
true = extended frame (29 bits ID, CAN_EFF_FLAG), false = standard frame (11 bits ID)
bool fd_brs_
Use bit rate switch for a FD frame (only valid if is_fd_ = true)
bool rtr_flag_
Remote transmission request flag (CAN_RTR_FLAG)
const uint8_t * data_
Pointer to data (can_frame_.data resp. fd_frame_.data)
bool RawToFrame(const uint8_t *data, const std::size_t size)
Populate frame (this struct) from raw data.
bool err_flag_
Error message frame flag (CAN_ERR_FLAG)
struct canfd_frame fd_frame_
FD CAN frame (is_fd_ = true)
bool is_fd_
true = CAN FD frame (up to CANFD_MAX_DLEN bytes), false = classical frame (up to CAN_MAX_DLEN bytes)
std::size_t data_len_
Number of bytes in payload data: up to CAN_MAX_DLEN for classical frames (is_fd_ = false),...
uint32_t can_id_
CAN ID (masked by CAN_SFF_MASK resp CAN_EFF_MASK), i.e. flags removed)
void FrameToRaw()
Set raw CAN frame from frame (this struct)
Fixposition SDK: Common types and type helpers.