libHartwer - Documentation

bcs_can.h

Go to the documentation of this file.
00001 /*
00002 * Copyright (c) 2008-2011 Marius Zwicker / Elefant Racing Bayreuth. 
00003 * All rights reserved.
00004 *
00005 * @ERB_OPEN_LICENSE_HEADER_START@
00006 *
00007 * Licensed under the Apache License, Version 2.0 (the "License");
00008 * you may not use this file except in compliance with the License.
00009 * You may obtain a copy of the License at
00010 * 
00011 *     http://www.apache.org/licenses/LICENSE-2.0
00012 * 
00013 * Unless required by applicable law or agreed to in writing, software
00014 * distributed under the License is distributed on an "AS IS" BASIS,
00015 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00016 * See the License for the specific language governing permissions and
00017 * limitations under the License.
00018 *
00019 *      http://www.elefantracing.de
00020 *
00021 * @ERB_OPEN_LICENSE_HEADER_END@
00022 */
00023 
00034 #ifndef FR9BCS_CAN_H_
00035 #define FR9BCS_CAN_H_
00036 
00037 #ifdef __cplusplus
00038 extern "C" {
00039 #endif
00040 
00041 #include "bcs_general.h"
00042 
00043 typedef UInt32 BCS_canmsg_id;
00044 
00050 #define BCS_CAN_ECU "/dev/can0"
00051 
00057 #define BCS_CAN_BOARD "/dev/can1"
00058 
00064 #define BCS_CAN_MSG_LENGTH 8
00065 
00071 typedef struct {
00072        int                         flags; 
00073        int                                cob; 
00074        BCS_canmsg_id        id; 
00075        UInt16                      length; 
00076        UInt8                       data[BCS_CAN_MSG_LENGTH]; 
00077 } BCS_canmsg;
00078 
00082 typedef enum {
00083        BCS_CAN_NONE, 
00084        BCS_CAN_NOWAIT 
00085 } BCS_CAN_Flag;
00086 
00094 BCS_ERROR BCS_CAN_open(BCS_canport* fd, const char * port, BCS_CAN_Flag f);
00095 
00096 // for simulator functions
00097 #define _MESSAGEIN 1
00098 #define _MESSAGEOUT 2
00099 // private methods
00100 BCS_ERROR _BCS_CAN_read(BCS_canport* filedescriptor, BCS_canmsg * data, long flag);
00101 BCS_ERROR _BCS_CAN_write(BCS_canport* filedescriptor, BCS_canmsg * data, long flag);
00102 
00110 static inline BCS_ERROR BCS_CAN_read(BCS_canport* fd, BCS_canmsg * dt) {
00111        return _BCS_CAN_read(fd, dt, _MESSAGEIN);
00112 }
00113        
00114 static inline BCS_ERROR _SIM_CAN_read(BCS_canport* fd, BCS_canmsg * dt) {
00115        return _BCS_CAN_read(fd, dt, _MESSAGEOUT);
00116 }
00117 
00125 static inline BCS_ERROR BCS_CAN_write(BCS_canport* fd, BCS_canmsg * dt) {
00126        return _BCS_CAN_write(fd, dt, _MESSAGEOUT);
00127 }
00128 
00129 static inline BCS_ERROR _SIM_CAN_write(BCS_canport* fd, BCS_canmsg * dt) {
00130        return _BCS_CAN_write(fd, dt, _MESSAGEIN);
00131 }
00132        
00133 #undef _MESSAGEIN
00134 #undef _MESSAGEOUT
00135 
00142 BCS_ERROR BCS_CAN_close(BCS_canport* filedescriptor);
00143 
00144 #ifdef __cplusplus
00145 }
00146 #endif
00147 
00148 #endif /* FR9BCS_CAN_H_ */

Generated on Fri Feb 11 2011 18:25:46 for libHartwer by Doxygen 1.7.3
Content © 2009-2011 Elefant Racing Bayreuth & MLBA (About) – Design © 2010 Emzeat. All Rights reserved.