Lely core libraries  2.2.5
can.c File Reference

This file is part of the I/O library; it exposes the abstract CAN bus functions. More...

#include "io2.h"
#include <lely/io2/can.h>
#include <lely/util/util.h>
#include <assert.h>
Include dependency graph for can.c:

Go to the source code of this file.

Data Structures

struct  io_can_chan_async_read
 
struct  io_can_chan_async_write
 

Functions

ev_future_tio_can_chan_async_read (io_can_chan_t *chan, ev_exec_t *exec, struct can_msg *msg, struct can_err *err, struct timespec *tp, struct io_can_chan_read **pread)
 Submits an asynchronous read operation to a CAN channel and creates a future which becomes ready once the read operation completes (or is canceled). More...
 
ev_future_tio_can_chan_async_write (io_can_chan_t *chan, ev_exec_t *exec, const struct can_msg *msg, struct io_can_chan_write **pwrite)
 Submits an asynchronous write operation to a CAN channel and creates a future which becomes ready once the write operation completes (or is canceled). More...
 
struct io_can_chan_readio_can_chan_read_from_task (struct ev_task *task)
 Obtains a pointer to a CAN channel read operation from a pointer to its completion task.
 
struct io_can_chan_writeio_can_chan_write_from_task (struct ev_task *task)
 Obtains a pointer to a CAN channel write operation from a pointer to its completion task.
 

Detailed Description

This file is part of the I/O library; it exposes the abstract CAN bus functions.

See also
lely/io2/can.h
Author
J. S. Seldenthuis jseld.nosp@m.enth.nosp@m.uis@l.nosp@m.ely..nosp@m.com

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.c.

Function Documentation

◆ io_can_chan_async_read()

ev_future_t* io_can_chan_async_read ( io_can_chan_t chan,
ev_exec_t exec,
struct can_msg msg,
struct can_err err,
struct timespec *  tp,
struct io_can_chan_read **  pread 
)

Submits an asynchronous read operation to a CAN channel and creates a future which becomes ready once the read operation completes (or is canceled).

The result of the future has type io_can_chan_read_result.

Parameters
chana pointer to a CAN channel.
execa pointer to the executor used to execute the completion function of the read operation. If NULL, the default executor of the CAN channel is used.
msgthe address at which to store the CAN frame (can be NULL).
errthe address at which to store the CAN error frame (can be NULL).
tpthe address at which to store the system time at which the CAN frame or CAN error frame was received (can be NULL).
preadthe address at which to store a pointer to the read operation (can be NULL).
Returns
a pointer to a future, or NULL on error. In the latter case, the error number can be obtained with get_errc().

Definition at line 46 of file can.c.

◆ io_can_chan_async_write()

ev_future_t* io_can_chan_async_write ( io_can_chan_t chan,
ev_exec_t exec,
const struct can_msg msg,
struct io_can_chan_write **  pwrite 
)

Submits an asynchronous write operation to a CAN channel and creates a future which becomes ready once the write operation completes (or is canceled).

The result of the future is an int containing the error number.

Parameters
chana pointer to a CAN channel.
execa pointer to the executor used to execute the completion function of the write operation. If NULL, the default executor of the CAN channel is used.
msga pointer to the CAN frame to be writen.
pwritethe address at which to store a pointer to the write operation (can be NULL).
Returns
a pointer to a future, or NULL on error. In the latter case, the error number can be obtained with get_errc().

Definition at line 69 of file can.c.