Пример #1
0
extern "C" int
CanalSetMask(long handle, unsigned long mask)
{
    VscpRemoteTcpIf *pvscpif = getDriverObject(handle);
    if (NULL == pvscpif) return CANAL_ERROR_MEMORY;
    return (pvscpif->doCmdMask(mask) ? CANAL_ERROR_SUCCESS
                                     : CANAL_ERROR_SUB_DRIVER);
}
Пример #2
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;
    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;
}
Пример #3
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	
    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;
}