Lely core libraries
2.2.5
|
This header file is part of the I/O library; it contains the user-defined CAN channel declarations. More...
#include <lely/io2/can.h>
Go to the source code of this file.
Typedefs | |
typedef int | io_user_can_chan_write_t(const struct can_msg *msg, int timeout, void *arg) |
The type of function invoked by a user-defined CAN channel when a CAN frame needs to be written. More... | |
Functions | |
io_can_chan_t * | io_user_can_chan_create (io_ctx_t *ctx, ev_exec_t *exec, int flags, size_t rxlen, int txtimeo, io_user_can_chan_write_t *func, void *arg) |
Creates a new user-defined CAN channel. More... | |
void | io_user_can_chan_destroy (io_can_chan_t *chan) |
Destroys a user-defined CAN channel. More... | |
int | io_user_can_chan_on_msg (io_can_chan_t *chan, const struct can_msg *msg, const struct timespec *tp, int timeout) |
Processes an incoming CAN frame. More... | |
int | io_user_can_chan_on_err (io_can_chan_t *chan, const struct can_err *err, const struct timespec *tp, int timeout) |
Processes an incoming CAN error frame. More... | |
This header file is part of the I/O library; it contains the user-defined CAN channel declarations.
The user-defined CAN channel is a passive channel; it does not actively read CAN frames, but requires the user to notify it of incoming (error) frames with io_user_can_chan_on_msg() and io_user_can_chan_on_err(). A user-defined callback function is invoked when a CAN frame needs to be written.
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.h.
typedef int io_user_can_chan_write_t(const struct can_msg *msg, int timeout, void *arg) |
The type of function invoked by a user-defined CAN channel when a CAN frame needs to be written.
msg | a pointer to the CAN frame to be written. |
arg | the user-specific value submitted to io_user_can_chan_create(). |
timeout | the maximum number of milliseconds this function SHOULD block. If timeout is negative, this function SHOULD block indefinitely. |
io_can_chan_t* io_user_can_chan_create | ( | io_ctx_t * | ctx, |
ev_exec_t * | exec, | ||
int | flags, | ||
size_t | rxlen, | ||
int | txtimeo, | ||
io_user_can_chan_write_t * | func, | ||
void * | arg | ||
) |
Creates a new user-defined CAN channel.
ctx | a pointer to the I/O context with which the channel should be registered. |
exec | a pointer to the executor used to execute asynchronous tasks. |
flags | the flags specifying which CAN bus features MUST be enabled (any combination of IO_CAN_BUS_FLAG_ERR, IO_CAN_BUS_FLAG_FDF and IO_CAN_BUS_FLAG_BRS). |
rxlen | the receive queue length (in number of frames) of the channel. If rxlen is 0, the default value LELY_IO_USER_CAN_RXLEN is used. |
txtimeo | the timeout (in milliseconds) passed to func when writing a CAN frame asynchronously. If txtimeo is 0, the default value LELY_IO_TX_TIMEOUT is used. If txtimeo is negative, the write function will wait indefinitely. |
func | a pointer to the function to be invoked when a CAN frame needs to be written (can be NULL). |
arg | the user-specific value to be passed as the second argument to func. |
void io_user_can_chan_destroy | ( | io_can_chan_t * | chan | ) |
Destroys a user-defined CAN channel.
int io_user_can_chan_on_msg | ( | io_can_chan_t * | chan, |
const struct can_msg * | msg, | ||
const struct timespec * | tp, | ||
int | timeout | ||
) |
Processes an incoming CAN frame.
chan | a pointer to a user-defined CAN channel. |
msg | a pointer to the incoming CAN frame. |
tp | a pointer to the system time at which the CAN frame was received (can be NULL). |
timeout | the maximum number of milliseconds this function will block when the receive queue is full. If timeout is negative, this function will block indefinitely. |
int io_user_can_chan_on_err | ( | io_can_chan_t * | chan, |
const struct can_err * | err, | ||
const struct timespec * | tp, | ||
int | timeout | ||
) |
Processes an incoming CAN error frame.
chan | a pointer to a user-defined CAN channel. |
err | a pointer to the incoming CAN error frame. |
tp | a pointer to the system time at which the CAN error frame was received (can be NULL). |
timeout | the maximum number of milliseconds this function will block when the receive queue is full. If timeout is negative, this function will block indefinitely. |