drivers: can: remove z prefix from public CAN API types

Remove the "z" prefix from the public CAN controller API types as this
makes them appear as internal APIs.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
This commit is contained in:
Henrik Brix Andersen 2022-08-11 15:31:59 +02:00 committed by Carles Cufí
commit 13c75417ba
28 changed files with 314 additions and 320 deletions

View file

@ -151,7 +151,7 @@ a mailbox. When a transmitting mailbox is assigned, sending cannot be canceled.
.. code-block:: C
struct zcan_frame frame = {
struct can_frame frame = {
.id_type = CAN_STANDARD_IDENTIFIER,
.rtr = CAN_DATAFRAME,
.id = 0x123,
@ -186,7 +186,7 @@ occurred. It does not block until the message is sent like the example above.
int send_function(const struct device *can_dev)
{
struct zcan_frame frame = {
struct can_frame frame = {
.id_type = CAN_EXTENDED_IDENTIFIER,
.rtr = CAN_DATAFRAME,
.id = 0x1234567,
@ -211,7 +211,7 @@ added.
.. code-block:: C
void rx_callback_function(const struct device *dev, struct zcan_frame *frame, void *user_data)
void rx_callback_function(const struct device *dev, struct can_frame *frame, void *user_data)
{
... do something with the frame ...
}
@ -226,7 +226,7 @@ The filter for this example is configured to match the identifier 0x123 exactly.
.. code-block:: C
const struct zcan_filter my_filter = {
const struct can_filter my_filter = {
.id_type = CAN_STANDARD_IDENTIFIER,
.rtr = CAN_DATAFRAME,
.id = 0x123,
@ -251,7 +251,7 @@ The filter for this example is configured to match the extended identifier
.. code-block:: C
const struct zcan_filter my_filter = {
const struct can_filter my_filter = {
.id_type = CAN_EXTENDED_IDENTIFIER,
.rtr = CAN_DATAFRAME,
.id = 0x1234567,
@ -259,7 +259,7 @@ The filter for this example is configured to match the extended identifier
.id_mask = CAN_EXT_ID_MASK
};
CAN_MSGQ_DEFINE(my_can_msgq, 2);
struct zcan_frame rx_frame;
struct can_frame rx_frame;
int filter_id;
const struct device *can_dev = DEVICE_DT_GET(DT_CHOSEN(zephyr_canbus));

View file

@ -17,7 +17,7 @@ LOG_MODULE_REGISTER(can_common, CONFIG_CAN_LOG_LEVEL);
/* CAN sync segment is always one time quantum */
#define CAN_SYNC_SEG 1
static void can_msgq_put(const struct device *dev, struct zcan_frame *frame, void *user_data)
static void can_msgq_put(const struct device *dev, struct can_frame *frame, void *user_data)
{
struct k_msgq *msgq = (struct k_msgq *)user_data;
int ret;
@ -33,7 +33,7 @@ static void can_msgq_put(const struct device *dev, struct zcan_frame *frame, voi
}
int z_impl_can_add_rx_filter_msgq(const struct device *dev, struct k_msgq *msgq,
const struct zcan_filter *filter)
const struct can_filter *filter)
{
const struct can_driver_api *api = dev->api;

View file

@ -164,12 +164,12 @@ static inline int z_vrfy_can_set_bitrate(const struct device *dev, uint32_t bitr
#include <syscalls/can_set_bitrate_mrsh.c>
static inline int z_vrfy_can_send(const struct device *dev,
const struct zcan_frame *frame,
const struct can_frame *frame,
k_timeout_t timeout,
can_tx_callback_t callback,
void *user_data)
{
struct zcan_frame frame_copy;
struct can_frame frame_copy;
Z_OOPS(Z_SYSCALL_DRIVER_CAN(dev, send));
Z_OOPS(z_user_from_copy(&frame_copy, frame, sizeof(frame_copy)));
@ -181,9 +181,9 @@ static inline int z_vrfy_can_send(const struct device *dev,
static inline int z_vrfy_can_add_rx_filter_msgq(const struct device *dev,
struct k_msgq *msgq,
const struct zcan_filter *filter)
const struct can_filter *filter)
{
struct zcan_filter filter_copy;
struct can_filter filter_copy;
Z_OOPS(Z_SYSCALL_DRIVER_CAN(dev, add_rx_filter));
Z_OOPS(Z_SYSCALL_OBJ(msgq, K_OBJ_MSGQ));

View file

@ -19,7 +19,7 @@
LOG_MODULE_REGISTER(can_loopback, CONFIG_CAN_LOG_LEVEL);
struct can_loopback_frame {
struct zcan_frame frame;
struct can_frame frame;
can_tx_callback_t cb;
void *cb_arg;
struct k_sem *tx_compl;
@ -28,7 +28,7 @@ struct can_loopback_frame {
struct can_loopback_filter {
can_rx_callback_t rx_cb;
void *cb_arg;
struct zcan_filter filter;
struct can_filter filter;
};
struct can_loopback_data {
@ -44,10 +44,10 @@ struct can_loopback_data {
};
static void dispatch_frame(const struct device *dev,
const struct zcan_frame *frame,
const struct can_frame *frame,
struct can_loopback_filter *filter)
{
struct zcan_frame frame_tmp = *frame;
struct can_frame frame_tmp = *frame;
LOG_DBG("Receiving %d bytes. Id: 0x%x, ID type: %s %s",
frame->dlc, frame->id,
@ -91,7 +91,7 @@ static void tx_thread(void *arg1, void *arg2, void *arg3)
}
static int can_loopback_send(const struct device *dev,
const struct zcan_frame *frame,
const struct can_frame *frame,
k_timeout_t timeout, can_tx_callback_t callback,
void *user_data)
{
@ -153,7 +153,7 @@ static inline int get_free_filter(struct can_loopback_filter *filters)
}
static int can_loopback_add_rx_filter(const struct device *dev, can_rx_callback_t cb,
void *cb_arg, const struct zcan_filter *filter)
void *cb_arg, const struct can_filter *filter)
{
struct can_loopback_data *data = dev->data;
struct can_loopback_filter *loopback_filter;

View file

@ -619,7 +619,7 @@ static void can_mcan_get_message(const struct device *dev,
{
struct can_mcan_data *data = dev->data;
uint32_t get_idx, filt_idx;
struct zcan_frame frame;
struct can_frame frame;
can_rx_callback_t cb;
int data_length;
void *cb_arg;
@ -781,7 +781,7 @@ int can_mcan_recover(const struct device *dev, k_timeout_t timeout)
int can_mcan_send(const struct device *dev,
const struct zcan_frame *frame,
const struct can_frame *frame,
k_timeout_t timeout,
can_tx_callback_t callback, void *user_data)
{
@ -902,7 +902,7 @@ int can_mcan_get_max_filters(const struct device *dev, enum can_ide id_type)
*/
int can_mcan_add_rx_filter_std(const struct device *dev,
can_rx_callback_t callback, void *user_data,
const struct zcan_filter *filter)
const struct can_filter *filter)
{
struct can_mcan_data *data = dev->data;
struct can_mcan_msg_sram *msg_ram = data->msg_ram;
@ -966,7 +966,7 @@ static int can_mcan_get_free_ext(volatile struct can_mcan_ext_filter *filters)
static int can_mcan_add_rx_filter_ext(const struct device *dev,
can_rx_callback_t callback, void *user_data,
const struct zcan_filter *filter)
const struct can_filter *filter)
{
struct can_mcan_data *data = dev->data;
struct can_mcan_msg_sram *msg_ram = data->msg_ram;
@ -1019,7 +1019,7 @@ static int can_mcan_add_rx_filter_ext(const struct device *dev,
int can_mcan_add_rx_filter(const struct device *dev,
can_rx_callback_t callback, void *user_data,
const struct zcan_filter *filter)
const struct can_filter *filter)
{
int filter_id;

View file

@ -275,7 +275,7 @@ void can_mcan_line_1_isr(const struct device *dev);
int can_mcan_recover(const struct device *dev, k_timeout_t timeout);
int can_mcan_send(const struct device *dev, const struct zcan_frame *frame,
int can_mcan_send(const struct device *dev, const struct can_frame *frame,
k_timeout_t timeout, can_tx_callback_t callback,
void *user_data);
@ -283,7 +283,7 @@ int can_mcan_get_max_filters(const struct device *dev, enum can_ide id_type);
int can_mcan_add_rx_filter(const struct device *dev,
can_rx_callback_t callback, void *user_data,
const struct zcan_filter *filter);
const struct can_filter *filter);
void can_mcan_remove_rx_filter(const struct device *dev, int filter_id);

View file

@ -209,7 +209,7 @@ static int mcp2515_cmd_read_rx_buffer(const struct device *dev, uint8_t nm,
return spi_transceive_dt(&dev_cfg->bus, &tx, &rx);
}
static void mcp2515_convert_zcanframe_to_mcp2515frame(const struct zcan_frame
static void mcp2515_convert_zcanframe_to_mcp2515frame(const struct can_frame
*source, uint8_t *target)
{
uint8_t rtr;
@ -241,7 +241,7 @@ static void mcp2515_convert_zcanframe_to_mcp2515frame(const struct zcan_frame
}
static void mcp2515_convert_mcp2515frame_to_zcanframe(const uint8_t *source,
struct zcan_frame *target)
struct can_frame *target)
{
uint8_t data_idx = 0U;
@ -499,7 +499,7 @@ done:
}
static int mcp2515_send(const struct device *dev,
const struct zcan_frame *frame,
const struct can_frame *frame,
k_timeout_t timeout, can_tx_callback_t callback,
void *user_data)
{
@ -564,7 +564,7 @@ static int mcp2515_send(const struct device *dev,
static int mcp2515_add_rx_filter(const struct device *dev,
can_rx_callback_t rx_cb,
void *cb_arg,
const struct zcan_filter *filter)
const struct can_filter *filter)
{
struct mcp2515_data *dev_data = dev->data;
int filter_id = 0;
@ -616,12 +616,12 @@ static void mcp2515_set_state_change_callback(const struct device *dev,
}
static void mcp2515_rx_filter(const struct device *dev,
struct zcan_frame *frame)
struct can_frame *frame)
{
struct mcp2515_data *dev_data = dev->data;
uint8_t filter_id = 0U;
can_rx_callback_t callback;
struct zcan_frame tmp_frame;
struct can_frame tmp_frame;
k_mutex_lock(&dev_data->mutex, K_FOREVER);
@ -649,7 +649,7 @@ static void mcp2515_rx(const struct device *dev, uint8_t rx_idx)
{
__ASSERT(rx_idx < MCP2515_RX_CNT, "rx_idx < MCP2515_RX_CNT");
struct zcan_frame frame;
struct can_frame frame;
uint8_t rx_frame[MCP2515_FRAME_LEN];
uint8_t nm;

View file

@ -38,7 +38,7 @@ struct mcp2515_data {
uint32_t filter_usage;
can_rx_callback_t rx_cb[CONFIG_CAN_MAX_FILTER];
void *cb_arg[CONFIG_CAN_MAX_FILTER];
struct zcan_filter filter[CONFIG_CAN_MAX_FILTER];
struct can_filter filter[CONFIG_CAN_MAX_FILTER];
can_state_change_callback_t state_change_cb;
void *state_change_cb_data;

View file

@ -247,7 +247,7 @@ static int mcux_flexcan_set_mode(const struct device *dev, can_mode_t mode)
return 0;
}
static void mcux_flexcan_copy_zframe_to_frame(const struct zcan_frame *src,
static void mcux_flexcan_copy_zframe_to_frame(const struct can_frame *src,
flexcan_frame_t *dest)
{
if (src->id_type == CAN_STANDARD_IDENTIFIER) {
@ -270,7 +270,7 @@ static void mcux_flexcan_copy_zframe_to_frame(const struct zcan_frame *src,
}
static void mcux_flexcan_copy_frame_to_zframe(const flexcan_frame_t *src,
struct zcan_frame *dest)
struct can_frame *dest)
{
if (src->format == kFLEXCAN_FrameFormatStandard) {
dest->id_type = CAN_STANDARD_IDENTIFIER;
@ -294,7 +294,7 @@ static void mcux_flexcan_copy_frame_to_zframe(const flexcan_frame_t *src,
#endif /* CAN_RX_TIMESTAMP */
}
static void mcux_flexcan_copy_zfilter_to_mbconfig(const struct zcan_filter *src,
static void mcux_flexcan_copy_zfilter_to_mbconfig(const struct can_filter *src,
flexcan_rx_mb_config_t *dest,
uint32_t *mask)
{
@ -345,7 +345,7 @@ static int mcux_flexcan_get_state(const struct device *dev, enum can_state *stat
}
static int mcux_flexcan_send(const struct device *dev,
const struct zcan_frame *frame,
const struct can_frame *frame,
k_timeout_t timeout,
can_tx_callback_t callback, void *user_data)
{
@ -400,7 +400,7 @@ static int mcux_flexcan_send(const struct device *dev,
static int mcux_flexcan_add_rx_filter(const struct device *dev,
can_rx_callback_t callback,
void *user_data,
const struct zcan_filter *filter)
const struct can_filter *filter)
{
const struct mcux_flexcan_config *config = dev->config;
struct mcux_flexcan_data *data = dev->data;
@ -627,7 +627,7 @@ static inline void mcux_flexcan_transfer_rx_idle(const struct device *dev,
struct mcux_flexcan_data *data = dev->data;
can_rx_callback_t function;
flexcan_mb_transfer_t xfer;
struct zcan_frame frame;
struct can_frame frame;
status_t status;
void *arg;
int alloc;

View file

@ -200,7 +200,7 @@ struct can_rcar_data {
struct k_mutex rx_mutex;
can_rx_callback_t rx_callback[CONFIG_CAN_RCAR_MAX_FILTER];
void *rx_callback_arg[CONFIG_CAN_RCAR_MAX_FILTER];
struct zcan_filter filter[CONFIG_CAN_RCAR_MAX_FILTER];
struct can_filter filter[CONFIG_CAN_RCAR_MAX_FILTER];
can_state_change_callback_t state_change_cb;
void *state_change_cb_data;
enum can_state state;
@ -366,9 +366,9 @@ static void can_rcar_error(const struct device *dev)
static void can_rcar_rx_filter_isr(const struct device *dev,
struct can_rcar_data *data,
const struct zcan_frame *frame)
const struct can_frame *frame)
{
struct zcan_frame tmp_frame;
struct can_frame tmp_frame;
uint8_t i;
for (i = 0; i < CONFIG_CAN_RCAR_MAX_FILTER; i++) {
@ -392,7 +392,7 @@ static void can_rcar_rx_isr(const struct device *dev)
{
const struct can_rcar_cfg *config = dev->config;
struct can_rcar_data *data = dev->data;
struct zcan_frame frame;
struct can_frame frame;
uint32_t val;
int i;
@ -782,7 +782,7 @@ done:
}
#endif /* CONFIG_CAN_AUTO_BUS_OFF_RECOVERY */
static int can_rcar_send(const struct device *dev, const struct zcan_frame *frame,
static int can_rcar_send(const struct device *dev, const struct can_frame *frame,
k_timeout_t timeout, can_tx_callback_t callback,
void *user_data)
{
@ -865,7 +865,7 @@ static int can_rcar_send(const struct device *dev, const struct zcan_frame *fram
static inline int can_rcar_add_rx_filter_unlocked(const struct device *dev,
can_rx_callback_t cb,
void *cb_arg,
const struct zcan_filter *filter)
const struct can_filter *filter)
{
struct can_rcar_data *data = dev->data;
int i;
@ -884,7 +884,7 @@ static inline int can_rcar_add_rx_filter_unlocked(const struct device *dev,
}
static int can_rcar_add_rx_filter(const struct device *dev, can_rx_callback_t cb,
void *cb_arg, const struct zcan_filter *filter)
void *cb_arg, const struct can_filter *filter)
{
struct can_rcar_data *data = dev->data;
int filter_id;

View file

@ -207,7 +207,7 @@ static inline int read_data(const struct shell *sh, int pos, char **argv,
return i;
}
static void print_frame(struct zcan_frame *frame, const struct shell *sh)
static void print_frame(struct can_frame *frame, const struct shell *sh)
{
shell_fprintf(sh, SHELL_NORMAL, "|0x%-8x|%s|%s|%d|",
frame->id,
@ -228,7 +228,7 @@ static void print_frame(struct zcan_frame *frame, const struct shell *sh)
static void msgq_triggered_work_handler(struct k_work *work)
{
struct zcan_frame frame;
struct can_frame frame;
int ret;
while (k_msgq_get(&msgq, &frame, K_NO_WAIT) == 0) {
@ -311,7 +311,7 @@ static int cmd_send(const struct shell *sh, size_t argc, char **argv)
const struct device *can_dev;
int pos = 1;
bool rtr = false, ext = false;
struct zcan_frame frame;
struct can_frame frame;
int ret;
uint32_t id;
@ -361,7 +361,7 @@ static int cmd_add_rx_filter(const struct shell *sh, size_t argc, char **argv)
const struct device *can_dev;
int pos = 1;
bool rtr = false, ext = false, rtr_mask = false;
struct zcan_filter filter;
struct can_filter filter;
int ret;
uint32_t id, mask;

View file

@ -207,7 +207,7 @@ unlock:
return err;
}
static void can_sja1000_read_frame(const struct device *dev, struct zcan_frame *frame)
static void can_sja1000_read_frame(const struct device *dev, struct can_frame *frame)
{
uint8_t info;
int i;
@ -257,7 +257,7 @@ static void can_sja1000_read_frame(const struct device *dev, struct zcan_frame *
}
}
void can_sja1000_write_frame(const struct device *dev, const struct zcan_frame *frame)
void can_sja1000_write_frame(const struct device *dev, const struct can_frame *frame)
{
uint8_t info;
int i;
@ -299,7 +299,7 @@ void can_sja1000_write_frame(const struct device *dev, const struct zcan_frame *
}
}
int can_sja1000_send(const struct device *dev, const struct zcan_frame *frame, k_timeout_t timeout,
int can_sja1000_send(const struct device *dev, const struct can_frame *frame, k_timeout_t timeout,
can_tx_callback_t callback, void *user_data)
{
struct can_sja1000_data *data = dev->data;
@ -352,7 +352,7 @@ int can_sja1000_send(const struct device *dev, const struct zcan_frame *frame, k
}
int can_sja1000_add_rx_filter(const struct device *dev, can_rx_callback_t callback, void *user_data,
const struct zcan_filter *filter)
const struct can_filter *filter)
{
struct can_sja1000_data *data = dev->data;
int filter_id = -ENOSPC;
@ -386,7 +386,7 @@ void can_sja1000_remove_rx_filter(const struct device *dev, int filter_id)
if (atomic_test_and_clear_bit(data->rx_allocs, filter_id)) {
data->filters[filter_id].callback = NULL;
data->filters[filter_id].user_data = NULL;
data->filters[filter_id].filter = (struct zcan_filter){0};
data->filters[filter_id].filter = (struct can_filter){0};
}
}
@ -479,7 +479,7 @@ int can_sja1000_get_max_bitrate(const struct device *dev, uint32_t *max_bitrate)
static void can_sja1000_handle_receive_irq(const struct device *dev)
{
struct can_sja1000_data *data = dev->data;
struct zcan_frame frame;
struct can_frame frame;
can_rx_callback_t callback;
uint8_t sr;
int i;

View file

@ -91,7 +91,7 @@ struct can_sja1000_config {
CAN_SJA1000_DT_CONFIG_GET(DT_DRV_INST(inst), _custom, _read_reg, _write_reg, _ocr, _cdr)
struct can_sja1000_rx_filter {
struct zcan_filter filter;
struct can_filter filter;
can_rx_callback_t callback;
void *user_data;
};
@ -124,11 +124,11 @@ int can_sja1000_get_capabilities(const struct device *dev, can_mode_t *cap);
int can_sja1000_set_mode(const struct device *dev, can_mode_t mode);
int can_sja1000_send(const struct device *dev, const struct zcan_frame *frame, k_timeout_t timeout,
int can_sja1000_send(const struct device *dev, const struct can_frame *frame, k_timeout_t timeout,
can_tx_callback_t callback, void *user_data);
int can_sja1000_add_rx_filter(const struct device *dev, can_rx_callback_t callback, void *user_data,
const struct zcan_filter *filter);
const struct can_filter *filter);
void can_sja1000_remove_rx_filter(const struct device *dev, int filter_id);

View file

@ -63,7 +63,7 @@ static void can_stm32_signal_tx_complete(const struct device *dev, struct can_st
}
}
static void can_stm32_rx_fifo_pop(CAN_FIFOMailBox_TypeDef *mbox, struct zcan_frame *frame)
static void can_stm32_rx_fifo_pop(CAN_FIFOMailBox_TypeDef *mbox, struct can_frame *frame)
{
if (mbox->RIR & CAN_RI0R_IDE) {
frame->id = mbox->RIR >> CAN_RI0R_EXID_Pos;
@ -89,7 +89,7 @@ static inline void can_stm32_rx_isr_handler(const struct device *dev)
CAN_TypeDef *can = cfg->can;
CAN_FIFOMailBox_TypeDef *mbox;
int filter_id, index;
struct zcan_frame frame;
struct can_frame frame;
can_rx_callback_t callback = NULL;
void *cb_arg;
@ -663,7 +663,7 @@ done:
#endif /* CONFIG_CAN_AUTO_BUS_OFF_RECOVERY */
static int can_stm32_send(const struct device *dev, const struct zcan_frame *frame,
static int can_stm32_send(const struct device *dev, const struct can_frame *frame,
k_timeout_t timeout, can_tx_callback_t callback,
void *user_data)
{
@ -776,35 +776,35 @@ static void can_stm32_set_filter_bank(int filter_id, CAN_FilterRegister_TypeDef
}
}
static inline uint32_t can_stm32_filter_to_std_mask(const struct zcan_filter *filter)
static inline uint32_t can_stm32_filter_to_std_mask(const struct can_filter *filter)
{
return (filter->id_mask << CAN_STM32_FIRX_STD_ID_POS) |
(filter->rtr_mask << CAN_STM32_FIRX_STD_RTR_POS) |
(1U << CAN_STM32_FIRX_STD_IDE_POS);
}
static inline uint32_t can_stm32_filter_to_ext_mask(const struct zcan_filter *filter)
static inline uint32_t can_stm32_filter_to_ext_mask(const struct can_filter *filter)
{
return (filter->id_mask << CAN_STM32_FIRX_EXT_EXT_ID_POS) |
(filter->rtr_mask << CAN_STM32_FIRX_EXT_RTR_POS) |
(1U << CAN_STM32_FIRX_EXT_IDE_POS);
}
static inline uint32_t can_stm32_filter_to_std_id(const struct zcan_filter *filter)
static inline uint32_t can_stm32_filter_to_std_id(const struct can_filter *filter)
{
return (filter->id << CAN_STM32_FIRX_STD_ID_POS) |
(filter->rtr << CAN_STM32_FIRX_STD_RTR_POS);
}
static inline uint32_t can_stm32_filter_to_ext_id(const struct zcan_filter *filter)
static inline uint32_t can_stm32_filter_to_ext_id(const struct can_filter *filter)
{
return (filter->id << CAN_STM32_FIRX_EXT_EXT_ID_POS) |
(filter->rtr << CAN_STM32_FIRX_EXT_RTR_POS) |
(1U << CAN_STM32_FIRX_EXT_IDE_POS);
}
static inline int can_stm32_set_filter(const struct device *dev, const struct zcan_filter *filter)
static inline int can_stm32_set_filter(const struct device *dev, const struct can_filter *filter)
{
const struct can_stm32_config *cfg = dev->config;
struct can_stm32_data *data = dev->data;
@ -875,7 +875,7 @@ static inline int can_stm32_set_filter(const struct device *dev, const struct zc
* Currently, all filter banks are assigned to FIFO 0 and FIFO 1 is not used.
*/
static int can_stm32_add_rx_filter(const struct device *dev, can_rx_callback_t cb,
void *cb_arg, const struct zcan_filter *filter)
void *cb_arg, const struct can_filter *filter)
{
struct can_stm32_data *data = dev->data;
int filter_id;

View file

@ -18,8 +18,8 @@
* @param filter CAN filter.
* @return true if the CAN filter matches the CAN frame, false otherwise
*/
static inline bool can_utils_filter_match(const struct zcan_frame *frame,
struct zcan_filter *filter)
static inline bool can_utils_filter_match(const struct can_frame *frame,
struct can_filter *filter)
{
if (frame->id_type != filter->id_type) {
return false;

View file

@ -27,7 +27,7 @@ struct net_canbus_config {
const struct device *can_dev;
};
static void net_canbus_recv(const struct device *dev, struct zcan_frame *frame, void *user_data)
static void net_canbus_recv(const struct device *dev, struct can_frame *frame, void *user_data)
{
struct net_canbus_context *ctx = user_data;
struct net_pkt *pkt;
@ -36,14 +36,14 @@ static void net_canbus_recv(const struct device *dev, struct zcan_frame *frame,
ARG_UNUSED(dev);
LOG_DBG("pkt on interface %p", ctx->iface);
pkt = net_pkt_rx_alloc_with_buffer(ctx->iface, sizeof(struct zcan_frame),
pkt = net_pkt_rx_alloc_with_buffer(ctx->iface, sizeof(struct can_frame),
AF_CAN, 0, K_NO_WAIT);
if (pkt == NULL) {
LOG_ERR("Failed to obtain net_pkt");
return;
}
if (net_pkt_write(pkt, frame, sizeof(struct zcan_frame))) {
if (net_pkt_write(pkt, frame, sizeof(struct can_frame))) {
LOG_ERR("Failed to append RX data");
net_pkt_unref(pkt);
return;
@ -69,7 +69,7 @@ static int net_canbus_setsockopt(const struct device *dev, void *obj, int level,
return -1;
}
__ASSERT_NO_MSG(optlen == sizeof(struct zcan_filter));
__ASSERT_NO_MSG(optlen == sizeof(struct can_filter));
ret = can_add_rx_filter(cfg->can_dev, net_canbus_recv, context, optval);
if (ret == -ENOSPC) {
@ -108,7 +108,7 @@ static int net_canbus_send(const struct device *dev, struct net_pkt *pkt)
return -EPFNOSUPPORT;
}
ret = can_send(cfg->can_dev, (struct zcan_frame *)pkt->frags->data,
ret = can_send(cfg->can_dev, (struct can_frame *)pkt->frags->data,
SEND_TIMEOUT, net_canbus_send_tx_callback, NULL);
if (ret == 0) {

View file

@ -143,7 +143,7 @@ enum can_rtr {
/**
* @brief CAN frame structure
*/
struct zcan_frame {
struct can_frame {
/** Standard (11-bit) or extended (29-bit) CAN identifier. */
uint32_t id : 29;
/** Frame is in the CAN-FD frame format if set to true. */
@ -184,7 +184,7 @@ struct zcan_frame {
/**
* @brief CAN filter structure
*/
struct zcan_filter {
struct can_filter {
/** CAN identifier to match. */
uint32_t id : 29;
/** @cond INTERNAL_HIDDEN */
@ -283,7 +283,7 @@ typedef void (*can_tx_callback_t)(const struct device *dev, int error, void *use
* @param frame Received frame.
* @param user_data User data provided when the filter was added.
*/
typedef void (*can_rx_callback_t)(const struct device *dev, struct zcan_frame *frame,
typedef void (*can_rx_callback_t)(const struct device *dev, struct can_frame *frame,
void *user_data);
/**
@ -336,7 +336,7 @@ typedef int (*can_set_mode_t)(const struct device *dev, can_mode_t mode);
* See @a can_send() for argument description
*/
typedef int (*can_send_t)(const struct device *dev,
const struct zcan_frame *frame,
const struct can_frame *frame,
k_timeout_t timeout, can_tx_callback_t callback,
void *user_data);
@ -347,7 +347,7 @@ typedef int (*can_send_t)(const struct device *dev,
typedef int (*can_add_rx_filter_t)(const struct device *dev,
can_rx_callback_t callback,
void *user_data,
const struct zcan_filter *filter);
const struct can_filter *filter);
/**
* @brief Callback API upon removing an RX filter
@ -1016,11 +1016,11 @@ __syscall int can_set_bitrate(const struct device *dev, uint32_t bitrate);
* automatic retransmissions are disabled).
* @retval -EAGAIN on timeout.
*/
__syscall int can_send(const struct device *dev, const struct zcan_frame *frame,
__syscall int can_send(const struct device *dev, const struct can_frame *frame,
k_timeout_t timeout, can_tx_callback_t callback,
void *user_data);
static inline int z_impl_can_send(const struct device *dev, const struct zcan_frame *frame,
static inline int z_impl_can_send(const struct device *dev, const struct can_frame *frame,
k_timeout_t timeout, can_tx_callback_t callback,
void *user_data)
{
@ -1053,13 +1053,13 @@ static inline int z_impl_can_send(const struct device *dev, const struct zcan_fr
* @param callback This function is called by the CAN controller driver whenever
* a frame matching the filter is received.
* @param user_data User data to pass to callback function.
* @param filter Pointer to a @a zcan_filter structure defining the filter.
* @param filter Pointer to a @a can_filter structure defining the filter.
*
* @retval filter_id on success.
* @retval -ENOSPC if there are no free filters.
*/
static inline int can_add_rx_filter(const struct device *dev, can_rx_callback_t callback,
void *user_data, const struct zcan_filter *filter)
void *user_data, const struct can_filter *filter)
{
const struct can_driver_api *api = (const struct can_driver_api *)dev->api;
@ -1077,7 +1077,7 @@ static inline int can_add_rx_filter(const struct device *dev, can_rx_callback_t
* @param max_frames Maximum number of CAN frames that can be queued.
*/
#define CAN_MSGQ_DEFINE(name, max_frames) \
K_MSGQ_DEFINE(name, sizeof(struct zcan_frame), max_frames, 4)
K_MSGQ_DEFINE(name, sizeof(struct can_frame), max_frames, 4)
/**
* @brief Wrapper function for adding a message queue for a given filter
@ -1095,13 +1095,13 @@ static inline int can_add_rx_filter(const struct device *dev, can_rx_callback_t
*
* @param dev Pointer to the device structure for the driver instance.
* @param msgq Pointer to the already initialized @a k_msgq struct.
* @param filter Pointer to a @a zcan_filter structure defining the filter.
* @param filter Pointer to a @a can_filter structure defining the filter.
*
* @retval filter_id on success.
* @retval -ENOSPC if there are no free filters.
*/
__syscall int can_add_rx_filter_msgq(const struct device *dev, struct k_msgq *msgq,
const struct zcan_filter *filter);
const struct can_filter *filter);
/**
* @brief Remove a CAN RX filter

View file

@ -117,13 +117,13 @@ struct socketcan_filter {
};
/**
* @brief Translate a @a socketcan_frame struct to a @a zcan_frame struct.
* @brief Translate a @a socketcan_frame struct to a @a can_frame struct.
*
* @param sframe Pointer to sockecan_frame struct.
* @param zframe Pointer to zcan_frame struct.
* @param zframe Pointer to can_frame struct.
*/
static inline void can_copy_frame_to_zframe(const struct socketcan_frame *sframe,
struct zcan_frame *zframe)
struct can_frame *zframe)
{
zframe->id_type = (sframe->can_id & BIT(31)) >> 31;
zframe->rtr = (sframe->can_id & BIT(30)) >> 30;
@ -133,12 +133,12 @@ static inline void can_copy_frame_to_zframe(const struct socketcan_frame *sframe
}
/**
* @brief Translate a @a zcan_frame struct to a @a socketcan_frame struct.
* @brief Translate a @a can_frame struct to a @a socketcan_frame struct.
*
* @param zframe Pointer to zcan_frame struct.
* @param zframe Pointer to can_frame struct.
* @param sframe Pointer to socketcan_frame struct.
*/
static inline void can_copy_zframe_to_frame(const struct zcan_frame *zframe,
static inline void can_copy_zframe_to_frame(const struct can_frame *zframe,
struct socketcan_frame *sframe)
{
sframe->can_id = (zframe->id_type << 31) | (zframe->rtr << 30) | zframe->id;
@ -147,13 +147,13 @@ static inline void can_copy_zframe_to_frame(const struct zcan_frame *zframe,
}
/**
* @brief Translate a @a socketcan_filter struct to a @a zcan_filter struct.
* @brief Translate a @a socketcan_filter struct to a @a can_filter struct.
*
* @param sfilter Pointer to socketcan_filter struct.
* @param zfilter Pointer to zcan_filter struct.
* @param zfilter Pointer to can_filter struct.
*/
static inline void can_copy_filter_to_zfilter(const struct socketcan_filter *sfilter,
struct zcan_filter *zfilter)
struct can_filter *zfilter)
{
zfilter->id_type = (sfilter->can_id & BIT(31)) >> 31;
zfilter->rtr = (sfilter->can_id & BIT(30)) >> 30;
@ -163,12 +163,12 @@ static inline void can_copy_filter_to_zfilter(const struct socketcan_filter *sfi
}
/**
* @brief Translate a @a zcan_filter struct to a @a socketcan_filter struct.
* @brief Translate a @a can_filter struct to a @a socketcan_filter struct.
*
* @param zfilter Pointer to zcan_filter struct.
* @param zfilter Pointer to can_filter struct.
* @param sfilter Pointer to socketcan_filter struct.
*/
static inline void can_copy_zfilter_to_filter(const struct zcan_filter *zfilter,
static inline void can_copy_zfilter_to_filter(const struct can_filter *zfilter,
struct socketcan_filter *sfilter)
{
sfilter->can_id = (zfilter->id_type << 31) |

View file

@ -78,7 +78,7 @@ static void canopen_detach_all_rx_filters(CO_CANmodule_t *CANmodule)
}
}
static void canopen_rx_callback(const struct device *dev, struct zcan_frame *msg, void *arg)
static void canopen_rx_callback(const struct device *dev, struct can_frame *frame, void *arg)
{
CO_CANrx_t *buffer = (CO_CANrx_t *)arg;
CO_CANrxMsg_t rxMsg;
@ -90,9 +90,9 @@ static void canopen_rx_callback(const struct device *dev, struct zcan_frame *msg
return;
}
rxMsg.ident = msg->id;
rxMsg.DLC = msg->dlc;
memcpy(rxMsg.data, msg->data, msg->dlc);
rxMsg.ident = frame->id;
rxMsg.DLC = frame->dlc;
memcpy(rxMsg.data, frame->data, frame->dlc);
buffer->pFunct(buffer->object, &rxMsg);
}
@ -119,7 +119,7 @@ static void canopen_tx_retry(struct k_work *item)
struct canopen_tx_work_container *container =
CONTAINER_OF(item, struct canopen_tx_work_container, work);
CO_CANmodule_t *CANmodule = container->CANmodule;
struct zcan_frame msg;
struct can_frame frame;
CO_CANtx_t *buffer;
int err;
uint16_t i;
@ -129,13 +129,13 @@ static void canopen_tx_retry(struct k_work *item)
for (i = 0; i < CANmodule->tx_size; i++) {
buffer = &CANmodule->tx_array[i];
if (buffer->bufferFull) {
msg.id_type = CAN_STANDARD_IDENTIFIER;
msg.id = buffer->ident;
msg.dlc = buffer->DLC;
msg.rtr = (buffer->rtr ? 1 : 0);
memcpy(msg.data, buffer->data, buffer->DLC);
frame.id_type = CAN_STANDARD_IDENTIFIER;
frame.id = buffer->ident;
frame.dlc = buffer->DLC;
frame.rtr = (buffer->rtr ? 1 : 0);
memcpy(frame.data, buffer->data, buffer->DLC);
err = can_send(CANmodule->dev, &msg, K_NO_WAIT,
err = can_send(CANmodule->dev, &frame, K_NO_WAIT,
canopen_tx_callback, CANmodule);
if (err == -EAGAIN) {
break;
@ -266,7 +266,7 @@ CO_ReturnError_t CO_CANrxBufferInit(CO_CANmodule_t *CANmodule, uint16_t index,
void *object,
CO_CANrxBufferCallback_t pFunct)
{
struct zcan_filter filter;
struct can_filter filter;
CO_CANrx_t *buffer;
if (CANmodule == NULL) {
@ -337,7 +337,7 @@ CO_CANtx_t *CO_CANtxBufferInit(CO_CANmodule_t *CANmodule, uint16_t index,
CO_ReturnError_t CO_CANsend(CO_CANmodule_t *CANmodule, CO_CANtx_t *buffer)
{
CO_ReturnError_t ret = CO_ERROR_NO;
struct zcan_frame msg;
struct can_frame frame;
int err;
if (!CANmodule || !CANmodule->dev || !buffer) {
@ -355,13 +355,13 @@ CO_ReturnError_t CO_CANsend(CO_CANmodule_t *CANmodule, CO_CANtx_t *buffer)
ret = CO_ERROR_TX_OVERFLOW;
}
msg.id_type = CAN_STANDARD_IDENTIFIER;
msg.id = buffer->ident;
msg.dlc = buffer->DLC;
msg.rtr = (buffer->rtr ? 1 : 0);
memcpy(msg.data, buffer->data, buffer->DLC);
frame.id_type = CAN_STANDARD_IDENTIFIER;
frame.id = buffer->ident;
frame.dlc = buffer->DLC;
frame.rtr = (buffer->rtr ? 1 : 0);
memcpy(frame.data, buffer->data, buffer->DLC);
err = can_send(CANmodule->dev, &msg, K_NO_WAIT, canopen_tx_callback,
err = can_send(CANmodule->dev, &frame, K_NO_WAIT, canopen_tx_callback,
CANmodule);
if (err == -EAGAIN) {
buffer->bufferFull = true;

View file

@ -60,35 +60,35 @@ void rx_thread(void *arg1, void *arg2, void *arg3)
ARG_UNUSED(arg1);
ARG_UNUSED(arg2);
ARG_UNUSED(arg3);
const struct zcan_filter filter = {
const struct can_filter filter = {
.id_type = CAN_EXTENDED_IDENTIFIER,
.rtr = CAN_DATAFRAME,
.id = COUNTER_MSG_ID,
.rtr_mask = 1,
.id_mask = CAN_EXT_ID_MASK
};
struct zcan_frame msg;
struct can_frame frame;
int filter_id;
filter_id = can_add_rx_filter_msgq(can_dev, &counter_msgq, &filter);
printk("Counter filter id: %d\n", filter_id);
while (1) {
k_msgq_get(&counter_msgq, &msg, K_FOREVER);
k_msgq_get(&counter_msgq, &frame, K_FOREVER);
if (msg.dlc != 2U) {
printk("Wrong data length: %u\n", msg.dlc);
if (frame.dlc != 2U) {
printk("Wrong data length: %u\n", frame.dlc);
continue;
}
printk("Counter received: %u\n",
sys_be16_to_cpu(UNALIGNED_GET((uint16_t *)&msg.data)));
sys_be16_to_cpu(UNALIGNED_GET((uint16_t *)&frame.data)));
}
}
void change_led_work_handler(struct k_work *work)
{
struct zcan_frame frame;
struct can_frame frame;
int ret;
while (k_msgq_get(&change_led_msgq, &frame, K_NO_WAIT) == 0) {
@ -189,20 +189,20 @@ void state_change_callback(const struct device *dev, enum can_state state,
void main(void)
{
const struct zcan_filter change_led_filter = {
const struct can_filter change_led_filter = {
.id_type = CAN_STANDARD_IDENTIFIER,
.rtr = CAN_DATAFRAME,
.id = LED_MSG_ID,
.rtr_mask = 1,
.id_mask = CAN_STD_ID_MASK
};
struct zcan_frame change_led_frame = {
struct can_frame change_led_frame = {
.id_type = CAN_STANDARD_IDENTIFIER,
.rtr = CAN_DATAFRAME,
.id = LED_MSG_ID,
.dlc = 1
};
struct zcan_frame counter_frame = {
struct can_frame counter_frame = {
.id_type = CAN_EXTENDED_IDENTIFIER,
.rtr = CAN_DATAFRAME,
.id = COUNTER_MSG_ID,

View file

@ -13,7 +13,7 @@ tests:
type: multi_line
ordered: True
regex:
- "(.*)\\[0\\] CAN msg: type 0x0 RTR 0x0 EID 0x1 DLC 0x8"
- "(.*)\\[0\\] CAN frame: type 0x0 RTR 0x0 EID 0x1 DLC 0x8"
- "(.*)f0 f1 f2 f3 f4 f5 f6 f7"
sample.net.sockets.can.two_sockets:
extra_configs:
@ -22,7 +22,7 @@ tests:
type: multi_line
ordered: True
regex:
- "(.*)\\[0\\] CAN msg: type 0x0 RTR 0x0 EID 0x1 DLC 0x8"
- "(.*)\\[0\\] CAN frame: type 0x0 RTR 0x0 EID 0x1 DLC 0x8"
- "(.*)f0 f1 f2 f3 f4 f5 f6 f7"
- "(.*)\\[1\\] CAN msg: type 0x0 RTR 0x0 EID 0x1 DLC 0x8"
- "(.*)\\[1\\] CAN frame: type 0x0 RTR 0x0 EID 0x1 DLC 0x8"
- "(.*)f0 f1 f2 f3 f4 f5 f6 f7"

View file

@ -33,7 +33,7 @@ static struct k_thread rx_data;
#define CLOSE_PERIOD 15
static const struct zcan_filter zfilter = {
static const struct can_filter zfilter = {
.id_type = CAN_STANDARD_IDENTIFIER,
.rtr = CAN_DATAFRAME,
.id = 0x1,
@ -46,27 +46,27 @@ static struct socketcan_filter sfilter;
static void tx(int *can_fd)
{
int fd = POINTER_TO_INT(can_fd);
struct zcan_frame msg = {0};
struct can_frame zframe = {0};
struct socketcan_frame sframe = {0};
int ret, i;
msg.dlc = 8U;
msg.id_type = CAN_STANDARD_IDENTIFIER;
msg.id = 0x1;
msg.rtr = CAN_DATAFRAME;
zframe.dlc = 8U;
zframe.id_type = CAN_STANDARD_IDENTIFIER;
zframe.id = 0x1;
zframe.rtr = CAN_DATAFRAME;
for (i = 0; i < msg.dlc; i++) {
msg.data[i] = 0xF0 | i;
for (i = 0; i < zframe.dlc; i++) {
zframe.data[i] = 0xF0 | i;
}
can_copy_zframe_to_frame(&msg, &sframe);
can_copy_zframe_to_frame(&zframe, &sframe);
LOG_DBG("Sending CAN data...");
while (1) {
ret = send(fd, &sframe, sizeof(sframe), 0);
if (ret < 0) {
LOG_ERR("Cannot send CAN message (%d)", -errno);
LOG_ERR("Cannot send CAN frame (%d)", -errno);
}
k_sleep(SLEEP_PERIOD);
@ -108,7 +108,7 @@ static void rx(int *can_fd, int *do_close_period,
int fd = POINTER_TO_INT(can_fd);
struct sockaddr_can can_addr;
socklen_t addr_len;
struct zcan_frame msg;
struct can_frame zframe;
struct socketcan_frame sframe;
int ret;
@ -123,26 +123,26 @@ static void rx(int *can_fd, int *do_close_period,
ret = recvfrom(fd, &sframe, sizeof(struct socketcan_frame),
0, (struct sockaddr *)&can_addr, &addr_len);
if (ret < 0) {
LOG_ERR("[%d] Cannot receive CAN message (%d)", fd,
LOG_ERR("[%d] Cannot receive CAN frame (%d)", fd,
-errno);
continue;
}
can_copy_frame_to_zframe(&sframe, &msg);
can_copy_frame_to_zframe(&sframe, &zframe);
LOG_INF("[%d] CAN msg: type 0x%x RTR 0x%x EID 0x%x DLC 0x%x",
fd, msg.id_type, msg.rtr, msg.id, msg.dlc);
LOG_INF("[%d] CAN frame: type 0x%x RTR 0x%x EID 0x%x DLC 0x%x",
fd, zframe.id_type, zframe.rtr, zframe.id, zframe.dlc);
if (!msg.rtr) {
if (msg.dlc > 8) {
data = (uint8_t *)msg.data_32;
if (!zframe.rtr) {
if (zframe.dlc > 8) {
data = (uint8_t *)zframe.data_32;
} else {
data = msg.data;
data = zframe.data;
}
LOG_HEXDUMP_INF(data, msg.dlc, "Data");
LOG_HEXDUMP_INF(data, zframe.dlc, "Data");
} else {
LOG_INF("[%d] EXT Remote message received", fd);
LOG_INF("[%d] EXT Remote frame received", fd);
}
if (POINTER_TO_INT(do_close_period) > 0) {
@ -228,14 +228,14 @@ static int setup_socket(void)
rx_fd = fd;
#if CONFIG_NET_SOCKETS_CAN_RECEIVERS == 2
fd = create_socket(&filter);
fd = create_socket(&sfilter);
if (fd >= 0) {
rx_tid = k_thread_create(&rx_data, rx_stack,
K_THREAD_STACK_SIZEOF(rx_stack),
(k_thread_entry_t)rx,
INT_TO_POINTER(fd),
INT_TO_POINTER(CLOSE_PERIOD),
&filter, PRIORITY, 0, K_NO_WAIT);
&sfilter, PRIORITY, 0, K_NO_WAIT);
if (!rx_tid) {
ret = -ENOENT;
errno = -ret;

View file

@ -118,7 +118,7 @@ static inline uint32_t receive_get_sf_length(struct net_buf *buf)
static void receive_send_fc(struct isotp_recv_ctx *ctx, uint8_t fs)
{
struct zcan_frame frame = {
struct can_frame frame = {
.id_type = ctx->tx_addr.id_type,
.rtr = CAN_DATAFRAME,
.id = ctx->tx_addr.ext_id
@ -375,7 +375,7 @@ static void receive_work_handler(struct k_work *item)
receive_state_machine(ctx);
}
static void process_ff_sf(struct isotp_recv_ctx *ctx, struct zcan_frame *frame)
static void process_ff_sf(struct isotp_recv_ctx *ctx, struct can_frame *frame)
{
int index = 0;
uint8_t payload_len;
@ -464,7 +464,7 @@ static inline void receive_add_mem(struct isotp_recv_ctx *ctx, uint8_t *data,
net_buf_add_mem(ctx->act_frag, data + tailroom, len - tailroom);
}
static void process_cf(struct isotp_recv_ctx *ctx, struct zcan_frame *frame)
static void process_cf(struct isotp_recv_ctx *ctx, struct can_frame *frame)
{
uint32_t *ud_rem_len = (uint32_t *)net_buf_user_data(ctx->buf);
int index = 0;
@ -527,7 +527,7 @@ static void process_cf(struct isotp_recv_ctx *ctx, struct zcan_frame *frame)
}
}
static void receive_can_rx(const struct device *dev, struct zcan_frame *frame, void *arg)
static void receive_can_rx(const struct device *dev, struct can_frame *frame, void *arg)
{
struct isotp_recv_ctx *ctx = (struct isotp_recv_ctx *)arg;
@ -570,7 +570,7 @@ static inline int attach_ff_filter(struct isotp_recv_ctx *ctx)
mask = CAN_EXT_ID_MASK;
}
struct zcan_filter filter = {
struct can_filter filter = {
.id_type = ctx->rx_addr.id_type,
.rtr = CAN_DATAFRAME,
.id = ctx->rx_addr.ext_id,
@ -761,7 +761,7 @@ static void send_timeout_handler(struct _timeout *to)
}
static void send_process_fc(struct isotp_send_ctx *ctx,
struct zcan_frame *frame)
struct can_frame *frame)
{
uint8_t *data = frame->data;
@ -822,7 +822,7 @@ static void send_process_fc(struct isotp_send_ctx *ctx,
}
}
static void send_can_rx_cb(const struct device *dev, struct zcan_frame *frame, void *arg)
static void send_can_rx_cb(const struct device *dev, struct can_frame *frame, void *arg)
{
struct isotp_send_ctx *ctx = (struct isotp_send_ctx *)arg;
@ -865,7 +865,7 @@ static void pull_data_ctx(struct isotp_send_ctx *ctx, size_t len)
static inline int send_sf(struct isotp_send_ctx *ctx)
{
struct zcan_frame frame = {
struct can_frame frame = {
.id_type = ctx->tx_addr.id_type,
.rtr = CAN_DATAFRAME,
.id = ctx->tx_addr.ext_id
@ -903,7 +903,7 @@ static inline int send_sf(struct isotp_send_ctx *ctx)
static inline int send_ff(struct isotp_send_ctx *ctx)
{
struct zcan_frame frame = {
struct can_frame frame = {
.id_type = ctx->tx_addr.id_type,
.rtr = CAN_DATAFRAME,
.id = ctx->tx_addr.ext_id,
@ -945,7 +945,7 @@ static inline int send_ff(struct isotp_send_ctx *ctx)
static inline int send_cf(struct isotp_send_ctx *ctx)
{
struct zcan_frame frame = {
struct can_frame frame = {
.id_type = ctx->tx_addr.id_type,
.rtr = CAN_DATAFRAME,
.id = ctx->tx_addr.ext_id,
@ -1128,7 +1128,7 @@ static void send_work_handler(struct k_work *item)
static inline int attach_fc_filter(struct isotp_send_ctx *ctx)
{
struct zcan_filter filter = {
struct can_filter filter = {
.id_type = ctx->rx_addr.id_type,
.rtr = CAN_DATAFRAME,
.id = ctx->rx_addr.ext_id,

View file

@ -100,8 +100,8 @@ static void zcan_received_cb(struct net_context *ctx, struct net_pkt *pkt,
int i;
for (i = 0; i < ARRAY_SIZE(receivers); i++) {
struct zcan_frame *zframe =
(struct zcan_frame *)net_pkt_data(pkt);
struct can_frame *zframe =
(struct can_frame *)net_pkt_data(pkt);
struct socketcan_frame sframe;
if (!receivers[i].ctx ||
@ -226,7 +226,7 @@ ssize_t zcan_sendto_ctx(struct net_context *ctx, const void *buf, size_t len,
socklen_t addrlen)
{
struct sockaddr_can can_addr;
struct zcan_frame zframe;
struct can_frame zframe;
k_timeout_t timeout = K_FOREVER;
int ret;
@ -276,7 +276,7 @@ static ssize_t zcan_recvfrom_ctx(struct net_context *ctx, void *buf,
struct sockaddr *src_addr,
socklen_t *addrlen)
{
struct zcan_frame zframe;
struct can_frame zframe;
size_t recv_len = 0;
k_timeout_t timeout = K_FOREVER;
struct net_pkt *pkt;
@ -672,7 +672,7 @@ static int can_sock_setsockopt_vmeth(void *obj, int level, int optname,
for (i = 0; i < count; i++) {
struct socketcan_filter *sfilter;
struct zcan_filter zfilter;
struct can_filter zfilter;
bool duplicate;
sfilter = &((struct socketcan_filter *)optval)[i];

View file

@ -59,7 +59,7 @@ CAN_MSGQ_DEFINE(can_msgq, 5);
/**
* @brief Standard (11-bit) CAN ID frame 1.
*/
const struct zcan_frame test_std_frame_1 = {
const struct can_frame test_std_frame_1 = {
.id_type = CAN_STANDARD_IDENTIFIER,
.rtr = CAN_DATAFRAME,
.id = TEST_CAN_STD_ID_1,
@ -70,7 +70,7 @@ const struct zcan_frame test_std_frame_1 = {
/**
* @brief Standard (11-bit) CAN ID frame 2.
*/
const struct zcan_frame test_std_frame_2 = {
const struct can_frame test_std_frame_2 = {
.id_type = CAN_STANDARD_IDENTIFIER,
.rtr = CAN_DATAFRAME,
.id = TEST_CAN_STD_ID_2,
@ -81,7 +81,7 @@ const struct zcan_frame test_std_frame_2 = {
/**
* @brief Extended (29-bit) CAN ID frame 1.
*/
const struct zcan_frame test_ext_frame_1 = {
const struct can_frame test_ext_frame_1 = {
.id_type = CAN_EXTENDED_IDENTIFIER,
.rtr = CAN_DATAFRAME,
.id = TEST_CAN_EXT_ID_1,
@ -92,7 +92,7 @@ const struct zcan_frame test_ext_frame_1 = {
/**
* @brief Extended (29-bit) CAN ID frame 1.
*/
const struct zcan_frame test_ext_frame_2 = {
const struct can_frame test_ext_frame_2 = {
.id_type = CAN_EXTENDED_IDENTIFIER,
.rtr = CAN_DATAFRAME,
.id = TEST_CAN_EXT_ID_2,
@ -103,7 +103,7 @@ const struct zcan_frame test_ext_frame_2 = {
/**
* @brief Standard (11-bit) CAN ID RTR frame 1.
*/
const struct zcan_frame test_std_rtr_frame_1 = {
const struct can_frame test_std_rtr_frame_1 = {
.id_type = CAN_STANDARD_IDENTIFIER,
.rtr = CAN_REMOTEREQUEST,
.id = TEST_CAN_STD_ID_1,
@ -114,7 +114,7 @@ const struct zcan_frame test_std_rtr_frame_1 = {
/**
* @brief Extended (29-bit) CAN ID RTR frame 1.
*/
const struct zcan_frame test_ext_rtr_frame_1 = {
const struct can_frame test_ext_rtr_frame_1 = {
.id_type = CAN_EXTENDED_IDENTIFIER,
.rtr = CAN_REMOTEREQUEST,
.id = TEST_CAN_EXT_ID_1,
@ -126,7 +126,7 @@ const struct zcan_frame test_ext_rtr_frame_1 = {
* @brief Standard (11-bit) CAN ID filter 1. This filter matches
* ``test_std_frame_1``.
*/
const struct zcan_filter test_std_filter_1 = {
const struct can_filter test_std_filter_1 = {
.id_type = CAN_STANDARD_IDENTIFIER,
.rtr = CAN_DATAFRAME,
.id = TEST_CAN_STD_ID_1,
@ -138,7 +138,7 @@ const struct zcan_filter test_std_filter_1 = {
* @brief Standard (11-bit) CAN ID filter 2. This filter matches
* ``test_std_frame_2``.
*/
const struct zcan_filter test_std_filter_2 = {
const struct can_filter test_std_filter_2 = {
.id_type = CAN_STANDARD_IDENTIFIER,
.rtr = CAN_DATAFRAME,
.id = TEST_CAN_STD_ID_2,
@ -150,7 +150,7 @@ const struct zcan_filter test_std_filter_2 = {
* @brief Standard (11-bit) CAN ID masked filter 1. This filter matches
* ``test_std_frame_1``.
*/
const struct zcan_filter test_std_masked_filter_1 = {
const struct can_filter test_std_masked_filter_1 = {
.id_type = CAN_STANDARD_IDENTIFIER,
.rtr = CAN_DATAFRAME,
.id = TEST_CAN_STD_MASK_ID_1,
@ -162,7 +162,7 @@ const struct zcan_filter test_std_masked_filter_1 = {
* @brief Standard (11-bit) CAN ID masked filter 2. This filter matches
* ``test_std_frame_2``.
*/
const struct zcan_filter test_std_masked_filter_2 = {
const struct can_filter test_std_masked_filter_2 = {
.id_type = CAN_STANDARD_IDENTIFIER,
.rtr = CAN_DATAFRAME,
.id = TEST_CAN_STD_MASK_ID_2,
@ -174,7 +174,7 @@ const struct zcan_filter test_std_masked_filter_2 = {
* @brief Extended (29-bit) CAN ID filter 1. This filter matches
* ``test_ext_frame_1``.
*/
const struct zcan_filter test_ext_filter_1 = {
const struct can_filter test_ext_filter_1 = {
.id_type = CAN_EXTENDED_IDENTIFIER,
.rtr = CAN_DATAFRAME,
.id = TEST_CAN_EXT_ID_1,
@ -186,7 +186,7 @@ const struct zcan_filter test_ext_filter_1 = {
* @brief Extended (29-bit) CAN ID filter 2. This filter matches
* ``test_ext_frame_2``.
*/
const struct zcan_filter test_ext_filter_2 = {
const struct can_filter test_ext_filter_2 = {
.id_type = CAN_EXTENDED_IDENTIFIER,
.rtr = CAN_DATAFRAME,
.id = TEST_CAN_EXT_ID_2,
@ -198,7 +198,7 @@ const struct zcan_filter test_ext_filter_2 = {
* @brief Extended (29-bit) CAN ID masked filter 1. This filter matches
* ``test_ext_frame_1``.
*/
const struct zcan_filter test_ext_masked_filter_1 = {
const struct can_filter test_ext_masked_filter_1 = {
.id_type = CAN_EXTENDED_IDENTIFIER,
.rtr = CAN_DATAFRAME,
.id = TEST_CAN_EXT_MASK_ID_1,
@ -210,7 +210,7 @@ const struct zcan_filter test_ext_masked_filter_1 = {
* @brief Extended (29-bit) CAN ID masked filter 2. This filter matches
* ``test_ext_frame_2``.
*/
const struct zcan_filter test_ext_masked_filter_2 = {
const struct can_filter test_ext_masked_filter_2 = {
.id_type = CAN_EXTENDED_IDENTIFIER,
.rtr = CAN_DATAFRAME,
.id = TEST_CAN_EXT_ID_1,
@ -222,7 +222,7 @@ const struct zcan_filter test_ext_masked_filter_2 = {
* @brief Standard (11-bit) CAN ID RTR filter 1. This filter matches
* ``test_std_rtr_frame_1``.
*/
const struct zcan_filter test_std_rtr_filter_1 = {
const struct can_filter test_std_rtr_filter_1 = {
.id_type = CAN_STANDARD_IDENTIFIER,
.rtr = CAN_REMOTEREQUEST,
.id = TEST_CAN_STD_ID_1,
@ -234,7 +234,7 @@ const struct zcan_filter test_std_rtr_filter_1 = {
* @brief Extended (29-bit) CAN ID RTR filter 1. This filter matches
* ``test_ext_rtr_frame_1``.
*/
const struct zcan_filter test_ext_rtr_filter_1 = {
const struct can_filter test_ext_rtr_filter_1 = {
.id_type = CAN_EXTENDED_IDENTIFIER,
.rtr = CAN_REMOTEREQUEST,
.id = TEST_CAN_EXT_ID_1,
@ -246,7 +246,7 @@ const struct zcan_filter test_ext_rtr_filter_1 = {
* @brief Standard (11-bit) CAN ID filter. This filter matches
* ``TEST_CAN_SOME_STD_ID``.
*/
const struct zcan_filter test_std_some_filter = {
const struct can_filter test_std_some_filter = {
.id_type = CAN_STANDARD_IDENTIFIER,
.rtr = CAN_DATAFRAME,
.id = TEST_CAN_SOME_STD_ID,
@ -261,8 +261,8 @@ const struct zcan_filter test_std_some_filter = {
* @param frame2 Second CAN frame.
* @param id_mask CAN ID mask.
*/
static inline void assert_frame_equal(const struct zcan_frame *frame1,
const struct zcan_frame *frame2,
static inline void assert_frame_equal(const struct can_frame *frame1,
const struct can_frame *frame2,
uint32_t id_mask)
{
zassert_equal(frame1->id_type, frame2->id_type, "ID type does not match");
@ -279,7 +279,7 @@ static inline void assert_frame_equal(const struct zcan_frame *frame1,
*/
static void tx_std_callback_1(const struct device *dev, int error, void *user_data)
{
const struct zcan_frame *frame = user_data;
const struct can_frame *frame = user_data;
k_sem_give(&tx_callback_sem);
@ -294,7 +294,7 @@ static void tx_std_callback_1(const struct device *dev, int error, void *user_da
*/
static void tx_std_callback_2(const struct device *dev, int error, void *user_data)
{
const struct zcan_frame *frame = user_data;
const struct can_frame *frame = user_data;
k_sem_give(&tx_callback_sem);
@ -309,7 +309,7 @@ static void tx_std_callback_2(const struct device *dev, int error, void *user_da
*/
static void tx_ext_callback_1(const struct device *dev, int error, void *user_data)
{
const struct zcan_frame *frame = user_data;
const struct can_frame *frame = user_data;
k_sem_give(&tx_callback_sem);
@ -324,7 +324,7 @@ static void tx_ext_callback_1(const struct device *dev, int error, void *user_da
*/
static void tx_ext_callback_2(const struct device *dev, int error, void *user_data)
{
const struct zcan_frame *frame = user_data;
const struct can_frame *frame = user_data;
k_sem_give(&tx_callback_sem);
@ -337,10 +337,10 @@ static void tx_ext_callback_2(const struct device *dev, int error, void *user_da
*
* See @a can_rx_callback_t() for argument description.
*/
static void rx_std_callback_1(const struct device *dev, struct zcan_frame *frame,
static void rx_std_callback_1(const struct device *dev, struct can_frame *frame,
void *user_data)
{
struct zcan_filter *filter = user_data;
struct can_filter *filter = user_data;
assert_frame_equal(frame, &test_std_frame_1, 0);
zassert_equal(dev, can_dev, "CAN device does not match");
@ -354,10 +354,10 @@ static void rx_std_callback_1(const struct device *dev, struct zcan_frame *frame
*
* See @a can_rx_callback_t() for argument description.
*/
static void rx_std_callback_2(const struct device *dev, struct zcan_frame *frame,
static void rx_std_callback_2(const struct device *dev, struct can_frame *frame,
void *user_data)
{
struct zcan_filter *filter = user_data;
struct can_filter *filter = user_data;
assert_frame_equal(frame, &test_std_frame_2, 0);
zassert_equal(dev, can_dev, "CAN device does not match");
@ -371,10 +371,10 @@ static void rx_std_callback_2(const struct device *dev, struct zcan_frame *frame
*
* See @a can_rx_callback_t() for argument description.
*/
static void rx_std_mask_callback_1(const struct device *dev, struct zcan_frame *frame,
static void rx_std_mask_callback_1(const struct device *dev, struct can_frame *frame,
void *user_data)
{
struct zcan_filter *filter = user_data;
struct can_filter *filter = user_data;
assert_frame_equal(frame, &test_std_frame_1, 0x0F);
zassert_equal(dev, can_dev, "CAN device does not match");
@ -388,10 +388,10 @@ static void rx_std_mask_callback_1(const struct device *dev, struct zcan_frame *
*
* See @a can_rx_callback_t() for argument description.
*/
static void rx_std_mask_callback_2(const struct device *dev, struct zcan_frame *frame,
static void rx_std_mask_callback_2(const struct device *dev, struct can_frame *frame,
void *user_data)
{
struct zcan_filter *filter = user_data;
struct can_filter *filter = user_data;
assert_frame_equal(frame, &test_std_frame_2, 0x0F);
zassert_equal(dev, can_dev, "CAN device does not match");
@ -405,10 +405,10 @@ static void rx_std_mask_callback_2(const struct device *dev, struct zcan_frame *
*
* See @a can_rx_callback_t() for argument description.
*/
static void rx_ext_callback_1(const struct device *dev, struct zcan_frame *frame,
static void rx_ext_callback_1(const struct device *dev, struct can_frame *frame,
void *user_data)
{
struct zcan_filter *filter = user_data;
struct can_filter *filter = user_data;
assert_frame_equal(frame, &test_ext_frame_1, 0);
zassert_equal(dev, can_dev, "CAN device does not match");
@ -422,10 +422,10 @@ static void rx_ext_callback_1(const struct device *dev, struct zcan_frame *frame
*
* See @a can_rx_callback_t() for argument description.
*/
static void rx_ext_callback_2(const struct device *dev, struct zcan_frame *frame,
static void rx_ext_callback_2(const struct device *dev, struct can_frame *frame,
void *user_data)
{
struct zcan_filter *filter = user_data;
struct can_filter *filter = user_data;
assert_frame_equal(frame, &test_ext_frame_2, 0);
zassert_equal(dev, can_dev, "CAN device does not match");
@ -439,10 +439,10 @@ static void rx_ext_callback_2(const struct device *dev, struct zcan_frame *frame
*
* See @a can_rx_callback_t() for argument description.
*/
static void rx_ext_mask_callback_1(const struct device *dev, struct zcan_frame *frame,
static void rx_ext_mask_callback_1(const struct device *dev, struct can_frame *frame,
void *user_data)
{
struct zcan_filter *filter = user_data;
struct can_filter *filter = user_data;
assert_frame_equal(frame, &test_ext_frame_1, 0x0F);
zassert_equal(dev, can_dev, "CAN device does not match");
@ -456,10 +456,10 @@ static void rx_ext_mask_callback_1(const struct device *dev, struct zcan_frame *
*
* See @a can_rx_callback_t() for argument description.
*/
static void rx_ext_mask_callback_2(const struct device *dev, struct zcan_frame *frame,
static void rx_ext_mask_callback_2(const struct device *dev, struct can_frame *frame,
void *user_data)
{
struct zcan_filter *filter = user_data;
struct can_filter *filter = user_data;
assert_frame_equal(frame, &test_ext_frame_2, 0x0F);
zassert_equal(dev, can_dev, "CAN device does not match");
@ -477,7 +477,7 @@ static void rx_ext_mask_callback_2(const struct device *dev, struct zcan_frame *
* @param dev Pointer to the device structure for the driver instance.
* @param frame Pointer to the CAN frame to send.
*/
static void send_test_frame(const struct device *dev, const struct zcan_frame *frame)
static void send_test_frame(const struct device *dev, const struct can_frame *frame)
{
int err;
@ -496,7 +496,7 @@ static void send_test_frame(const struct device *dev, const struct zcan_frame *f
* @param frame Pointer to the CAN frame to send.
* @param callback Transmit callback function.
*/
static void send_test_frame_nowait(const struct device *dev, const struct zcan_frame *frame,
static void send_test_frame_nowait(const struct device *dev, const struct can_frame *frame,
can_tx_callback_t callback)
{
int err;
@ -514,7 +514,7 @@ static void send_test_frame_nowait(const struct device *dev, const struct zcan_f
*
* @return CAN filter ID.
*/
static inline int add_rx_msgq(const struct device *dev, const struct zcan_filter *filter)
static inline int add_rx_msgq(const struct device *dev, const struct can_filter *filter)
{
int filter_id;
@ -535,7 +535,7 @@ static inline int add_rx_msgq(const struct device *dev, const struct zcan_filter
* @return CAN filter ID.
*/
static inline int add_rx_filter(const struct device *dev,
const struct zcan_filter *filter,
const struct can_filter *filter,
can_rx_callback_t callback)
{
int filter_id;
@ -557,12 +557,12 @@ static inline int add_rx_filter(const struct device *dev,
* @param frame1 CAN frame 1
* @param frame2 CAN frame 2
*/
static void send_receive(const struct zcan_filter *filter1,
const struct zcan_filter *filter2,
const struct zcan_frame *frame1,
const struct zcan_frame *frame2)
static void send_receive(const struct can_filter *filter1,
const struct can_filter *filter2,
const struct can_frame *frame1,
const struct can_frame *frame2)
{
struct zcan_frame frame_buffer;
struct can_frame frame_buffer;
uint32_t mask = 0U;
int filter_id_1;
int filter_id_2;
@ -640,12 +640,12 @@ static void send_receive(const struct zcan_filter *filter1,
* @param data_frame CAN data frame
* @param rtr_frame CAN RTR frame
*/
void send_receive_rtr(const struct zcan_filter *data_filter,
const struct zcan_filter *rtr_filter,
const struct zcan_frame *data_frame,
const struct zcan_frame *rtr_frame)
void send_receive_rtr(const struct can_filter *data_filter,
const struct can_filter *rtr_filter,
const struct can_frame *data_frame,
const struct can_frame *rtr_frame)
{
struct zcan_frame frame;
struct can_frame frame;
int filter_id;
int err;
@ -807,7 +807,7 @@ ZTEST(can_api, test_add_filter)
static void add_remove_max_filters(enum can_ide id_type)
{
uint32_t id_mask = id_type == CAN_STANDARD_IDENTIFIER ? CAN_STD_ID_MASK : CAN_EXT_ID_MASK;
struct zcan_filter filter = {
struct can_filter filter = {
.id_type = id_type,
.rtr = CAN_DATAFRAME,
.id = 0,
@ -866,7 +866,7 @@ ZTEST_USER(can_api, test_max_ext_filters)
*/
ZTEST_USER(can_api, test_receive_timeout)
{
struct zcan_frame frame;
struct can_frame frame;
int filter_id;
int err;
@ -935,7 +935,7 @@ ZTEST(can_api, test_send_receive_ext_id_masked)
ZTEST_USER(can_api, test_send_receive_msgq)
{
struct k_msgq_attrs attrs;
struct zcan_frame frame;
struct can_frame frame;
int filter_id;
int nframes;
int err;
@ -992,7 +992,7 @@ ZTEST_USER(can_api, test_send_receive_ext_id_rtr)
*/
ZTEST(can_api, test_send_receive_wrong_id)
{
struct zcan_frame frame_buffer;
struct can_frame frame_buffer;
int filter_id;
int err;
@ -1011,7 +1011,7 @@ ZTEST(can_api, test_send_receive_wrong_id)
*/
ZTEST_USER(can_api, test_send_invalid_dlc)
{
struct zcan_frame frame;
struct can_frame frame;
int err;
frame.dlc = CAN_MAX_DLC + 1;
@ -1054,7 +1054,7 @@ ZTEST_USER(can_api, test_get_state)
ZTEST_USER(can_api, test_filters_preserved_through_mode_change)
{
struct zcan_frame frame;
struct can_frame frame;
int filter_id;
int err;
@ -1082,7 +1082,7 @@ ZTEST_USER(can_api, test_filters_preserved_through_mode_change)
ZTEST_USER(can_api, test_filters_preserved_through_bitrate_change)
{
struct zcan_frame frame;
struct can_frame frame;
int filter_id;
int err;

View file

@ -40,7 +40,7 @@ CAN_MSGQ_DEFINE(can_msgq, 5);
/**
* @brief Standard (11-bit) CAN ID frame 1.
*/
const struct zcan_frame test_std_frame_1 = {
const struct can_frame test_std_frame_1 = {
.id_type = CAN_STANDARD_IDENTIFIER,
.rtr = CAN_DATAFRAME,
.id = TEST_CAN_STD_ID_1,
@ -51,7 +51,7 @@ const struct zcan_frame test_std_frame_1 = {
/**
* @brief Standard (11-bit) CAN ID frame 2.
*/
const struct zcan_frame test_std_frame_2 = {
const struct can_frame test_std_frame_2 = {
.id_type = CAN_STANDARD_IDENTIFIER,
.rtr = CAN_DATAFRAME,
.id = TEST_CAN_STD_ID_2,
@ -62,7 +62,7 @@ const struct zcan_frame test_std_frame_2 = {
/**
* @brief Standard (11-bit) CAN ID frame 1 with CAN-FD payload.
*/
const struct zcan_frame test_std_frame_fd_1 = {
const struct can_frame test_std_frame_fd_1 = {
.id = TEST_CAN_STD_ID_1,
.fd = 1,
.rtr = CAN_DATAFRAME,
@ -79,7 +79,7 @@ const struct zcan_frame test_std_frame_fd_1 = {
/**
* @brief Standard (11-bit) CAN ID frame 1 with CAN-FD payload.
*/
const struct zcan_frame test_std_frame_fd_2 = {
const struct can_frame test_std_frame_fd_2 = {
.id = TEST_CAN_STD_ID_2,
.fd = 1,
.rtr = CAN_DATAFRAME,
@ -96,7 +96,7 @@ const struct zcan_frame test_std_frame_fd_2 = {
/**
* @brief Standard (11-bit) CAN ID filter 1.
*/
const struct zcan_filter test_std_filter_1 = {
const struct can_filter test_std_filter_1 = {
.id_type = CAN_STANDARD_IDENTIFIER,
.rtr = CAN_DATAFRAME,
.id = TEST_CAN_STD_ID_1,
@ -107,7 +107,7 @@ const struct zcan_filter test_std_filter_1 = {
/**
* @brief Standard (11-bit) CAN ID filter 2.
*/
const struct zcan_filter test_std_filter_2 = {
const struct can_filter test_std_filter_2 = {
.id_type = CAN_STANDARD_IDENTIFIER,
.rtr = CAN_DATAFRAME,
.id = TEST_CAN_STD_ID_2,
@ -121,8 +121,8 @@ const struct zcan_filter test_std_filter_2 = {
* @param frame1 First CAN frame.
* @param frame2 Second CAN frame.
*/
static inline void assert_frame_equal(const struct zcan_frame *frame1,
const struct zcan_frame *frame2)
static inline void assert_frame_equal(const struct can_frame *frame1,
const struct can_frame *frame2)
{
zassert_equal(frame1->id_type, frame2->id_type, "ID type does not match");
zassert_equal(frame1->fd, frame2->fd, "FD bit does not match");
@ -134,7 +134,7 @@ static inline void assert_frame_equal(const struct zcan_frame *frame1,
static void tx_std_callback_1(const struct device *dev, int error, void *user_data)
{
const struct zcan_frame *frame = user_data;
const struct can_frame *frame = user_data;
k_sem_give(&tx_callback_sem);
@ -144,7 +144,7 @@ static void tx_std_callback_1(const struct device *dev, int error, void *user_da
static void tx_std_callback_2(const struct device *dev, int error, void *user_data)
{
const struct zcan_frame *frame = user_data;
const struct can_frame *frame = user_data;
k_sem_give(&tx_callback_sem);
@ -152,9 +152,9 @@ static void tx_std_callback_2(const struct device *dev, int error, void *user_da
zassert_equal(frame->id, TEST_CAN_STD_ID_2, "ID does not match");
}
static void rx_std_callback_1(const struct device *dev, struct zcan_frame *frame, void *user_data)
static void rx_std_callback_1(const struct device *dev, struct can_frame *frame, void *user_data)
{
struct zcan_filter *filter = user_data;
struct can_filter *filter = user_data;
assert_frame_equal(frame, &test_std_frame_1);
zassert_equal(dev, can_dev, "CAN device does not match");
@ -163,9 +163,9 @@ static void rx_std_callback_1(const struct device *dev, struct zcan_frame *frame
k_sem_give(&rx_callback_sem);
}
static void rx_std_callback_2(const struct device *dev, struct zcan_frame *frame, void *user_data)
static void rx_std_callback_2(const struct device *dev, struct can_frame *frame, void *user_data)
{
struct zcan_filter *filter = user_data;
struct can_filter *filter = user_data;
assert_frame_equal(frame, &test_std_frame_2);
zassert_equal(dev, can_dev, "CAN device does not match");
@ -174,10 +174,10 @@ static void rx_std_callback_2(const struct device *dev, struct zcan_frame *frame
k_sem_give(&rx_callback_sem);
}
static void rx_std_callback_fd_1(const struct device *dev, struct zcan_frame *frame,
static void rx_std_callback_fd_1(const struct device *dev, struct can_frame *frame,
void *user_data)
{
struct zcan_filter *filter = user_data;
struct can_filter *filter = user_data;
assert_frame_equal(frame, &test_std_frame_fd_1);
zassert_equal(dev, can_dev, "CAN device does not match");
@ -186,10 +186,10 @@ static void rx_std_callback_fd_1(const struct device *dev, struct zcan_frame *fr
k_sem_give(&rx_callback_sem);
}
static void rx_std_callback_fd_2(const struct device *dev, struct zcan_frame *frame,
static void rx_std_callback_fd_2(const struct device *dev, struct can_frame *frame,
void *user_data)
{
struct zcan_filter *filter = user_data;
struct can_filter *filter = user_data;
assert_frame_equal(frame, &test_std_frame_fd_2);
zassert_equal(dev, can_dev, "CAN device does not match");
@ -207,7 +207,7 @@ static void rx_std_callback_fd_2(const struct device *dev, struct zcan_frame *fr
* @param dev Pointer to the device structure for the driver instance.
* @param frame Pointer to the CAN frame to send.
*/
static void send_test_frame(const struct device *dev, const struct zcan_frame *frame)
static void send_test_frame(const struct device *dev, const struct can_frame *frame)
{
int err;
@ -226,7 +226,7 @@ static void send_test_frame(const struct device *dev, const struct zcan_frame *f
* @param frame Pointer to the CAN frame to send.
* @param callback Transmit callback function.
*/
static void send_test_frame_nowait(const struct device *dev, const struct zcan_frame *frame,
static void send_test_frame_nowait(const struct device *dev, const struct can_frame *frame,
can_tx_callback_t callback)
{
int err;
@ -244,7 +244,7 @@ static void send_test_frame_nowait(const struct device *dev, const struct zcan_f
*
* @return CAN filter ID.
*/
static inline int add_rx_msgq(const struct device *dev, const struct zcan_filter *filter)
static inline int add_rx_msgq(const struct device *dev, const struct can_filter *filter)
{
int filter_id;
@ -265,7 +265,7 @@ static inline int add_rx_msgq(const struct device *dev, const struct zcan_filter
* @return CAN filter ID.
*/
static inline int add_rx_filter(const struct device *dev,
const struct zcan_filter *filter,
const struct can_filter *filter,
can_rx_callback_t callback)
{
int filter_id;
@ -287,12 +287,12 @@ static inline int add_rx_filter(const struct device *dev,
* @param frame1 CAN frame 1
* @param frame2 CAN frame 2
*/
static void send_receive(const struct zcan_filter *filter1,
const struct zcan_filter *filter2,
const struct zcan_frame *frame1,
const struct zcan_frame *frame2)
static void send_receive(const struct can_filter *filter1,
const struct can_filter *filter2,
const struct can_frame *frame1,
const struct can_frame *frame2)
{
struct zcan_frame frame_buffer;
struct can_frame frame_buffer;
int filter_id_1;
int filter_id_2;
int err;

View file

@ -16,31 +16,31 @@ LOG_MODULE_REGISTER(socket_can, LOG_LEVEL_ERR);
*/
ZTEST(socket_can, test_can_frame_to_zcan_frame)
{
struct socketcan_frame frame = { 0 };
struct zcan_frame expected = { 0 };
struct zcan_frame msg;
struct socketcan_frame sframe = { 0 };
struct can_frame expected = { 0 };
struct can_frame zframe;
const uint8_t data[CAN_MAX_DLEN] = { 0x01, 0x02, 0x03, 0x04,
0x05, 0x06, 0x07, 0x08 };
frame.can_id = BIT(31) | BIT(30) | 1234;
frame.can_dlc = sizeof(data);
memcpy(frame.data, data, sizeof(frame.data));
sframe.can_id = BIT(31) | BIT(30) | 1234;
sframe.can_dlc = sizeof(data);
memcpy(sframe.data, data, sizeof(sframe.data));
expected.rtr = CAN_REMOTEREQUEST;
expected.id_type = CAN_EXTENDED_IDENTIFIER;
expected.id = 1234U;
expected.dlc = sizeof(data);
can_copy_frame_to_zframe(&frame, &msg);
can_copy_frame_to_zframe(&sframe, &zframe);
LOG_HEXDUMP_DBG((const uint8_t *)&frame, sizeof(frame), "frame");
LOG_HEXDUMP_DBG((const uint8_t *)&msg, sizeof(msg), "msg");
LOG_HEXDUMP_DBG((const uint8_t *)&sframe, sizeof(sframe), "sframe");
LOG_HEXDUMP_DBG((const uint8_t *)&zframe, sizeof(zframe), "zframe");
LOG_HEXDUMP_DBG((const uint8_t *)&expected, sizeof(expected), "expected");
zassert_equal(msg.rtr, expected.rtr, "RTR bit not set");
zassert_equal(msg.id_type, expected.id_type, "Id-type bit not set");
zassert_equal(msg.id, expected.id, "CAN id invalid");
zassert_equal(msg.dlc, expected.dlc, "Msg length invalid");
zassert_equal(zframe.rtr, expected.rtr, "RTR bit not set");
zassert_equal(zframe.id_type, expected.id_type, "Id-type bit not set");
zassert_equal(zframe.id, expected.id, "CAN id invalid");
zassert_equal(zframe.dlc, expected.dlc, "Msg length invalid");
}
/**
@ -48,9 +48,9 @@ ZTEST(socket_can, test_can_frame_to_zcan_frame)
*/
ZTEST(socket_can, test_zcan_frame_to_can_frame)
{
struct socketcan_frame frame = { 0 };
struct socketcan_frame sframe = { 0 };
struct socketcan_frame expected = { 0 };
struct zcan_frame msg = { 0 };
struct can_frame zframe = { 0 };
const uint8_t data[CAN_MAX_DLEN] = { 0x01, 0x02, 0x03, 0x04,
0x05, 0x06, 0x07, 0x08 };
@ -58,22 +58,22 @@ ZTEST(socket_can, test_zcan_frame_to_can_frame)
expected.can_dlc = sizeof(data);
memcpy(expected.data, data, sizeof(expected.data));
msg.rtr = CAN_REMOTEREQUEST;
msg.id_type = CAN_EXTENDED_IDENTIFIER;
msg.id = 1234U;
msg.dlc = sizeof(data);
memcpy(msg.data, data, sizeof(data));
zframe.rtr = CAN_REMOTEREQUEST;
zframe.id_type = CAN_EXTENDED_IDENTIFIER;
zframe.id = 1234U;
zframe.dlc = sizeof(data);
memcpy(zframe.data, data, sizeof(data));
can_copy_zframe_to_frame(&msg, &frame);
can_copy_zframe_to_frame(&zframe, &sframe);
LOG_HEXDUMP_DBG((const uint8_t *)&frame, sizeof(frame), "frame");
LOG_HEXDUMP_DBG((const uint8_t *)&msg, sizeof(msg), "msg");
LOG_HEXDUMP_DBG((const uint8_t *)&sframe, sizeof(sframe), "sframe");
LOG_HEXDUMP_DBG((const uint8_t *)&zframe, sizeof(zframe), "zframe");
LOG_HEXDUMP_DBG((const uint8_t *)&expected, sizeof(expected), "expected");
zassert_equal(frame.can_id, expected.can_id, "CAN ID not same");
zassert_mem_equal(&frame.data, &expected.data, sizeof(frame.data),
zassert_equal(sframe.can_id, expected.can_id, "CAN ID not same");
zassert_mem_equal(&sframe.data, &expected.data, sizeof(sframe.data),
"CAN data not same");
zassert_equal(frame.can_dlc, expected.can_dlc,
zassert_equal(sframe.can_dlc, expected.can_dlc,
"CAN msg length not same");
}
@ -82,12 +82,12 @@ ZTEST(socket_can, test_zcan_frame_to_can_frame)
*/
ZTEST(socket_can, test_can_filter_to_zcan_filter)
{
struct socketcan_filter filter = { 0 };
struct zcan_filter expected = { 0 };
struct zcan_filter msg_filter = { 0 };
struct socketcan_filter sfilter = { 0 };
struct can_filter expected = { 0 };
struct can_filter zfilter = { 0 };
filter.can_id = BIT(31) | BIT(30) | 1234;
filter.can_mask = BIT(31) | BIT(30) | 1234;
sfilter.can_id = BIT(31) | BIT(30) | 1234;
sfilter.can_mask = BIT(31) | BIT(30) | 1234;
expected.rtr = CAN_REMOTEREQUEST;
expected.id_type = CAN_EXTENDED_IDENTIFIER;
@ -95,22 +95,17 @@ ZTEST(socket_can, test_can_filter_to_zcan_filter)
expected.rtr_mask = 1U;
expected.id_mask = 1234U;
can_copy_filter_to_zfilter(&filter, &msg_filter);
can_copy_filter_to_zfilter(&sfilter, &zfilter);
LOG_HEXDUMP_DBG((const uint8_t *)&msg_filter, sizeof(msg_filter),
"msg_filter");
LOG_HEXDUMP_DBG((const uint8_t *)&filter, sizeof(filter), "filter");
LOG_HEXDUMP_DBG((const uint8_t *)&zfilter, sizeof(zfilter), "zfilter");
LOG_HEXDUMP_DBG((const uint8_t *)&sfilter, sizeof(sfilter), "sfilter");
LOG_HEXDUMP_DBG((const uint8_t *)&expected, sizeof(expected), "expected");
zassert_equal(msg_filter.rtr, expected.rtr, "RTR bit not set");
zassert_equal(msg_filter.id_type, expected.id_type,
"Id-type bit not set");
zassert_equal(msg_filter.id, expected.id,
"CAN id invalid");
zassert_equal(msg_filter.rtr_mask, expected.rtr_mask,
"RTR mask bit not set");
zassert_equal(msg_filter.id_mask, expected.id_mask,
"id mask not set");
zassert_equal(zfilter.rtr, expected.rtr, "RTR bit not set");
zassert_equal(zfilter.id_type, expected.id_type, "Id-type bit not set");
zassert_equal(zfilter.id, expected.id, "CAN id invalid");
zassert_equal(zfilter.rtr_mask, expected.rtr_mask, "RTR mask bit not set");
zassert_equal(zfilter.id_mask, expected.id_mask, "id mask not set");
}
/**
@ -118,28 +113,27 @@ ZTEST(socket_can, test_can_filter_to_zcan_filter)
*/
ZTEST(socket_can, test_zcan_filter_to_can_filter)
{
struct socketcan_filter filter = { 0 };
struct socketcan_filter sfilter = { 0 };
struct socketcan_filter expected = { 0 };
struct zcan_filter msg_filter = { 0 };
struct can_filter zfilter = { 0 };
expected.can_id = BIT(31) | BIT(30) | 1234;
expected.can_mask = BIT(31) | BIT(30) | 1234;
msg_filter.rtr = CAN_REMOTEREQUEST;
msg_filter.id_type = CAN_EXTENDED_IDENTIFIER;
msg_filter.id = 1234U;
msg_filter.rtr_mask = 1U;
msg_filter.id_mask = 1234U;
zfilter.rtr = CAN_REMOTEREQUEST;
zfilter.id_type = CAN_EXTENDED_IDENTIFIER;
zfilter.id = 1234U;
zfilter.rtr_mask = 1U;
zfilter.id_mask = 1234U;
can_copy_zfilter_to_filter(&msg_filter, &filter);
can_copy_zfilter_to_filter(&zfilter, &sfilter);
LOG_HEXDUMP_DBG((const uint8_t *)&msg_filter, sizeof(msg_filter),
"msg_filter");
LOG_HEXDUMP_DBG((const uint8_t *)&filter, sizeof(filter), "filter");
LOG_HEXDUMP_DBG((const uint8_t *)&zfilter, sizeof(zfilter), "zfilter");
LOG_HEXDUMP_DBG((const uint8_t *)&sfilter, sizeof(sfilter), "sfilter");
LOG_HEXDUMP_DBG((const uint8_t *)&expected, sizeof(expected), "expected");
zassert_equal(filter.can_id, expected.can_id, "CAN ID not same");
zassert_equal(filter.can_mask, expected.can_mask, "CAN mask not same");
zassert_equal(sfilter.can_id, expected.can_id, "CAN ID not same");
zassert_equal(sfilter.can_mask, expected.can_mask, "CAN mask not same");
}
ZTEST_SUITE(socket_can, NULL, NULL, NULL, NULL, NULL);

View file

@ -232,7 +232,7 @@ static void send_frame_series(struct frame_desired *frames, size_t length,
uint32_t id)
{
int i, ret;
struct zcan_frame frame = {
struct can_frame frame = {
.id_type = (id > 0x7FF) ? CAN_EXTENDED_IDENTIFIER :
CAN_STANDARD_IDENTIFIER,
.rtr = CAN_DATAFRAME,
@ -253,7 +253,7 @@ static void check_frame_series(struct frame_desired *frames, size_t length,
struct k_msgq *msgq)
{
int i, ret;
struct zcan_frame frame;
struct can_frame frame;
struct frame_desired *desired = frames;
for (i = 0; i < length; i++) {
@ -282,7 +282,7 @@ static void check_frame_series(struct frame_desired *frames, size_t length,
static int add_rx_msgq(uint32_t id, uint32_t mask)
{
int filter_id;
struct zcan_filter filter = {
struct can_filter filter = {
.id_type = (id > 0x7FF) ? CAN_EXTENDED_IDENTIFIER :
CAN_STANDARD_IDENTIFIER,
.rtr = CAN_DATAFRAME,
@ -529,7 +529,7 @@ ZTEST(isotp_conformance, test_send_data_blocks)
size_t remaining_length = DATA_SEND_LENGTH;
struct frame_desired *data_frame_ptr = des_frames;
int filter_id, ret;
struct zcan_frame dummy_frame;
struct can_frame dummy_frame;
struct frame_desired fc_frame, ff_frame;
ff_frame.data[0] = FF_PCI_BYTE_1(DATA_SEND_LENGTH);
@ -637,7 +637,7 @@ ZTEST(isotp_conformance, test_receive_data_blocks)
size_t remaining_frames;
struct frame_desired fc_frame, ff_frame;
struct zcan_frame dummy_frame;
struct can_frame dummy_frame;
ff_frame.data[0] = FF_PCI_BYTE_1(DATA_SEND_LENGTH);
ff_frame.data[1] = FF_PCI_BYTE_2(DATA_SEND_LENGTH);
@ -790,7 +790,7 @@ ZTEST(isotp_conformance, test_stmin)
{
int filter_id, ret;
struct frame_desired fc_frame, ff_frame;
struct zcan_frame raw_frame;
struct can_frame raw_frame;
uint32_t start_time, time_diff;
ff_frame.data[0] = FF_PCI_BYTE_1(DATA_SIZE_FF + DATA_SIZE_CF * 4);