Apollo 10.0
自动驾驶开放平台
bcan.h
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2017 The Apollo Authors. All Rights Reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *****************************************************************************/
16
17#pragma once
18
19#include <sys/ioctl.h>
20#include <sys/types.h>
21#include <cstdint>
22#include <cstdlib>
23
24/* bcan_msg_t and bcan_err_code definitions. */
25// #include "linux/bcan_defs.h"
27
28#ifdef __cplusplus
29extern "C" {
30#endif
31
32#define BCAN_MAX_TX_MSG 256
33#define BCAN_MAX_RX_MSG 256
34
35// Channel states
36#define BCAN_DEV_UNINIT -1
37#define BCAN_DEV_OPEN (1 << 0)
38#define BCAN_DEV_CLOSE (1 << 1)
39#define BCAN_DEV_BAUD_SET (1 << 2)
40#define BCAN_DEV_NORMAL (1 << 3)
41#define BCAN_DEV_LOOPBACK (1 << 4)
42#define BCAN_DEV_CONFIG (1 << 5)
43#define BCAN_DEV_START (1 << 6)
44#define BCAN_DEV_STOP (1 << 7)
45#define BCAN_DEV_ACTIVE (1 << 8)
46#define BCAN_DEV_RECVD (1 << 9)
47
48typedef uint64_t bcan_hdl_t;
49
57
58/* Returns bcan library version. */
59const char *bcan_get_libversion(void);
60
61/* Returns detailed bcan library build info. */
62const char *bcan_bld_info(void);
63
64/* Returns brief bcan library build info. */
65const char *bcan_bld_info_short(void);
66
67/* Returns error message corresponding to the given error code. */
68const char *bcan_get_err_msg(int err_code);
69
70int bcan_open(uint32_t dev_index, uint32_t flags, uint64_t tx_to,
71 uint64_t rx_to, bcan_hdl_t *hdl);
75
78int bcan_set_baudrate(bcan_hdl_t hdl, uint32_t rate);
79int bcan_get_baudrate(bcan_hdl_t hdl, uint32_t *rate);
80int bcan_recv(bcan_hdl_t hdl, bcan_msg_t *buf, uint32_t num_msg);
81int bcan_send(bcan_hdl_t hdl, bcan_msg_t *buf, uint32_t num_msg);
84int bcan_get_err_counter(bcan_hdl_t hdl, uint8_t *rx_err, uint8_t *tx_err);
85
86/* The following APIs are not implemented yet. { */
87int bcan_id_add(bcan_hdl_t hdl, uint32_t id_start, uint32_t id_end);
89int bcan_id_remove(bcan_hdl_t hdl, uint32_t id_start, uint32_t id_end);
91/* } Not implemented. */
92
93#ifdef __cplusplus
94}
95#endif
int bcan_recv(bcan_hdl_t hdl, bcan_msg_t *buf, uint32_t num_msg)
const char * bcan_bld_info_short(void)
int bcan_set_baudrate(bcan_hdl_t hdl, uint32_t rate)
int bcan_unset_loopback(bcan_hdl_t hdl)
const char * bcan_bld_info(void)
int bcan_id_remove_all(bcan_hdl_t hdl)
int bcan_get_err_counter(bcan_hdl_t hdl, uint8_t *rx_err, uint8_t *tx_err)
int bcan_id_add(bcan_hdl_t hdl, uint32_t id_start, uint32_t id_end)
bcan_baudrate_val
Definition bcan.h:50
@ BCAN_BAUDRATE_500K
Definition bcan.h:52
@ BCAN_BAUDRATE_1M
Definition bcan.h:51
@ BCAN_BAUDRATE_250K
Definition bcan.h:53
@ BCAN_BAUDRATE_150K
Definition bcan.h:54
@ BCAN_BAUDRATE_NUM
Definition bcan.h:55
int bcan_stop(bcan_hdl_t hdl)
const char * bcan_get_libversion(void)
int bcan_get_status(bcan_hdl_t hdl)
int bcan_open(uint32_t dev_index, uint32_t flags, uint64_t tx_to, uint64_t rx_to, bcan_hdl_t *hdl)
int bcan_id_add_all(bcan_hdl_t hdl)
int bcan_start(bcan_hdl_t hdl)
int bcan_set_loopback(bcan_hdl_t hdl)
int bcan_close(bcan_hdl_t hdl)
int bcan_get_baudrate(bcan_hdl_t hdl, uint32_t *rate)
uint64_t bcan_hdl_t
Definition bcan.h:48
int bcan_send_hi_pri(bcan_hdl_t hdl, bcan_msg_t *buf)
int bcan_send(bcan_hdl_t hdl, bcan_msg_t *buf, uint32_t num_msg)
const char * bcan_get_err_msg(int err_code)
int bcan_id_remove(bcan_hdl_t hdl, uint32_t id_start, uint32_t id_end)