Lely core libraries 2.3.4
|
This file is part of the I/O library; it contains the implementation of the CAN network interface. More...
#include "io2.h"
#include <lely/can/net.h>
#include <lely/io2/can_net.h>
#include <lely/io2/ctx.h>
#include <lely/libc/stdlib.h>
#include <lely/libc/threads.h>
#include <lely/util/diag.h>
#include <lely/util/spscring.h>
#include <lely/util/time.h>
#include <lely/util/util.h>
#include <assert.h>
Go to the source code of this file.
Data Structures | |
struct | io_can_net |
The implementation of a CAN network interface. More... | |
Functions | |
io_can_net_t * | io_can_net_create (ev_exec_t *exec, io_timer_t *timer, io_can_chan_t *chan, size_t txlen, int txtimeo) |
Creates a new CAN network interface. | |
void | io_can_net_destroy (io_can_net_t *net) |
Destroys a CAN network interface. | |
void | io_can_net_start (io_can_net_t *net) |
Starts a CAN network interface and begins processing CAN frames. | |
io_ctx_t * | io_can_net_get_ctx (const io_can_net_t *net) |
Returns a pointer to the I/O context with which the CAN network interface is registered. | |
ev_exec_t * | io_can_net_get_exec (const io_can_net_t *net) |
Returns a pointer to the executor used by the CAN network interface to execute asynchronous tasks. | |
io_clock_t * | io_can_net_get_clock (const io_can_net_t *net) |
Returns a pointer to the clock used by the CAN network interface. | |
io_tqueue_t * | io_can_net_get_tqueue (const io_can_net_t *net) |
Returns a pointer to the internal timer queue of a CAN network interface. | |
void | io_can_net_get_on_read_error_func (const io_can_net_t *net, io_can_net_on_error_func_t **pfunc, void **parg) |
Retrieves the function invoked when a new CAN frame read error occurs, or when a read operation completes successfully after one or more errors. | |
void | io_can_net_set_on_read_error_func (io_can_net_t *net, io_can_net_on_error_func_t *func, void *arg) |
Sets the function invoked when a new CAN frame read error occurs, or when a read operation completes successfully after one or more errors. | |
void | io_can_net_get_on_queue_error_func (const io_can_net_t *net, io_can_net_on_error_func_t **pfunc, void **parg) |
Retrieves the function invoked when a CAN frame is dropped because the transmit queue is full, or when a frame is successfully queued after one or more errors. | |
void | io_can_net_set_on_queue_error_func (io_can_net_t *net, io_can_net_on_error_func_t *func, void *arg) |
Sets the function invoked when a CAN frame is dropped because the transmit queue is full, or when a frame is successfully queued after one or more errors. | |
void | io_can_net_get_on_write_error_func (const io_can_net_t *net, io_can_net_on_error_func_t **pfunc, void **parg) |
Retrieves the function invoked when a new CAN frame write error occurs, or when a write operation completes successfully after one or more errors. | |
void | io_can_net_set_on_write_error_func (io_can_net_t *net, io_can_net_on_error_func_t *func, void *arg) |
Sets the function invoked when a new CAN frame write error occurs, or when a write operation completes successfully after one or more errors. | |
void | io_can_net_get_on_can_state_func (const io_can_net_t *net, io_can_net_on_can_state_func_t **pfunc, void **parg) |
Retrieves the function invoked when a CAN bus state change is detected. | |
void | io_can_net_set_on_can_state_func (io_can_net_t *net, io_can_net_on_can_state_func_t *func, void *arg) |
Sets the function to be invoked when a CAN bus state change is detected. | |
void | io_can_net_get_on_can_error_func (const io_can_net_t *net, io_can_net_on_can_error_func_t **pfunc, void **parg) |
Retrieves the function invoked when a CAN bus error is detected. | |
void | io_can_net_set_on_can_error_func (io_can_net_t *net, io_can_net_on_can_error_func_t *func, void *arg) |
Sets the function to be invoked when a CAN bus error is detected. | |
int | io_can_net_lock (io_can_net_t *net) |
Locks the mutex protecting the CAN network interface. | |
int | io_can_net_unlock (io_can_net_t *net) |
Unlocks the mutex protecting the CAN network interface. | |
can_net_t * | io_can_net_get_net (const io_can_net_t *net) |
Returns a pointer to the internal interface of a CAN network interface. | |
int | io_can_net_set_time (io_can_net_t *net) |
Updates the CAN network time. | |
This file is part of the I/O library; it contains the implementation of the CAN network interface.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Definition in file can_net.c.
io_can_net_t * io_can_net_create | ( | ev_exec_t * | exec, |
io_timer_t * | timer, | ||
io_can_chan_t * | chan, | ||
size_t | txlen, | ||
int | txtimeo | ||
) |
Creates a new CAN network interface.
exec | a pointer to the executor used to execute asynchronous tasks. If exec is NULL, the CAN channel executor is used. |
timer | a pointer to a timer. This timer MUST NOT be used for any other purpose. |
chan | a pointer to a CAN channel. This channel MUST NOT be used for any other purpose. |
txlen | the length (in number of frames) of the user-space transmit queue length. If txlen is 0, the default value LELY_IO_CAN_NET_TXLEN is used. |
txtimeo | the timeout (in milliseconds) when waiting for a CAN frame write confirmation. If txtimeo is 0, the default value #LELY_IO_CAN_CTX_TXTIMEO is used. If txtimeo is negative. the timeout is disabled. |
void io_can_net_start | ( | io_can_net_t * | net | ) |
void io_can_net_get_on_read_error_func | ( | const io_can_net_t * | net, |
io_can_net_on_error_func_t ** | pfunc, | ||
void ** | parg | ||
) |
Retrieves the function invoked when a new CAN frame read error occurs, or when a read operation completes successfully after one or more errors.
net | a pointer to a CAN network interface. |
pfunc | the address at which to store a pointer to the function (can be NULL). |
parg | the address at which to store the user-specified argument (can be NULL). |
void io_can_net_set_on_read_error_func | ( | io_can_net_t * | net, |
io_can_net_on_error_func_t * | func, | ||
void * | arg | ||
) |
Sets the function invoked when a new CAN frame read error occurs, or when a read operation completes successfully after one or more errors.
net | a pointer to a CAN network interface. |
func | a pointer to the function to be invoked. If func is NULL, the default implementation will be used. |
arg | the user-specified argument (can be NULL). arg is passed as the last argument to func. |
void io_can_net_get_on_queue_error_func | ( | const io_can_net_t * | net, |
io_can_net_on_error_func_t ** | pfunc, | ||
void ** | parg | ||
) |
Retrieves the function invoked when a CAN frame is dropped because the transmit queue is full, or when a frame is successfully queued after one or more errors.
net | a pointer to a CAN network interface. |
pfunc | the address at which to store a pointer to the function (can be NULL). |
parg | the address at which to store the user-specified argument (can be NULL). |
void io_can_net_set_on_queue_error_func | ( | io_can_net_t * | net, |
io_can_net_on_error_func_t * | func, | ||
void * | arg | ||
) |
Sets the function invoked when a CAN frame is dropped because the transmit queue is full, or when a frame is successfully queued after one or more errors.
net | a pointer to a CAN network interface. |
func | a pointer to the function to be invoked. If func is NULL, the default implementation will be used. |
arg | the user-specified argument (can be NULL). arg is passed as the last argument to func. |
void io_can_net_get_on_write_error_func | ( | const io_can_net_t * | net, |
io_can_net_on_error_func_t ** | pfunc, | ||
void ** | parg | ||
) |
Retrieves the function invoked when a new CAN frame write error occurs, or when a write operation completes successfully after one or more errors.
net | a pointer to a CAN network interface. |
pfunc | the address at which to store a pointer to the function (can be NULL). |
parg | the address at which to store the user-specified argument (can be NULL). |
void io_can_net_set_on_write_error_func | ( | io_can_net_t * | net, |
io_can_net_on_error_func_t * | func, | ||
void * | arg | ||
) |
Sets the function invoked when a new CAN frame write error occurs, or when a write operation completes successfully after one or more errors.
net | a pointer to a CAN network interface. |
func | a pointer to the function to be invoked. If func is NULL, the default implementation will be used. |
arg | the user-specified argument (can be NULL). arg is passed as the last argument to func. |
void io_can_net_get_on_can_state_func | ( | const io_can_net_t * | net, |
io_can_net_on_can_state_func_t ** | pfunc, | ||
void ** | parg | ||
) |
Retrieves the function invoked when a CAN bus state change is detected.
net | a pointer to a CAN network interface. |
pfunc | the address at which to store a pointer to the function (can be NULL). |
parg | the address at which to store the user-specified argument (can be NULL). |
void io_can_net_set_on_can_state_func | ( | io_can_net_t * | net, |
io_can_net_on_can_state_func_t * | func, | ||
void * | arg | ||
) |
Sets the function to be invoked when a CAN bus state change is detected.
net | a pointer to a CAN network interface. |
func | a pointer to the function to be invoked. If func is NULL, the default implementation will be used. |
arg | the user-specified argument (can be NULL). arg is passed as the last argument to func. |
void io_can_net_get_on_can_error_func | ( | const io_can_net_t * | net, |
io_can_net_on_can_error_func_t ** | pfunc, | ||
void ** | parg | ||
) |
Retrieves the function invoked when a CAN bus error is detected.
net | a pointer to a CAN network interface. |
pfunc | the address at which to store a pointer to the function (can be NULL). |
parg | the address at which to store the user-specified argument (can be NULL). |
void io_can_net_set_on_can_error_func | ( | io_can_net_t * | net, |
io_can_net_on_can_error_func_t * | func, | ||
void * | arg | ||
) |
Sets the function to be invoked when a CAN bus error is detected.
net | a pointer to a CAN network interface. |
func | a pointer to the function to be invoked. If func is NULL, the default implementation will be used. |
arg | the user-specified argument (can be NULL). arg is passed as the last argument to func. |
int io_can_net_lock | ( | io_can_net_t * | net | ) |
Locks the mutex protecting the CAN network interface.
int io_can_net_unlock | ( | io_can_net_t * | net | ) |
Unlocks the mutex protecting the CAN network interface.
can_net_t * io_can_net_get_net | ( | const io_can_net_t * | net | ) |
Returns a pointer to the internal interface of a CAN network interface.
The mutex protecting the CAN network interface MUST be locked when using the internal interface.
int io_can_net_set_time | ( | io_can_net_t * | net | ) |
Updates the CAN network time.
The mutex protecting the CAN network interface MUST be locked for the duration of this call.