csock-raw (Can Socket Raw)ï
Header: udo/csock-raw.h
Table of contents (click to go)ï
Macrosï
Enumsï
Unionsï
Structsï
Functionsï
API Documentationï
Kernel Modulesï
On Host Machine
sudo modprobe -a can can_raw vcan
sudo ip link add dev vcan0 type vcan
sudo ip link set vcan0 up
udo_csock_raw (private)ï
Structure defining UDO CAN Socket Raw context.
udo_csock_raw_create_infoï
Structure passed to
udo_csock_raw_create()used to define how to create the CAN socket.
udo_csock_raw_createï
-
struct udo_csock_raw *udo_csock_raw_create(struct udo_csock_raw *csock, const void *csock_info);ï
Creates a socket that may be utilized
for sending & receiving CAN frames. On
a caller specified CAN interface.
Param
Decription
csock
IfNULLmemory will be allocated and return tocaller. If notNULLaddress passed will be usedto store the newly createdstructudo_csock_rawcontext.csock_info
Implementation uses a pointer to astructudo_csock_raw_create_info.
- Returns:
on success: Pointer to astructudo_csock_rawon failure:NULL
udo_csock_raw_send_dataï
-
ssize_t udo_csock_raw_send_data(struct udo_csock_raw *csock, const struct can_frame *frame, const void *csock_info);ï
Send CAN frame through socket bounded to CAN interface
specified by a call to
udo_csock_raw_create().
Param
Decription
csock
Must pass a pointer to astructudo_csock_raw.frame
Pointer to frame buffer to send through socket.csock_info
Reserved for future usage. For now usedto set the flag argument of send(2).
- Returns:
on success: Size of CAN frameon failure: # < 0
udo_csock_raw_recv_dataï
-
ssize_t udo_csock_raw_recv_data(struct udo_csock_raw *csock, struct can_frame *frame, const void *csock_info);ï
Receive CAN frame from socket bounded to CAN interface
specified by a call to
udo_csock_raw_create().
Param
Decription
csock
Must pass a pointer to astructudo_csock_raw.frame
Pointer to buffer to store data received from a socket.csock_info
Reserved for future usage. For now usedto set the flag argument of send(2).
- Returns:
on success: Size of CAN frameon failure: # < 0
udo_csock_raw_get_fdï
-
int udo_csock_raw_get_fd(struct udo_csock_raw *csock);ï
Acquire socket file descriptor associated with
struct udo_csock_raw context.
Param
Decription
csock
Must pass a pointer to astructudo_csock_raw.
- Returns:
on success: RAW socket file descriptoron failure: -1
udo_csock_raw_get_ifaceï
-
const char *udo_csock_raw_get_iface(struct udo_csock_raw *csock);ï
Acquire textual CAN interface name in string format
associated with
struct udo_csock_raw context.
Param
Decription
csock
Must pass a pointer to astructudo_csock_raw.
- Returns:
on success: Textual CAN interface name in string formaton failure:NULL
udo_csock_raw_destroyï
-
void udo_csock_raw_destroy(struct udo_csock_raw *csock);ï
Frees any allocated memory and closes FDâs (if open)
created after
udo_csock_raw_create() call.
Param
Decription
csock
Pointer to a validstructudo_csock_raw.
udo_csock_raw_get_sizeofï
-
int udo_csock_raw_get_sizeof(void);ï
Returns size of the internal structure. So,
if caller decides to allocate memory outside
of API interface they know the exact amount
of bytes.
- Returns:
on success: sizeof(structudo_csock_raw)on failure: sizeof(structudo_csock_raw)