20 #include "../include/dpn_user.h" 63 unsigned short int iRetVal = 0;
74 struct dpn_interface_m dpnIn;
75 dpnIn.dpn_if_single[0].reference.access =
m_access;
76 dpnIn.dpn_if_single[0].reference.board_select =
m_hDevice;
77 dpnIn.dpn_if_single[0].stat_nr = rclProtocolMessage.
m_iModuleId;
78 for(
int j = 1; j < DPN_MULTIPLE_SIZE; j++ )
79 dpnIn.dpn_if_single[j].stat_nr = DPN_IF_S_UNUSED;
80 dpn_interface_m* pDpnIn = &dpnIn;
87 iRetVal = dpn_in_slv_m( &dpnIn );
97 warning(
"CP5X11 readDevice timeout");
102 if( iRetVal != DPN_NO_ERROR )
103 {
warning(
"CP5X11 dpn_in_slv failure: %x", iRetVal );
117 if( pDpnIn->dpn_if_single[0].user_data[0] == rclProtocolMessage.
m_aucMessageData[0] )
120 if( pDpnIn->dpn_if_single[0].user_data[0] == rclProtocolMessage.
m_aucMessageData[0] &&
121 pDpnIn->dpn_if_single[0].user_data[1] == rclProtocolMessage.
m_aucMessageData[1] )
145 memcpy( rclProtocolMessage.
m_aucMessageData, pDpnIn->dpn_if_single[0].user_data, 8 );
151 unsigned short int iRetVal = 0;
166 struct dpn_interface_m dpnOut;
167 dpnOut.dpn_if_single[0].reference.access =
m_access;
168 dpnOut.dpn_if_single[0].reference.board_select =
m_hDevice;
169 dpnOut.dpn_if_single[0].stat_nr = rclProtocolMessage.
m_iModuleId;
170 dpnOut.dpn_if_single[0].length = 8;
171 for(
int i = 0; i < 8; i++ )
172 dpnOut.dpn_if_single[0].user_data[i] = rclProtocolMessage.
m_aucMessageData[i];
173 for(
int j = 1; j < DPN_MULTIPLE_SIZE; j++ )
174 dpnOut.dpn_if_single[j].stat_nr = DPN_IF_S_UNUSED;
175 dpn_interface_m* pDpnOut = &dpnOut;
177 iRetVal = dpn_out_slv_m( &dpnOut );
206 error(-1,
"Sorry constructor is not implemented");
221 error(-1,
"Sorry operator= is not implemented");
263 unsigned short int iRetVal = 0;
270 dpn_interface dpnReinit;
273 strncpy( acString, acInitString, 128 );
275 pcToken = strtok( acString,
":" );
280 if( strcmp( pcToken,
"CP5X11" ) != 0 )
285 pcToken = strtok( NULL,
"," );
296 dpn.reference.access = DPN_SYS_NOT_CENTRAL | DPN_ROLE_NOT_CENTRAL;
298 for(
int i = 0; i < 126; i++ )
299 dpn.user_data[i] = DPN_SLV_NO_ACCESS;
300 dpn_interface* pDpn = &(dpn);
302 iRetVal = dpn_init( pDpn );
303 if( iRetVal != DPN_NO_ERROR )
304 {
warning(
"CP5X11 dpn_init failed: %x", iRetVal );
308 m_hDevice = pDpn->reference.board_select;
315 iRetVal = dpn_read_cfg( pDpn );
316 if( iRetVal != DPN_NO_ERROR )
317 {
warning(
"CP5X11 dpn_init failed: %x", iRetVal );
323 for( i = 0; i < pDpn->length; i++ )
324 {
if( pDpn->user_data[i] == DPN_CFG_NORM )
325 dpnReinit.user_data[i] = DPN_SLV_WRITE_READ;
327 dpnReinit.user_data[i] = DPN_SLV_NO_ACCESS;
334 iRetVal = dpn_reset( pDpn );
335 if( iRetVal != DPN_NO_ERROR )
336 {
warning(
"dpn_reset failed with %x", iRetVal );
341 dpnReinit.reference.board_select =
m_hDevice;
342 dpnReinit.reference.access = DPN_SYS_NOT_CENTRAL | DPN_ROLE_NOT_CENTRAL;
343 dpnReinit.length = 126;
346 iRetVal = dpn_init( pDpn );
347 if( iRetVal != DPN_NO_ERROR )
348 {
warning(
"CP5X11 dpn_init failed: %x", iRetVal );
353 m_hDevice = pDpn->reference.board_select;
358 warning(
"init CP5X11 device failed no library found");
375 unsigned short int iRetVal = 0;
381 warning(
"device not initialzed");
387 dpn_interface* pDpn = &(dpn);
389 iRetVal = dpn_reset( pDpn );
390 if( iRetVal != DPN_NO_ERROR )
392 warning(
"Could not exit CP5X11" );
#define ERRID_DEV_BADINITSTRING
unsigned long m_uiTimeOut
unsigned char m_aucMessageData[8]
int reinit(unsigned char ucBaudRateId)
int initMessage(const char *pcClassName, int iDebuglevel=0, bool bDebug=true, bool bDebugFile=false)
CRITICAL_SECTION m_csDevice
void error(const int iErrorCode, const char *pcErrorMessage,...) const
int getDeviceError(int iErrorState)
int setMessageId(unsigned long uiMessageId)
#define ERRID_DEV_NOTINITIALIZED
CCP5X11Device()
default constructor
void setTimeOut(unsigned long uiTimeOut)
unsigned char m_ucMessageLength
int writeDevice(CProtocolMessage &rclProtocolMessage)
unsigned long m_uiMessageId
virtual ~CCP5X11Device()
destructor
void warning(const char *pcWarningMessage,...) const
#define ERRID_DEV_INITERROR
#define ERRID_DEV_EXITERROR
int readDevice(CProtocolMessage &rclProtocolMessage)
#define ERRID_DEV_NOLIBRARY
#define ERRID_DEV_READERROR
CCP5X11Device & operator=(const CCP5X11Device &rclCP5X11Device)