extern "C" int CanalSetFilter(long handle, unsigned long filter) { VscpRemoteTcpIf *pvscpif = getDriverObject(handle); if (NULL == pvscpif) return CANAL_ERROR_MEMORY; return (pvscpif->doCmdFilter(filter) ? CANAL_ERROR_SUCCESS : CANAL_ERROR_SUB_DRIVER); }
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; std::string str; std::string strDevice(pDevice); std::deque<std::string> tokens; vscp_split(tokens, strDevice, ";"); // Get possible filter if (!tokens.empty()) { str = tokens.front(); tokens.pop_front(); if (0 != str.size()) { filter = vscp_readStringValue(str); } } // Get possible mask if (!tokens.empty()) { str = tokens.front(); tokens.pop_front(); if (0 != str.size()) { mask = vscp_readStringValue(str); } } VscpRemoteTcpIf *pvscpif = new VscpRemoteTcpIf(); if (NULL != pvscpif) { if (pvscpif->doCmdOpen(strDevice, flags)) { if (!(h = addDriverObject(pvscpif))) { delete pvscpif; } else { if (bFilter) { pvscpif->doCmdFilter(filter); } if (bMask) { pvscpif->doCmdMask(mask); } } } else { delete pvscpif; } } return h; }
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 str = tkz.GetNextToken(); if ( 0 != str.Length() ) { if ( str.ToULong( &filter ) ) { bFilter = true; } } // Get possible mask if ( 0 != str.Length() ) { if ( str.ToULong( &mask ) ) { bMask = true; } } VscpRemoteTcpIf *pvscpif = new VscpRemoteTcpIf(); 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; }