Main Page | Modules | Data Structures | Directories | File List | Data Fields | Globals

canapi.h

Go to the documentation of this file.
00001 /*============================================================================*
00002  * FILE:                      canapi.c
00003  *============================================================================*
00004  *
00005  *                      COPYRIGHT (C) 2006  BY
00006  *          CONDOR ENGINEERING, INC., SANTA BARBARA, CALIFORNIA
00007  *          ALL RIGHTS RESERVED.
00008  *
00009  *          THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY BE USED AND
00010  *          COPIED ONLY IN ACCORDANCE WITH THE TERMS OF SUCH LICENSE AND WITH
00011  *          THE INCLUSION OF THE ABOVE COPYRIGHT NOTICE.  THIS SOFTWARE OR ANY
00012  *          OTHER COPIES THEREOF MAY NOT BE PROVIDED OR OTHERWISE MADE
00013  *          AVAILABLE TO ANY OTHER PERSON.  NO TITLE TO AND OWNERSHIP OF THE
00014  *          SOFTWARE IS HEREBY TRANSFERRED.
00015  *
00016  *          THE INFORMATION IN THIS SOFTWARE IS SUBJECT TO CHANGE WITHOUT
00017  *          NOTICE AND SHOULD NOT BE CONSTRUED AS A COMMITMENT BY CONDOR
00018  *          ENGINEERING.
00019  *
00020  *============================================================================*
00021  *
00022  * FUNCTION:    Public include file for the CAN api library
00023  *
00024  * Author:      Christopher McKenzie
00025  * 
00026  * MAINTENANCE NOTES:
00027  * 
00028  *============================================================================*/
00029 #ifndef _CACEBOEING_H_
00030 #define _CACEBOEING_H_
00031 
00078 typedef unsigned char   uchar;
00079 typedef unsigned int    uint;
00080 typedef unsigned short  ushort;
00081 typedef unsigned long   ulong;
00082 
00091 typedef struct can20bframe
00092 {       uchar sof;      
00093         
00094         struct
00095         {       ushort  identifier11bit;        
00096                 uchar   srr,    
00097                                 ide;    
00098                 ulong   identifier18bit;        
00099                 uchar   rtr;    
00100         }arbitration;   
00101 
00102         struct
00103         {       ushort  r1,     
00104                                 r0,     
00105                                 dlc;    
00106         }control;       
00107         
00108         uchar data[8];  
00109 
00110         struct
00111         {       uint    sequence;       
00112                 uchar   delimeter;      
00113         }crc;   
00114 
00115         struct
00116         {       uchar   slot,   
00117                                 delimeter;      
00118         }ack;   
00119 
00120         uchar eof;      
00121         
00122         struct
00123         {       struct
00124                 {       unsigned __int64
00125                                 ts_sec,         
00126                                 ts_nsec;        
00127                 }ts;    
00128                 uchar
00129                         msgtype;        
00130 
00131                 ushort
00132                         isfake;         
00133 
00134                 ulong
00135                         txid;           
00136         }oob;   
00137 } can_frame;
00138 
00144 typedef struct _as_ts
00145 {       unsigned __int64
00146                         can_ts_sec,             
00147                         can_ts_nsec,    
00148 
00149                         irig_ts_sec,    
00150                         irig_ts_nsec;   
00151 } as_ts;
00152 
00166 enum
00167 {       //
00168         // This is CAN 2.0 A/B link level info
00169         //
00170         S_TYPE_ERROR    =0x8001,        
00171         S_TYPE_OVER             =0x8002,        
00172         S_TYPE_REMOTE   =0x8004,        
00173         S_TYPE_WAKEUP   =0x8008,        
00174         
00175         S_TYPE_SYNC             =0x8010,        
00176         
00177         S_ERR_OVERRUN   =0x8020,        
00178         S_ERR_LINE              =0x8040,        
00179         S_ERR_VOLTAGE   =0x8080,        
00180         S_COMPLETE              =0x8100,        
00181         S_QUEUED                =0x8200,        
00182 
00183         S_BOARD_OFF             =0x01,  
00184         S_BOARD_PASSIVE =0x02,  
00185         S_BOARD_WARNING =0x04,  
00186         S_BOARD_ACTIVE  =0x08,  
00187 
00188         S_MSG_TRANSMIT,         
00189         S_MSG_REMOTE,           
00190         S_MSG_ERROR             
00191 };
00192 
00200 enum
00201 {       S_SUCCESS=0,    
00202         S_PENDING,      
00203 
00204         S_ERR_QUEUE_IS_EMPTY,   
00205         S_ERR_QUEUE_IS_FULL,    
00206         S_ERR_TX_NOT_POSSIBLE,  
00207         S_ERR_TWICE_REGISTER,   
00208         S_ERR_INVALID_CHAN_INDEX,
00209         S_ERR_INVALID_ACCESS,   
00210         S_ERR_PORT_IS_OFFLINE,  
00211         S_ERR_CHAN_IS_ONLINE,   
00212         S_ERR_INVALID_PORT,             
00213         S_ERR_HW_NOT_READY,             
00214         S_ERR_CMD_TIMEOUT,              
00215         S_ERR_HW_NOT_PRESENT,   
00216         S_ERR_NOTIFY_ALREADY_ACTIVE,    
00217         S_ERR_NO_RESOURCES,             
00218         S_ERR_CANNOT_OPEN_DRIVER,       
00219         S_ERR_NOT_IMPLEMENTED,  
00220         S_ERR_INV_HANDLE,       
00221         S_ERR_INVARG1,  
00222         S_ERR_INVARG2,  
00223         S_ERR_INVARG3,  
00224         S_ERR_INVARGS,  
00225         S_ERR_OOB,      
00226         S_ERR_UNKNOWN,  
00227 
00230         S__MAX
00231 };
00232 
00237 enum
00238 {       FAKED_SOF       =0x0001,        
00239         FAKED_ID        =0x0002,        
00240         FAKED_SRR       =0x0004,        
00241         FAKED_IDE       =0x0008,        
00242         FAKED_EXT       =0x0010,        
00243         FAKED_RTR       =0x0020,        
00244         FAKED_RES       =0x0040,        
00245         FAKED_DLC       =0x0080,        
00246         FAKED_DATA      =0x0100,        
00247         FAKED_CRC       =0x0200,        
00248         FAKED_ACK       =0x0400,        
00249         FAKED_EOF       =0x0800,        
00250 
00254         //
00255         // get/set options can do the following
00256         //
00274         C_TXERROR=0,    //Set/read TXError counter
00287         C_RXERROR,              //Set/read RXError counter
00300         C_BAUDRATE,             //Set/read baudrate of channel
00313         C_MASK,                 //Set/read filter for channel
00326         C_CODE,
00339         C_RXQUEUE,              //Flush, get length of receive queue
00352         C_TXQUEUE,              //Flush, get length of transmit queue
00365         C_HIDEERRORS,   //Hid errors
00378         C_HIDECHIP,             //Hide Chip Status
00391         C_BLOCKTIMEOUT, //Block R/W
00404         C_BOARDSTATE,   //Active/passive/warning/off
00408         C__MAX
00409 };
00410 #define CAN_MAXCHANNELS         1024    
00411 #define CAN_MAXBUFFER           256     
00412 
00413 
00417 typedef char can_list[CAN_MAXCHANNELS][CAN_MAXBUFFER];
00418 #ifdef __cplusplus
00419    extern "C" {
00420 #endif
00421 
00438 int can_probebus (can_list list, char*errbuf);
00439 
00440 
00441 
00442 
00454 int can_openchannel (char*device, char*errbuf);
00455 
00456 
00457 
00458 
00471 int can_readchannel (int handle, can_frame*frame);
00472 
00473 
00474 
00475 
00488 int can_writechannel (int handle, can_frame*frame);
00489 
00490 
00491 
00492 
00503 int can_closechannel (int handle);
00504 
00505 
00506 
00507 
00523 int can_setchanneloptions (int handle, int option, int status);
00524 
00525 
00526 
00527 
00544 int can_getchanneloptions (int handle, int option, int*status);
00545 
00546 
00547 
00548 
00562 int can_can2raw (can_frame*frame, uchar*raw);
00563 
00564 
00565 
00566 
00580 int can_raw2can (uchar*raw, can_frame*frame);
00581 
00582 
00583 
00584 
00598 int can_getlasterror (int handle, char*errbuf);
00599 
00600 
00601 
00602 
00615 int can_getlastassoc (int handle, as_ts*timestamp);
00616 
00617 //***************************************************//
00618 //
00619 // Really, this is just for Boeing...
00620 // But I don't want to add another abstraction layer
00621 //
00622 enum
00623 {       B_CAN_GATEWAY,  
00624         B_CAN_GROUP,    
00625         B_CAN_MESSAGE,  
00626         B_CAN_STATUS    
00627 };
00643 int can_getfield (can_frame*frame,int type,int*ret);
00644 //
00645 //
00646 //**************************************************//
00647 
00652 #ifdef __cplusplus
00653 }
00654 #endif
00655 
00656 #endif

Generated on Wed Feb 22 13:31:25 2006 for CANapi by  doxygen 1.4.4