11#include "dawn/common/thread.hxx"
12#include "dawn/porting/config.hxx"
13#include "dawn/proto/common.hxx"
14#include "dawn/proto/can/isotp.hxx"
16#if defined(CONFIG_DAWN_PROTO_CAN_SEG) || defined(CONFIG_DAWN_PROTO_CAN_SINGLE_ID)
17# define DAWN_PROTO_HAS_ISOTP
64 }
typedef SProtoCanIOBind;
66 explicit CProtoCan(CDescObject &desc)
69 , nodeid(CONFIG_DAWN_PROTO_CAN_NODEID)
75 ~CProtoCan()
override;
77#ifdef CONFIG_DAWN_OBJECT_HAS_NAME
78 const char *getClassNameStr()
const override
126#ifdef DAWN_PROTO_HAS_ISOTP
127 CIsoTp::State *isotp;
129 }
typedef SCanIoData;
131#ifdef DAWN_PROTO_HAS_ISOTP
137 }
typedef SProtoCanWriteAll;
142 const SProtoCanIOBind *cfg;
145#ifdef CONFIG_DAWN_PROTO_CAN_SINGLE_ID
146 SProtoCanWriteAll *write_all;
148 }
typedef SProtoCanRegs;
150 char path[PATH_MAX] = {};
156 std::vector<SProtoCanIOBind *> valloc;
157 std::vector<SProtoCanRegs *> vregs;
159 int configureDesc(
const CDescObject &desc);
160 void allocObject(SProtoCanIOBind *alloc);
163 int validateCanIo(
const SProtoCanIOBind *v, CIOCommon *io, SCanIoData *canio);
164 int createRegsForGroup(SProtoCanIOBind *v);
168#ifdef DAWN_PROTO_HAS_ISOTP
169 int sendSegmented(uint16_t canid,
174 int sendSegmentedRead(SCanIoData *canio,
180 int sendIoResponse(SCanIoData *canio, uint8_t index,
bool segmented);
181#ifdef CONFIG_DAWN_PROTO_CAN_SINGLE_ID
185 bool ignore_len =
false);
198 static int beforePoll(
void *priv,
struct pollfd *pfds, nfds_t nfds);
199 static void afterPoll(
void *priv,
struct pollfd *pfds, nfds_t nfds,
int ret);
200 static int onPollReady(
void *priv,
struct pollfd *pfds, nfds_t nfds,
int pollRet);
201 static int notifierCb(
void *priv, io_ddata_t *data);
uint16_t getPriv() const
Get instance/private data field.
CAN bus protocol for industrial automation.
int deinit()
De-initialize object.
@ CAN_TYPE_READ_SEG
segmented response, requested by data frame
@ CAN_TYPE_WRITE_SEG
segmented request
@ CAN_TYPE_PUSH
device autonomously sends data
@ CAN_TYPE_INDEXED_WRITE
indexed request/response
@ CAN_TYPE_INDEXED_READ
indexed request/response
@ CAN_TYPE_READ
request/response with RTR frame
@ CAN_TYPE_WRITE
master sends command
int configure()
Configure object from descriptor data.
int init()
One-time initialize object after bindings are resolved.
int doStop()
Stop implementation hook.
bool hasThread() const
Check if a background thread is active.
int doStart()
Start implementation hook.
@ PROTO_CAN_CFG_DEVNO
CAN device number (0=can0)
@ PROTO_CAN_CFG_IOBIND
I/O object binding.
@ PROTO_CAN_CFG_FIRST
Reserved.
@ PROTO_CAN_CFG_NODEID
CAN node ID base address.
@ PROTO_CAN_CFG_LAST
Reserved.
Base class for all protocol implementations.
@ PROTO_CLASS_CAN
CAN bus protocol.
Portable thread owner abstraction for Dawn components.
static ObjectCfgId objectCfg(uint8_t type, uint16_t cls, uint8_t dtype, bool rw, uint16_t size, uint8_t id)
Construct 32-bit ConfigID from component fields.
uint32_t ObjectCfgId
ConfigID type - single 32-bit value.
Out-of-tree user-extension hooks for Dawn.
@ OBJTYPE_PROTO
Protocol object type.
@ DTYPE_ANY
Wildcard data type (matches any actual type).
@ DTYPE_UINT32
Unsigned 32-bit integer (0 to 4294967295).
uint32_t ObjectId
ObjectID type - single 32-bit value.
static ObjectId objectId(uint8_t type, uint16_t cls, uint8_t dtype, uint8_t flags, uint16_t priv)
Construct 32-bit ObjectID from component fields.
Common CAN message format for chardev and socketCAN.