Loading...
Searching...
No Matches

CAN memory allocation module. More...

Detailed Description

CAN memory allocation module.

Author
Vincent Dupont vince.nosp@m.nt@o.nosp@m.takey.nosp@m.s.co.nosp@m.m
Toon Stegen toon..nosp@m.steg.nosp@m.en@al.nosp@m.tran.nosp@m..com

Definition in file pkt.h.

#include <stdatomic.h>
#include "can/common.h"
#include "can/can.h"
#include "msg.h"
+ Include dependency graph for pkt.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  can_pkt_t
 A CAN packet. More...
 
void can_pkt_init (void)
 Initialize the CAN packet module.
 
can_pkt_tcan_pkt_alloc_tx (int ifnum, const struct can_frame *frame, kernel_pid_t tx_pid)
 Allocate a CAN packet to transmit.
 
can_pkt_tcan_pkt_alloc_rx (int ifnum, const struct can_frame *frame)
 Allocate an incoming CAN packet.
 
can_pkt_tcan_pkt_alloc_mbox_tx (int ifnum, const struct can_frame *frame, mbox_t *mbox)
 Allocate a CAN packet for a mbox to transmit.
 
void can_pkt_free (can_pkt_t *pkt)
 Free a CAN packet.
 
can_rx_data_tcan_pkt_alloc_rx_data (void *data, size_t len, void *arg)
 Allocate a can_rx_data_t and initialize it with gieven parameters.
 
void can_pkt_free_rx_data (can_rx_data_t *data)
 Free rx data previously allocated by can_pkt_alloc_rx_data()
 
void * can_pkt_buf_alloc (size_t size)
 Allocate size bytes and return the pointer.
 
void can_pkt_buf_free (void *data, size_t size)
 Free the data allocated by can_pkt_buf_alloc()
 

Function Documentation

◆ can_pkt_alloc_mbox_tx()

can_pkt_t * can_pkt_alloc_mbox_tx ( int  ifnum,
const struct can_frame frame,
mbox_t mbox 
)

Allocate a CAN packet for a mbox to transmit.

This function allocates a CAN packet and associate it to the ifnum and mbox. The provided frame is copied into the CAN packet and a unique handle is set.

Parameters
[in]ifnumthe interface number
[in]framethe frame to copy
[in]mboxthe pointer to the sender's mbox
Returns
an allocated CAN packet, NULL if an error occurred

◆ can_pkt_alloc_rx()

can_pkt_t * can_pkt_alloc_rx ( int  ifnum,
const struct can_frame frame 
)

Allocate an incoming CAN packet.

Parameters
[in]ifnumthe interface number
[in]framethe received frame
Returns
an allocated CAN packet, NULL if an error occurred

◆ can_pkt_alloc_rx_data()

can_rx_data_t * can_pkt_alloc_rx_data ( void *  data,
size_t  len,
void *  arg 
)

Allocate a can_rx_data_t and initialize it with gieven parameters.

This is used to allocate a return value to the upper layer

Parameters
[in]datadata which will be returned
[in]lenlength of data
[in]argoptional argument for the upper layer
Returns
a can_rx_data_t pointer, NULL if out of memory

◆ can_pkt_alloc_tx()

can_pkt_t * can_pkt_alloc_tx ( int  ifnum,
const struct can_frame frame,
kernel_pid_t  tx_pid 
)

Allocate a CAN packet to transmit.

This function allocates a CAN packet and associates it to the ifnum and tx_pid. The provided frame is copied into the CAN packet and a unique handle is set.

Parameters
[in]ifnumthe interface number
[in]framethe frame to copy
[in]tx_pidthe pid of the sender's device thread
Returns
an allocated CAN packet, NULL if an error occurred

◆ can_pkt_buf_alloc()

void * can_pkt_buf_alloc ( size_t  size)

Allocate size bytes and return the pointer.

This function has been copied from gnrc_pktbuf_static

Parameters
[in]sizethe number of bytes to allocate
Returns
the pointer to thje allocated data, NULL if out of memory

◆ can_pkt_buf_free()

void can_pkt_buf_free ( void *  data,
size_t  size 
)

Free the data allocated by can_pkt_buf_alloc()

Parameters
[in]datathe pointer to free
[in]sizethe size of the data to free

◆ can_pkt_free()

void can_pkt_free ( can_pkt_t pkt)

Free a CAN packet.

Parameters
[in]pktthe packet to free, it must be a pointer returned by can_pkt_alloc_tx or can_pkt_alloc_rx

◆ can_pkt_free_rx_data()

void can_pkt_free_rx_data ( can_rx_data_t data)

Free rx data previously allocated by can_pkt_alloc_rx_data()

Parameters
[in]datathe pointer to free

◆ can_pkt_init()

void can_pkt_init ( void  )

Initialize the CAN packet module.

This must be called by the DLL to initialize the module