Lely core libraries
2.3.4
|
This file is part of the I/O library; it contains the implementation of the CAN frame router. More...
#include "io2.h"
#include <lely/libc/threads.h>
#include <lely/ev/exec.h>
#include <lely/ev/strand.h>
#include <lely/io2/can_rt.h>
#include <lely/io2/ctx.h>
#include <lely/util/errnum.h>
#include <lely/util/util.h>
#include <assert.h>
#include <stdlib.h>
Go to the source code of this file.
Data Structures | |
struct | io_can_rt |
struct | io_can_rt_async_read_msg |
struct | io_can_rt_async_read_err |
struct | io_can_rt_async_shutdown |
Functions | |
io_can_rt_t * | io_can_rt_create (io_can_chan_t *chan, ev_exec_t *exec) |
Creates a new CAN frame router. More... | |
void | io_can_rt_destroy (io_can_rt_t *rt) |
Destroys a CAN frame router. More... | |
io_dev_t * | io_can_rt_get_dev (const io_can_rt_t *rt) |
Returns a pointer to the abstract I/O device representing the CAN frame router. | |
io_can_chan_t * | io_can_rt_get_chan (const io_can_rt_t *rt) |
Returns a pointer to the CAN channel used by the CAN frame router. | |
void | io_can_rt_submit_read_msg (io_can_rt_t *rt, struct io_can_rt_read_msg *read_msg) |
Submits a CAN frame read operation to a CAN frame router. More... | |
size_t | io_can_rt_cancel_read_msg (io_can_rt_t *rt, struct io_can_rt_read_msg *read_msg) |
Cancels the specified CAN frame read operation if it is pending. More... | |
size_t | io_can_rt_abort_read_msg (io_can_rt_t *rt, struct io_can_rt_read_msg *read_msg) |
Aborts the specified CAN frame read operation if it is pending. More... | |
ev_future_t * | io_can_rt_async_read_msg (io_can_rt_t *rt, uint_least32_t id, uint_least8_t flags, struct io_can_rt_read_msg **pread_msg) |
Submits an asynchronous CAN frame read operation to a CAN frame router and creates a future which becomes ready once the read operation completes (or is canceled). More... | |
void | io_can_rt_submit_read_err (io_can_rt_t *rt, struct io_can_rt_read_err *read_err) |
Submits a CAN error frame read operation to a CAN frame router. More... | |
size_t | io_can_rt_cancel_read_err (io_can_rt_t *rt, struct io_can_rt_read_err *read_err) |
Cancels the specified CAN error frame read operation if it is pending. More... | |
size_t | io_can_rt_abort_read_err (io_can_rt_t *rt, struct io_can_rt_read_err *read_err) |
Aborts the specified CAN error frame read operation if it is pending. More... | |
ev_future_t * | io_can_rt_async_read_err (io_can_rt_t *rt, struct io_can_rt_read_err **pread_err) |
Submits an asynchronous CAN error frame read operation to a CAN frame router and creates a future which becomes ready once the read operation completes (or is canceled). More... | |
ev_future_t * | io_can_rt_async_shutdown (io_can_rt_t *rt) |
Shuts down a CAN frame router, cancels all pending operations and creates a (void) future which becomes ready once it is safe to invoke io_can_rt_destroy() (i.e., once the completion task of the last canceled reader has finished executing). More... | |
struct io_can_rt_read_msg * | io_can_rt_read_msg_from_task (struct ev_task *task) |
Obtains a pointer to a CAN frame read operation from a pointer to its completion task. | |
struct io_can_rt_read_err * | io_can_rt_read_err_from_task (struct ev_task *task) |
Obtains a pointer to a CAN error frame read operation from a pointer to its completion task. | |
This file is part of the I/O library; it contains the implementation of the CAN frame router.
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_rt.c.
io_can_rt_t* io_can_rt_create | ( | io_can_chan_t * | chan, |
ev_exec_t * | exec | ||
) |
Creates a new CAN frame router.
chan | a pointer to the CAN channel to be used to read and write CAN frames. During the lifetime of the CAN frame router, no other read operations SHOULD be submitted to the CAN channel. |
exec | a pointer to the executor used to execute asynchronous tasks. |
void io_can_rt_destroy | ( | io_can_rt_t * | rt | ) |
Destroys a CAN frame router.
This function SHOULD NOT be called if there are pending read operations, since their completion tasks will never be executed. Use io_can_rt_async_shutdown() to cancel all operations and wait for the completion tasks to finish executing.
void io_can_rt_submit_read_msg | ( | io_can_rt_t * | rt, |
struct io_can_rt_read_msg * | read_msg | ||
) |
size_t io_can_rt_cancel_read_msg | ( | io_can_rt_t * | rt, |
struct io_can_rt_read_msg * | read_msg | ||
) |
Cancels the specified CAN frame read operation if it is pending.
The completion task is submitted for execution with errc = errnum2c(ERRNUM_CANCELED).
size_t io_can_rt_abort_read_msg | ( | io_can_rt_t * | rt, |
struct io_can_rt_read_msg * | read_msg | ||
) |
Aborts the specified CAN frame read operation if it is pending.
If aborted, the completion task is not submitted for execution.
ev_future_t* io_can_rt_async_read_msg | ( | io_can_rt_t * | rt, |
uint_least32_t | id, | ||
uint_least8_t | flags, | ||
struct io_can_rt_read_msg ** | pread_msg | ||
) |
Submits an asynchronous CAN frame read operation to a CAN frame router and creates a future which becomes ready once the read operation completes (or is canceled).
The result of the future has type io_can_rt_read_msg_result.
rt | a pointer to a CAN frame router. |
id | the identifier of the CAN frame to be received. |
flags | the flags of the CAN frame to be received (any combination of CAN_FLAG_IDE, CAN_FLAG_RTR, CAN_FLAG_FDF, CAN_FLAG_BRS and CAN_FLAG_ESI). |
pread_msg | the address at which to store a pointer to the read operation (can be NULL). |
void io_can_rt_submit_read_err | ( | io_can_rt_t * | rt, |
struct io_can_rt_read_err * | read_err | ||
) |
size_t io_can_rt_cancel_read_err | ( | io_can_rt_t * | rt, |
struct io_can_rt_read_err * | read_err | ||
) |
Cancels the specified CAN error frame read operation if it is pending.
The completion task is submitted for execution with errc = errnum2c(ERRNUM_CANCELED).
size_t io_can_rt_abort_read_err | ( | io_can_rt_t * | rt, |
struct io_can_rt_read_err * | read_err | ||
) |
Aborts the specified CAN error frame read operation if it is pending.
If aborted, the completion task is not submitted for execution.
ev_future_t* io_can_rt_async_read_err | ( | io_can_rt_t * | rt, |
struct io_can_rt_read_err ** | pread_err | ||
) |
Submits an asynchronous CAN error frame read operation to a CAN frame router and creates a future which becomes ready once the read operation completes (or is canceled).
The result of the future has type io_can_rt_read_err_result.
rt | a pointer to a CAN frame router. |
pread_err | the address at which to store a pointer to the read operation (can be NULL). |
Shuts down a CAN frame router, cancels all pending operations and creates a (void) future which becomes ready once it is safe to invoke io_can_rt_destroy() (i.e., once the completion task of the last canceled reader has finished executing).