Definitions high-level RAW CAN interface. More...
Definitions high-level RAW CAN interface.
This file defines the high-level CAN interface to send and receive RAW CAN frame.
Definition in file raw.h.
Go to the source code of this file.
#define | RAW_CAN_DEV_UNDEF (-1) |
Default value for undefined interface number. | |
int | raw_can_send (int ifnum, const struct can_frame *frame, kernel_pid_t pid) |
Send a CAN frame. More... | |
int | raw_can_abort (int ifnum, int handle) |
Abort a CAN frame. More... | |
int | raw_can_subscribe_rx (int ifnum, struct can_filter *filter, kernel_pid_t pid, void *param) |
Subscribe to a CAN filter. More... | |
int | raw_can_unsubscribe_rx (int ifnum, struct can_filter *filter, kernel_pid_t pid, void *param) |
Unsubscribe from reception for the given CAN filter on pid thread. More... | |
int | raw_can_free_frame (can_rx_data_t *frame) |
Free a received frame. More... | |
int | raw_can_get_can_opt (int ifnum, can_opt_t *opt) |
Get a CAN option opt from interface ifnum . More... | |
int | raw_can_set_can_opt (int ifnum, can_opt_t *opt) |
Set a CAN option opt to interface ifnum . More... | |
int | raw_can_send_mbox (int ifnum, const struct can_frame *frame, mbox_t *mbox) |
Send a CAN frame. More... | |
int | raw_can_subscribe_rx_mbox (int ifnum, struct can_filter *filter, mbox_t *mbox, void *param) |
Subscribe to a CAN filter. More... | |
int | raw_can_unsubscribe_rx_mbox (int ifnum, struct can_filter *filter, mbox_t *mbox, void *param) |
Unsubscribe from reception for the given CAN filter and mbox . More... | |
int | raw_can_power_down (int ifnum) |
Power down a given interface. More... | |
int | raw_can_power_up (int ifnum) |
Power up a given interface. More... | |
int | raw_can_get_ifnum_by_name (const char *name) |
Get the interface number of a given interface. More... | |
const char * | raw_can_get_name_by_ifnum (int ifnum) |
Get the interface name of a given interface number. More... | |
candev_dev_t * | raw_can_get_dev_by_ifnum (int ifnum) |
Get the candev descriptor from a given interface number. More... | |
int | raw_can_set_bitrate (int ifnum, uint32_t bitrate, uint32_t sample_point) |
Set the given bitrate/sample_point to the given ifnum. More... | |
int | raw_can_set_trx (int ifnum, can_trx_t *trx) |
Set a transceiver for a given interface. More... | |
int raw_can_abort | ( | int | ifnum, |
int | handle | ||
) |
Abort a CAN frame.
Abort the frame identified by handle
in the interface ifnum
If no tx confirmation is received, this function must be called by the upper layer to ensure the driver frees its tx mailbox. The driver is not responsible of tx timeouts.
[in] | ifnum | the interface number used to send the frame |
[in] | handle | the handle of the frame to abort, it must be the value returned by raw_can_send |
int raw_can_free_frame | ( | can_rx_data_t * | frame | ) |
Free a received frame.
This function must be called by the user when a received frame is not needed anymore.
[in] | frame | the frame to free, it must be a pointer to a frame received by the stack |
int raw_can_get_can_opt | ( | int | ifnum, |
can_opt_t * | opt | ||
) |
Get a CAN option opt
from interface ifnum
.
[in] | ifnum | the interface number |
[in,out] | opt | the option to get |
candev_dev_t* raw_can_get_dev_by_ifnum | ( | int | ifnum | ) |
Get the candev descriptor from a given interface number.
[in] | ifnum | interface number |
int raw_can_get_ifnum_by_name | ( | const char * | name | ) |
Get the interface number of a given interface.
[in] | name | interface name |
const char* raw_can_get_name_by_ifnum | ( | int | ifnum | ) |
Get the interface name of a given interface number.
[in] | ifnum | interface number |
int raw_can_power_down | ( | int | ifnum | ) |
Power down a given interface.
[in] | ifnum | the interface number to power down |
int raw_can_power_up | ( | int | ifnum | ) |
Power up a given interface.
[in] | ifnum | the interface number to power up |
int raw_can_send | ( | int | ifnum, |
const struct can_frame * | frame, | ||
kernel_pid_t | pid | ||
) |
Send a CAN frame.
Send a CAN frame
through the ifnum
interface. The result is sent to the pid
thread via IPC.
[in] | ifnum | the interface number to send to |
[in] | frame | the frame to send |
[in] | pid | the user thread id to whom the result msg will be sent it can be THREAD_PID_UNDEF if no feedback is expected |
Send a CAN frame.
Send a CAN frame
through the ifnum
interface. The result is sent to the mbox
thread via mailbox IPC.
[in] | ifnum | the interface number to send to |
[in] | frame | the frame to send |
[in] | mbox | the user mbox to whom the result msg will be sent it can be NULL if no feedback is expected |
int raw_can_set_bitrate | ( | int | ifnum, |
uint32_t | bitrate, | ||
uint32_t | sample_point | ||
) |
Set the given bitrate/sample_point to the given ifnum.
Set the given bitrate
and sample_point
to the given ifnum
. This is a helper function which calculates the right bittiming from bitrate
and sample_point
.
[in] | ifnum | the interface number |
[in] | bitrate | the bitrate in bits/s |
[in] | sample_point | the sample point in tenth of percent (875 = 87.5%) if not set, the default value of 87.5% is used |
int raw_can_set_can_opt | ( | int | ifnum, |
can_opt_t * | opt | ||
) |
Set a CAN option opt
to interface ifnum
.
[in] | ifnum | the interface number |
[in,out] | opt | the option to set |
int raw_can_set_trx | ( | int | ifnum, |
can_trx_t * | trx | ||
) |
Set a transceiver for a given interface.
The interface must be powered down before changing the transceiver.
[in] | ifnum | the interface number |
[in] | trx | the transceiver to set |
int raw_can_subscribe_rx | ( | int | ifnum, |
struct can_filter * | filter, | ||
kernel_pid_t | pid, | ||
void * | param | ||
) |
Subscribe to a CAN filter.
This function must be called if a user thread pid
wants to receive the CAN frame matching filter
on the interface ifnum
. The user thread will then receive msg via IPC on reception of frame matching filters
.
[in] | ifnum | the interface number to listen |
[in] | filter | the list of filter to receive |
[in] | pid | the thread id of the user |
[in] | param | optional user parameter |
ifnum
on success int raw_can_subscribe_rx_mbox | ( | int | ifnum, |
struct can_filter * | filter, | ||
mbox_t * | mbox, | ||
void * | param | ||
) |
Subscribe to a CAN filter.
This function must be called if a user thread waiting on mbox
wants to receive the CAN frame matching filter
on the interface ifnum
. The user thread will then receive msg via mailbox IPC on reception of frame matching filters
.
Currently only single frame ID (i.e. filters->can_mask = 0xFFFFFFFF) are supported.
[in] | ifnum | the interface number to listen |
[in] | filter | the list of filter to receive |
[in] | mbox | the mbox of the user |
[in] | param | optional user parameter |
ifnum
on success int raw_can_unsubscribe_rx | ( | int | ifnum, |
struct can_filter * | filter, | ||
kernel_pid_t | pid, | ||
void * | param | ||
) |
Unsubscribe from reception for the given CAN filter
on pid
thread.
[in] | ifnum | the interface number |
[in] | filter | the filter to remove |
[in] | pid | the thread id of the user |
[in] | param | optional user parameter |
int raw_can_unsubscribe_rx_mbox | ( | int | ifnum, |
struct can_filter * | filter, | ||
mbox_t * | mbox, | ||
void * | param | ||
) |
Unsubscribe from reception for the given CAN filter
and mbox
.
[in] | ifnum | the interface number |
[in] | filter | the filter to remove |
[in] | mbox | the mbox of the user |
[in] | param | optional user parameter |