예제 #1
0
extern "C" long CanalOpen( const char *pDevice, unsigned long flags )
{
	long h = CANAL_ERROR_SUB_DRIVER;
	unsigned long filter=0, mask=0;
	bool bFilter=false, bMask=false;
	wxString str;
	wxString strDevice( pDevice, wxConvUTF8);
	wxStringTokenizer tkz(strDevice, _(";") );

	// Get possible filter	
	if ( str = tkz.GetNextToken() ) {
		if ( 0 != str.Length() ) {
			if ( str.ToULong( &filter ) ) {
				bFilter = true;
			}
		}
	}

	// Get possible mask
	if ( str = tkz.GetNextToken() ) {
		if ( 0 != str.Length() ) {
			if ( str.ToULong( &mask ) ) {
				bMask = true;
			}
		}
	}
	
	
	VscpTcpIf *pvscpif = new VscpTcpIf();
	if ( NULL != pvscpif ) {

		if ( pvscpif->doCmdOpen( strDevice, flags ) ){

			if ( !( h = theApp.addDriverObject( pvscpif ) ) ) {
				delete pvscpif;
			}
			else {
				
				if ( bFilter ) {
					pvscpif->doCmdFilter( filter );	
				}

				if ( bMask ) {
					pvscpif->doCmdMask( mask );
				}
			}

		}
		else {
			delete pvscpif;
		}

	}
 
	return h;
}
예제 #2
0
extern "C" int CanalSetMask( long handle, unsigned long mask )
{
	VscpTcpIf *pvscpif =  theApp.getDriverObject( handle );
	if ( NULL == pvscpif ) return CANAL_ERROR_MEMORY;
	return ( pvscpif->doCmdMask( mask ) ? CANAL_ERROR_SUCCESS : CANAL_ERROR_SUB_DRIVER );
}