//**************************************************************************** // Copyright (C) 2007 // Nissan North America // All Rights Reserved. Proprietary and Confidential. //============================================================================ /* prevent multiple inclusions */ #ifndef __CanSocket__ #define __CanSocket__ /* includes *****************************************************************/ #include #include "netlib.h" #include #include #include /* defines ******************************************************************/ #define CAN_MAX_FILTER 31 #define CAN_MAX_ADDRESSES 256 /* macros *******************************************************************/ /* structs & typedefs *******************************************************/ typedef struct can_filter CanFilter; typedef struct can_frame CanFrame; typedef struct _BcmFrame { struct bcm_msg_head head; struct can_frame frame; } BcmFrame; /* c class definitions ******************************************************/ // // Uses the Peak Systems CAN Linux driver and Nissan CAN data // class CanSocket { // public data public: int m_sock; int m_proto; // private data private: // device int m_flags; // errors bool m_logerrs; long m_errcount; // static data // public methods public: // constructors CanSocket(); // destructor virtual ~CanSocket(); // virtual functions // public methods void AddrFlags( u_long f ) { m_flags = f; }; int GetSock(void) {return m_sock;}; int GetSocket(void) {return m_sock;}; int GetProto(void) {return m_proto;}; int CanOpen( const char *dev="can0", int proto=CAN_RAW, int flags=0 ); void CanClose(void); // misc int ClearFilters( void ); int Blocking(bool block=true); int NonBlocking(void) { return Blocking(false); }; int Loopback(bool loop=true); int NoLoopback(void) { return Loopback(false); }; void LogErrors(bool logerrs=true) {m_logerrs = logerrs;}; // rx filter int CanAddRx( u_int32_t addr ); int CanAddRx( const CanFilter *filter, int max=1 ); int CanDelRx( u_int32_t addr ); // raw int CanRawRead( CanFrame *buf, int max=1 ); int CanRawWrite( const CanFrame *buf, int max=1 ); // bcm int CanBcmRead( BcmFrame *msg, int max=1 ); int CanBcmWrite( BcmFrame *msg, int max=1 ); }; #endif