Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef _ntcan_h_
00026 #define _ntcan_h_
00027
00028 #if ((__GNUC__ > 2) || (__GNUC__ > 2) && (__GNUC_MINOR__ >= 1))
00029 # define NTCAN_GCCATTR_DEPRECATED __attribute__((deprecated))
00030 #else
00031 # define NTCAN_GCCATTR_DEPRECATED
00032 #endif
00033
00034 #include <stdint.h>
00035
00036 #ifndef EXPORT
00037 #define EXPORT
00038 #endif
00039
00040 #ifndef CALLTYPE
00041 #define CALLTYPE
00042 #endif
00043
00044 #ifdef __cplusplus
00045 extern "C" {
00046 #endif
00047
00048
00049 #define NTCAN_EV_BASE 0x40000000
00050 #define NTCAN_EV_USER 0x40000080
00051 #define NTCAN_EV_LAST 0x400000FF
00052
00053 #define NTCAN_20B_BASE 0x20000000
00054
00055 #define NTCAN_RTR 0x10
00056 #define NTCAN_NO_DATA 0x20
00057 #define NTCAN_INTERACTION 0x20
00058
00059 #define NTCAN_EV_CAN_ERROR NTCAN_EV_BASE
00060 #define NTCAN_EV_BAUD_CHANGE (NTCAN_EV_BASE + 0x1)
00061 #define NTCAN_EV_CAN_ERROR_EXT (NTCAN_EV_BASE + 0x2)
00062
00063
00064 #define NTCAN_MODE_OVERLAPPED 0x20000000
00065 #define NTCAN_MODE_OBJECT 0x10000000
00066
00067
00068 #define NTCAN_MAX_TX_QUEUESIZE 2047
00069 #define NTCAN_MAX_RX_QUEUESIZE 2047
00070 #define NTCAN_NO_QUEUE -1
00071
00072
00073 #define NTCAN_NO_BAUDRATE 0x7FFFFFFF
00074 #define NTCAN_AUTOBAUD 0x7FFFFFFE
00075
00076
00077 #define NTCAN_BAUD_1000 0x0
00078 #define NTCAN_BAUD_800 0xE
00079 #define NTCAN_BAUD_500 0x2
00080 #define NTCAN_BAUD_250 0x4
00081 #define NTCAN_BAUD_125 0x6
00082 #define NTCAN_BAUD_100 0x7
00083 #define NTCAN_BAUD_50 0x9
00084 #define NTCAN_BAUD_20 0xB
00085 #define NTCAN_BAUD_10 0xD
00086
00087 #define NTCAN_USER_BAUD 0x80000000
00088 #define NTCAN_USER_BAUDRATE 0x80000000
00089 #define NTCAN_LISTEN_ONLY_MODE 0x40000000
00090 #define NTCAN_USER_BAUDRATE_NUM 0x20000000
00091
00092
00093 #define NTCAN_ERRNO_BASE 0x00000100
00094
00095 #define NTCAN_SUCCESS 0
00096
00097 #define NTCAN_RX_TIMEOUT (NTCAN_ERRNO_BASE +1)
00098 #define NTCAN_TX_TIMEOUT (NTCAN_ERRNO_BASE +2)
00099
00100 #define NTCAN_TX_ERROR (NTCAN_ERRNO_BASE +4)
00101 #define NTCAN_CONTR_OFF_BUS (NTCAN_ERRNO_BASE +5)
00102 #define NTCAN_CONTR_BUSY (NTCAN_ERRNO_BASE +6)
00103 #define NTCAN_CONTR_WARN (NTCAN_ERRNO_BASE +7)
00104 #define NTCAN_NO_ID_ENABLED (NTCAN_ERRNO_BASE +9)
00105 #define NTCAN_ID_ALREADY_ENABLED (NTCAN_ERRNO_BASE +10)
00106 #define NTCAN_ID_NOT_ENABLED (NTCAN_ERRNO_BASE +11)
00107
00108 #define NTCAN_INVALID_FIRMWARE (NTCAN_ERRNO_BASE +13)
00109 #define NTCAN_MESSAGE_LOST (NTCAN_ERRNO_BASE +14)
00110 #define NTCAN_INVALID_HARDWARE (NTCAN_ERRNO_BASE +15)
00111
00112 #define NTCAN_PENDING_WRITE (NTCAN_ERRNO_BASE +16)
00113 #define NTCAN_PENDING_READ (NTCAN_ERRNO_BASE +17)
00114 #define NTCAN_INVALID_DRIVER (NTCAN_ERRNO_BASE +18)
00115
00116 #define NTCAN_SOCK_CONN_TIMEOUT (NTCAN_ERRNO_BASE + 0x80)
00117 #define NTCAN_SOCK_CMD_TIMEOUT (NTCAN_ERRNO_BASE + 0x81)
00118 #define NTCAN_SOCK_HOST_NOT_FOUND (NTCAN_ERRNO_BASE + 0x82)
00119
00120 #define NTCAN_INVALID_PARAMETER EINVAL
00121 #define NTCAN_INVALID_HANDLE EBADFD
00122
00123
00124 #define NTCAN_NET_NOT_FOUND ENODEV
00125 #define NTCAN_INSUFFICIENT_RESOURCES ENOMEM
00126
00127 #define NTCAN_OPERATION_ABORTED EINTR
00128 #define NTCAN_WRONG_DEVICE_STATE (NTCAN_ERRNO_BASE +19)
00129 #define NTCAN_HANDLE_FORCED_CLOSE (NTCAN_ERRNO_BASE +20)
00130 #define NTCAN_NOT_IMPLEMENTED ENOSYS
00131 #define NTCAN_NOT_SUPPORTED (NTCAN_ERRNO_BASE +21)
00132 #define NTCAN_CONTR_ERR_PASSIVE (NTCAN_ERRNO_BASE +22)
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142 typedef int32_t OVERLAPPED;
00143 #ifndef NTCAN_CLEAN_NAMESPACE
00144 typedef int32_t HANDLE NTCAN_GCCATTR_DEPRECATED;
00145 #endif
00146 typedef int32_t NTCAN_RESULT;
00147 typedef int32_t NTCAN_HANDLE;
00148
00149 #pragma pack(1)
00150
00151 typedef struct {
00152 int32_t id;
00153 uint8_t len;
00154 uint8_t msg_lost;
00155 uint8_t reserved[2];
00156 uint8_t data[8];
00157 } CMSG;
00158
00159 typedef struct {
00160 int32_t evid;
00161 uint8_t len;
00162 uint8_t reserved[3];
00163 union {
00164 uint8_t c[8];
00165 uint16_t s[4];
00166 uint32_t l[2];
00167 } evdata;
00168 } EVMSG;
00169
00170 typedef struct {
00171 int32_t id;
00172 uint8_t len;
00173 uint8_t msg_lost;
00174 uint8_t reserved[2];
00175 uint8_t data[8];
00176 uint64_t timestamp;
00177 } CMSG_T;
00178
00179 typedef struct {
00180 uint16_t hardware;
00181 uint16_t firmware;
00182 uint16_t driver;
00183 uint16_t dll;
00184 uint32_t boardstatus;
00185 uint8_t boardid[14];
00186 uint16_t features;
00187 } CAN_IF_STATUS;
00188
00189
00190 typedef struct
00191 {
00192 int32_t id;
00193 int32_t flags;
00194 uint64_t time_start;
00195 uint64_t time_interval;
00196 uint8_t reserved[8];
00197 } CSCHED;
00198
00199 #pragma pack()
00200
00201
00202
00203 #define NTCAN_FEATURE_FULL_CAN (1<<0)
00204 #define NTCAN_FEATURE_BASIC_20B (1<<1)
00205 #define NTCAN_FEATURE_DEVICE_NET (1<<2)
00206 #define NTCAN_FEATURE_CYCLIC_TX (1<<3)
00207 #define NTCAN_FEATURE_RX_OBJECT_MODE (1<<4)
00208 #define NTCAN_FEATURE_TIMESTAMP (1<<5)
00209 #define NTCAN_FEATURE_LISTEN_ONLY_MODE (1<<6)
00210 #define NTCAN_FEATURE_SMART_DISCONNECT (1<<7)
00211
00212
00213 #define NTCAN_BUSSTATE_OK 0x00
00214 #define NTCAN_BUSSTATE_WARN 0x40
00215 #define NTCAN_BUSSTATE_ERRPASSIVE 0x80
00216 #define NTCAN_BUSSTATE_BUSOFF 0xC0
00217
00218
00219
00220
00221 #define NTCAN_IOCTL_FLUSH_RX_FIFO 0x0001
00222 #define NTCAN_IOCTL_GET_RX_MSG_COUNT 0x0002
00223 #define NTCAN_IOCTL_GET_RX_TIMEOUT 0x0003
00224 #define NTCAN_IOCTL_GET_TX_TIMEOUT 0x0004
00225
00226
00227
00228
00229
00230 #define NTCAN_IOCTL_SET_20B_HND_FILTER 0x0005
00231 #define NTCAN_IOCTL_GET_SERIAL 0x0006
00232 #define NTCAN_IOCTL_GET_TIMESTAMP_FREQ 0x0007
00233 #define NTCAN_IOCTL_GET_TIMESTAMP 0x0008
00234 #define NTCAN_IOCTL_ABORT_RX 0x0009
00235 #define NTCAN_IOCTL_ABORT_TX 0x000A
00236 #define NTCAN_IOCTL_SET_RX_TIMEOUT 0x000B
00237 #define NTCAN_IOCTL_SET_TX_TIMEOUT 0x000C
00238 #define NTCAN_IOCTL_TX_OBJ_CREATE 0x000D
00239 #define NTCAN_IOCTL_TX_OBJ_AUTOANSWER_ON 0x000E
00240 #define NTCAN_IOCTL_TX_OBJ_AUTOANSWER_OFF 0x000F
00241 #define NTCAN_IOCTL_TX_OBJ_UPDATE 0x0010
00242 #define NTCAN_IOCTL_TX_OBJ_DESTROY 0x0011
00243
00244 #define NTCAN_IOCTL_TX_OBJ_SCHEDULE_START 0x0013
00245 #define NTCAN_IOCTL_TX_OBJ_SCHEDULE_STOP 0x0014
00246 #define NTCAN_IOCTL_TX_OBJ_SCHEDULE 0x0015
00247
00248
00249
00250 EXPORT NTCAN_RESULT CALLTYPE canSetBaudrate(
00251 NTCAN_HANDLE handle,
00252 uint32_t baud );
00253
00254 EXPORT NTCAN_RESULT CALLTYPE canGetBaudrate(
00255 NTCAN_HANDLE handle,
00256 uint32_t *baud );
00257
00258 EXPORT NTCAN_RESULT CALLTYPE canOpen(
00259 int32_t net,
00260 uint32_t flags,
00261 int32_t txqueuesize,
00262 int32_t rxqueuesize,
00263 int32_t txtimeout,
00264 int32_t rxtimeout,
00265 NTCAN_HANDLE *handle );
00266
00267 EXPORT NTCAN_RESULT CALLTYPE canClose(
00268 NTCAN_HANDLE handle );
00269
00270 EXPORT NTCAN_RESULT CALLTYPE canIdAdd(
00271 NTCAN_HANDLE handle,
00272 int32_t id );
00273
00274 EXPORT NTCAN_RESULT CALLTYPE canIdDelete(
00275 NTCAN_HANDLE handle,
00276 int32_t id );
00277
00278 EXPORT NTCAN_RESULT CALLTYPE canGetOverlappedResult(
00279 NTCAN_HANDLE handle,
00280 OVERLAPPED *ovrlppd,
00281 int32_t *len,
00282 int32_t bWait );
00283
00284 EXPORT NTCAN_RESULT CALLTYPE canTake(
00285 NTCAN_HANDLE handle,
00286 CMSG *cmsg,
00287 int32_t *len );
00288
00289
00290 EXPORT NTCAN_RESULT CALLTYPE canRead(
00291 NTCAN_HANDLE handle,
00292 CMSG *cmsg,
00293 int32_t *len,
00294
00295 OVERLAPPED *ovrlppd);
00296
00297 EXPORT NTCAN_RESULT CALLTYPE canSend(
00298 NTCAN_HANDLE handle,
00299 CMSG *cmsg,
00300 int32_t *len );
00301
00302 EXPORT NTCAN_RESULT CALLTYPE canWrite(
00303 NTCAN_HANDLE handle,
00304 CMSG *cmsg,
00305 int32_t *len,
00306 OVERLAPPED *ovrlppd);
00307
00308 EXPORT NTCAN_RESULT CALLTYPE canSendT(
00309 NTCAN_HANDLE handle,
00310 CMSG_T *cmsg,
00311 int32_t *len );
00312
00313 EXPORT NTCAN_RESULT CALLTYPE canWriteT(
00314 NTCAN_HANDLE handle,
00315 CMSG_T *cmsg,
00316 int32_t *len,
00317 OVERLAPPED *ovrlppd);
00318
00319 EXPORT NTCAN_RESULT CALLTYPE canReadEvent(
00320 NTCAN_HANDLE handle,
00321 EVMSG *evmsg,
00322 OVERLAPPED *ovrlppd);
00323
00324 EXPORT NTCAN_RESULT CALLTYPE canSendEvent(
00325 NTCAN_HANDLE handle,
00326 EVMSG *evmsg );
00327
00328 EXPORT NTCAN_RESULT CALLTYPE canStatus(
00329 NTCAN_HANDLE handle,
00330 CAN_IF_STATUS *cstat );
00331
00332 EXPORT NTCAN_RESULT CALLTYPE canIoctl(
00333 NTCAN_HANDLE handle,
00334 uint32_t ulCmd,
00335 void *pArg );
00336
00337 EXPORT NTCAN_RESULT CALLTYPE canTakeT(
00338 NTCAN_HANDLE handle,
00339 CMSG_T *cmsg_t,
00340 int32_t *len );
00341
00342
00343 EXPORT NTCAN_RESULT CALLTYPE canReadT(
00344 NTCAN_HANDLE handle,
00345 CMSG_T *cmsg_t,
00346 int32_t *len,
00347
00348 OVERLAPPED *ovrlppd);
00349
00350 #ifdef __cplusplus
00351 }
00352 #endif
00353 #endif