Пример #1
0
extern "C" long
VSCPOpen(const char *pUsername,
		const char *pPassword,
		const char *pHost,
		short port,
		const char *pPrefix,
		const char *pParameter,
		unsigned long flags)
{
	long h = 0;

	CRawEthernet *pdrvObj = new CRawEthernet();
	if (NULL != pdrvObj) {

		if (pdrvObj->open(pUsername,
				pPassword,
				pHost,
				port,
				pPrefix,
				pParameter)) {

			if (!(h = theApp.addDriverObject(pdrvObj))) {
				delete pdrvObj;
			}

		} else {
			delete pdrvObj;
		}

	}

	return h;
}
Пример #2
0
CDllDrvObj::~CDllDrvObj()
{
	LOCK_MUTEX( m_objMutex );
	
	for ( int i = 0; i<VSCP_LOGGER_DRIVER_MAX_OPEN; i++ ) {
		
		if ( NULL == m_drvObjArray[ i ] ) {
			
			CRawEthernet *pdrvObj =  getDriverObject( i );
			if ( NULL != pdrvObj ) { 
				pdrvObj->close();	
				delete m_drvObjArray[ i ];
				m_drvObjArray[ i ] = NULL; 
			}
		}
	}

	UNLOCK_MUTEX( m_objMutex );

#ifdef WIN32
	CloseHandle( m_objMutex );
#else	
	pthread_mutex_destroy( &m_objMutex );
#endif
}
Пример #3
0
extern "C" int
VSCPClose(long handle)
{
	int rv = 0;

	CRawEthernet *pdrvObj = theApp.getDriverObject(handle);
	if (NULL == pdrvObj) return 0;
	pdrvObj->close();
	theApp.removeDriverObject(handle);
	rv = 1;
	return CANAL_ERROR_SUCCESS;
}
Пример #4
0
extern "C" int
VSCPBlockingSend(long handle, const vscpEvent *pEvent, unsigned long timeout)
{
	int rv = 0;

	CRawEthernet *pdrvObj = theApp.getDriverObject(handle);
	if (NULL == pdrvObj) return CANAL_ERROR_MEMORY;
    
    //vscpEvent *pEventNew = new vscpEvent;
    //if ( NULL != pEventNew ) {
    //    copyVSCPEvent( pEventNew, pEvent );
    pdrvObj->addEvent2SendQueue( pEvent );
	//}
    //else {
    //    return CANAL_ERROR_MEMORY;
    //}
    
	return CANAL_ERROR_SUCCESS;
}
Пример #5
0
CVSCPDrvApp::~CVSCPDrvApp()
{
	LOCK_MUTEX(m_objMutex);

	for (int i = 0; i < VSCP_RAWETHERNET_DRIVER_MAX_OPEN; i++) {

		if (NULL == m_prawethernetArray[ i ]) {

			CRawEthernet *psockcan = getDriverObject(i);
			if (NULL != psockcan) {
				psockcan->close();
				delete m_prawethernetArray[ i ];
				m_prawethernetArray[ i ] = NULL;
			}
		}
	}

	UNLOCK_MUTEX(m_objMutex);
	pthread_mutex_destroy(&m_objMutex);
}