Macros | Functions
socketcan.c File Reference
#include <net/if.h>
#include "socketcan.h"
#include <poll.h>
#include <string.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <linux/can.h>
#include <errno.h>
#include <stdlib.h>
Include dependency graph for socketcan.c:

Go to the source code of this file.

Macros

#define _GNU_SOURCE
 

Functions

static int16_t getErrorCode ()
 Returns the current errno as negated int16_t. More...
 
int16_t socketcanClose (SocketCANInstance *ins)
 
int socketcanGetSocketFileDescriptor (const SocketCANInstance *ins)
 
int16_t socketcanInit (SocketCANInstance *out_ins, const char *can_iface_name)
 
int16_t socketcanReceive (SocketCANInstance *ins, CanardCANFrame *out_frame, int32_t timeout_msec)
 
int16_t socketcanTransmit (SocketCANInstance *ins, const CanardCANFrame *frame, int32_t timeout_msec)
 

Macro Definition Documentation

◆ _GNU_SOURCE

#define _GNU_SOURCE

Definition at line 10 of file socketcan.c.

Function Documentation

◆ getErrorCode()

static int16_t getErrorCode ( )
static

Returns the current errno as negated int16_t.

Definition at line 24 of file socketcan.c.

◆ socketcanClose()

int16_t socketcanClose ( SocketCANInstance ins)

Deinitializes the SocketCAN instance. Returns 0 on success, negative on error.

Definition at line 89 of file socketcan.c.

◆ socketcanGetSocketFileDescriptor()

int socketcanGetSocketFileDescriptor ( const SocketCANInstance ins)

Returns the file descriptor of the CAN socket. Can be used for external IO multiplexing.

Definition at line 180 of file socketcan.c.

◆ socketcanInit()

int16_t socketcanInit ( SocketCANInstance out_ins,
const char *  can_iface_name 
)

Initializes the SocketCAN instance. Returns 0 on success, negative on error.

Definition at line 45 of file socketcan.c.

◆ socketcanReceive()

int16_t socketcanReceive ( SocketCANInstance ins,
CanardCANFrame *  out_frame,
int32_t  timeout_msec 
)

Receives a CanardCANFrame from the CAN socket. Use negative timeout to block infinitely. Returns 1 on successful reception, 0 on timeout, negative on error.

Definition at line 136 of file socketcan.c.

◆ socketcanTransmit()

int16_t socketcanTransmit ( SocketCANInstance ins,
const CanardCANFrame *  frame,
int32_t  timeout_msec 
)

Transmits a CanardCANFrame to the CAN socket. Use negative timeout to block infinitely. Returns 1 on successful transmission, 0 on timeout, negative on error.

Definition at line 96 of file socketcan.c.



uavcan_communicator
Author(s):
autogenerated on Fri Dec 13 2024 03:10:03