bool LinnStrumentSerialWindows::detect()
{
    if (!hasFirmwareFile()) return false;

    linnstrumentDevice = String::empty;

	DISPATCH_OBJ(wmiSvc);
	DISPATCH_OBJ(colDevices);
	dhInitialize(TRUE);
	dhToggleExceptions(TRUE);
	dhGetObject(L"winmgmts:{impersonationLevel=impersonate}!\\\\.\\root\\cimv2", NULL, &wmiSvc);
	// only use entities that are COM ports with the vendor and product ID of LinnStrument
	dhGetValue(L"%o", &colDevices, wmiSvc, L".ExecQuery(%S)", L"SELECT * from Win32_PnPEntity WHERE Name LIKE \"%(COM%\" AND PnPDeviceID LIKE \"%VID_F055&PID_0070%\"");
	FOR_EACH(objDevice, colDevices, NULL)
	{
		char* name = NULL;
		char* pnpid = NULL;
		char* match;
		dhGetValue(L"%s", &name, objDevice, L".Name");
		dhGetValue(L"%s", &pnpid, objDevice, L".PnPDeviceID");
		if (name != NULL && pnpid != NULL && (match = strstr(name, "(COM")) != NULL)
		{
			char* comname = strtok(match, "()");
			linnstrumentDevice = String(comname);
			printf("Found LinnStrument %s - %s\n", comname, pnpid);
		}
		dhFreeString(name);
		dhFreeString(pnpid);
	}
Ejemplo n.º 2
0
/*
 * listComPorts.c -- list COM ports
 *
 * http://github.com/todbot/usbSearch/
 *
 * 2012, Tod E. Kurt, http://todbot.com/blog/
 *
 *
 * Uses DispHealper : http://disphelper.sourceforge.net/
 *
 * Notable VIDs & PIDs combos:
 * VID 0403 - FTDI
 *
 * VID 0403 / PID 6001 - Arduino Diecimila
 *
 */
void GetAdapterList(uv_work_t* req) {
    AdapterListBaton* data = static_cast<AdapterListBaton*>(req->data);

    {
        DISPATCH_OBJ(wmiSvc);
        DISPATCH_OBJ(colDevices);

        dhInitialize(TRUE);
        dhToggleExceptions(FALSE);

        dhGetObject(L"winmgmts:{impersonationLevel=impersonate}!\\\\.\\root\\cimv2", NULL, &wmiSvc);
        dhGetValue(L"%o", &colDevices, wmiSvc, L".ExecQuery(%S)", L"Select * from Win32_PnPEntity");

        FOR_EACH(objDevice, colDevices, NULL) {
            char* name = NULL;
            char* pnpid = NULL;
            char* manu = NULL;
            char* match;

            dhGetValue(L"%s", &name,  objDevice, L".Name");
            dhGetValue(L"%s", &pnpid, objDevice, L".PnPDeviceID");

            if( name != NULL && ((match = strstr( name, "(COM" )) != NULL) ) { // look for "(COM23)"
                // 'Manufacturuer' can be null, so only get it if we need it
                dhGetValue(L"%s", &manu, objDevice,  L".Manufacturer");

                if(strcmp("SEGGER", manu) == 0)
                {
                    char* comname = strtok( match, "()");
                    AdapterListResultItem* resultItem = new AdapterListResultItem();
                    resultItem->comName = comname;
                    resultItem->manufacturer = manu;
                    resultItem->pnpId = pnpid;
                    data->results.push_back(resultItem);
                }

                dhFreeString(manu);
              }

            dhFreeString(name);
            dhFreeString(pnpid);
        } NEXT(objDevice);

        SAFE_RELEASE(colDevices);
        SAFE_RELEASE(wmiSvc);

        dhUninitialize(TRUE);
    }
Ejemplo n.º 3
0
int listComPorts(void)
{
    if(verbose)
        printf("Searching for COM ports...\n");

    DISPATCH_OBJ(wmiSvc);
    DISPATCH_OBJ(colDevices);

    dhInitialize(TRUE);
    dhToggleExceptions(TRUE);
 
    dhGetObject(L"winmgmts:{impersonationLevel=impersonate}!\\\\.\\root\\cimv2",
    //dhGetObject(L"winmgmts:\\\\.\\root\\cimv2",
                NULL, &wmiSvc);
    dhGetValue(L"%o", &colDevices, wmiSvc, 
               L".ExecQuery(%S)",  
               L"Select * from Win32_PnPEntity");


    int port_count = 0;

    FOR_EACH(objDevice, colDevices, NULL) {
        
        char* name = NULL;
        char* pnpid = NULL;
        char* manu = NULL;
        char* match;

        dhGetValue(L"%s", &name,  objDevice, L".Name");
        dhGetValue(L"%s", &pnpid, objDevice, L".PnPDeviceID");
                                                
        if( name != NULL && ((match = strstr( name, "(COM" )) != NULL) ) { // look for "(COM23)"
            // 'Manufacturuer' can be null, so only get it if we need it
            dhGetValue(L"%s", &manu, objDevice,  L".Manufacturer");
            port_count++;
            char* comname = strtok( match, "()");
            printf("%s - %s - %s\n",comname, manu, pnpid);
            dhFreeString(manu);
        }
        
        dhFreeString(name);
        dhFreeString(pnpid);
        
    } NEXT(objDevice);
Ejemplo n.º 4
0
std::string __stdcall GetComputerString(int length)
{

 	DISPATCH_OBJ(wmiSvc);
	DISPATCH_OBJ(colMedia);
    DISPATCH_OBJ(colCPU);


    std::string uniqueIdentifier = "";
    CDispPtr ColProcesador;

	dhInitialize(TRUE);
	dhToggleExceptions(TRUE);




	dhGetObject(L"winmgmts:{impersonationLevel=impersonate}!\\\\.\\root\\cimv2", NULL, &wmiSvc);
	dhGetValue(L"%o", &colMedia, wmiSvc, L".ExecQuery(%S)",  L"SELECT * FROM Win32_PhysicalMedia");
    dhGetValue(L"%o", &colCPU, wmiSvc, L".ExecQuery(%S)",  L"SELECT * FROM Win32_Processor");



	FOR_EACH(wmiCPUItem, colCPU, NULL)
	{
        char *pszCPUCaption = NULL;



        dhGetValue(L"%s", &pszCPUCaption, wmiCPUItem, L".Caption");
        if (pszCPUCaption)
        {
            uniqueIdentifier = uniqueIdentifier + string(pszCPUCaption);
        }

        dhFreeString(pszCPUCaption);

	} NEXT(wmiCPUItem);
Ejemplo n.º 5
0
int listComPorts(void)
{

    if(verbose)
        printf("Searching for COM ports...\n");

    DISPATCH_OBJ(wmiSvc);
    DISPATCH_OBJ(colDevices);

    dhInitialize(TRUE);
    dhToggleExceptions(TRUE);

    dhGetObject(L"winmgmts:{impersonationLevel=impersonate}!\\\\.\\root\\cimv2",
                //dhGetObject(L"winmgmts:\\\\.\\root\\cimv2",
                NULL, &wmiSvc);
    dhGetValue(L"%o", &colDevices, wmiSvc,
               L".ExecQuery(%S)",
               L"Select * from Win32_PnPEntity");


    int port_count = 0;
    int error = 1;
    int found = 0;
    dhToggleExceptions(FALSE);

    FOR_EACH(objDevice, colDevices, NULL) {

        char* name = NULL;
        char* pnpid = NULL;
        char* manu = NULL;
        char* match;

        dhGetValue(L"%s", &name,  objDevice, L".Name");
        dhGetValue(L"%s", &pnpid, objDevice, L".PnPDeviceID");

        if(verbose>1) printf("'%s'.\n", name);
        if( name != NULL && ((match = strstr( name, "(COM" )) != NULL) ) { // look for "(COM23)"
            char* comname = strtok( match, "()");
            // 'Manufacturuer' can be null, so only get it if we need it
            dhGetValue(L"%s", &manu, objDevice,  L".Manufacturer");
            port_count++;

            if (VIDstr != NULL) { //Are we searching for a VID
                if( pnpid != NULL && ((match = strstr( pnpid, VIDstr )) != NULL) ) {// If searching for VID
                    printf("%s\n",comname);
                    error = 0;
                }
            } else if (papilio) {
                if( pnpid != NULL && ((match = strstr( pnpid, "VID_0403+PID_6010" )) != NULL) ) {// If searching for Papilio FPGA serial
                    printf("%s\n",comname);
                    found = 1;
                    error = 0;
                }
                else {
                    if (!found) {
                        //printf("No Papilio port detected.");
                        error = 1;
                    }
                }
            } else if (papilioduo) {
                if( pnpid != NULL && ((match = strstr( pnpid, "VID_0403+PID_7BC0" )) != NULL) ) {// If searching for Papilio DUO FPGA serial
                    printf("%s\n",comname);
                    found = 1;
                    error = 0;
                }
                else {
                    if (!found) {
                        //printf("No Papilio port detected.");
                        error = 1;
                    }
                }
            } else if (arduino) {
                if( pnpid != NULL && ((match = strstr( pnpid, "VID_1D50&PID_60A5&MI_00" )) != NULL) ) {// If searching for Papilio FPGA serial
                    printf("%s\n",comname);
                    found = 1;
                    error = 0;
                }
                else {
                    if (!found) {
                        //printf("No Arduino port detected.");
                        error = 1;
                    }
                }
            } else if (bootloader) {
                if( pnpid != NULL && ((match = strstr( pnpid, "VID_1D50&PID_60A4" )) != NULL) ) {// If searching for Papilio FPGA serial
                    printf("%s\n",comname);
                    found = 1;
                    error = 0;
                }
                else {
                    if (!found) {
                        //printf("No Arduino port detected.");
                        error = 1;
                    }
                }
            } else {
                if(verbose)
                    printf("%s - %s - %s - %s\n",comname, name, manu, pnpid);
                else
                    printf("%s - %s \n",comname, name);
                error = 0;
            }
            dhFreeString(manu);
        }

        dhFreeString(name);
        dhFreeString(pnpid);

    }