Detecting presence of a 634?

erikm

New member
Is there any way to ping a CFA-364 device to see if it's present on a port? I've looked through the documentation of the device and don't see anything that looks like a query command.

We're using the device through a USB port so alternatively is there any way to check the port to see if it's an emulation by the Crystalfontz driver?

Thanks in advance.
Looking for additional LCD resources? Check out our LCD blog for the latest developments in LCD technology.
 

CF Support2

Administrator
The CFA634 is "mute" -- it listens very well, but it does not talk back. So, there is no query command.

Since you are using the USB interface, at a system level you can check to see if the device is there, or the port exists. It will show up as a "CFA634".
 

CF Mark

Administrator
Some example code for enumerating COM ports:

Code:
# ifndef GUID_CLASS_COMPORT
   DEFINE_GUID(GUID_CLASS_COMPORT, 0x86e0d1e0L, 0x8089, 0x11d0, 0x9c, 0xe4, 0x08, 0x00, 0x3e, 0x30, 0x1f, 0x73);
# endif

void getPorts(YourPortStorageStruct *ports)
{
    // WINDOWS SERIAL ENUM
    GUID								*guidDev;
    HDEVINFO							devInfo;
    bool								bok;
    SP_DEVICE_INTERFACE_DATA			ifcData;
    DWORD								detDataSize;
    SP_DEVICE_INTERFACE_DETAIL_DATA		*detData;
    DWORD								ii;
    SP_DEVINFO_DATA						devData;
    char								tempName[1024];
    char								tempDesc[1024];
    COMHANDLE							comHandle;

    //setup
    guidDev = (GUID*)&GUID_CLASS_COMPORT;
    devInfo = SetupDiGetClassDevs(guidDev, NULL, NULL, DIGCF_PRESENT | DIGCF_DEVICEINTERFACE);
    if(devInfo == INVALID_HANDLE_VALUE)
        return ports;

    // enumerate the serial ports
    detDataSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA) + 256;
    detData = (SP_DEVICE_INTERFACE_DETAIL_DATA*)malloc(detDataSize);
    ifcData.cbSize = sizeof(SP_DEVICE_INTERFACE_DATA);
    detData->cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA);

    bok = true;
    ii = 0;
    do
    {
        bok = SetupDiEnumDeviceInterfaces(devInfo, NULL, guidDev, ii, &ifcData);
        if (bok)
        {
            //Got a device. Get the details.
            devData.cbSize = sizeof(SP_DEVINFO_DATA);
            bok = SetupDiGetDeviceInterfaceDetailW(devInfo, &ifcData, detData, detDataSize, NULL, &devData);
            if (bok)
            {
                //take note of detData->DevicePath here 
                ports[ii].availiable = false;
                ports[ii].path = detData->DevicePath;

                if (SetupDiGetDeviceRegistryPropertyW(devInfo, &devData, SPDRP_FRIENDLYNAME, NULL, (PBYTE)tempName, 512, NULL))
                    ports[i]].friendlyName = (ushort*)tempName;

                if (SetupDiGetDeviceRegistryPropertyW(devInfo, &devData, SPDRP_DEVICEDESC, NULL, (PBYTE)tempDesc, 512, NULL))
                    ports[ii].description = tempDesc;

                //test for port already used or usage error
                comHandle = CreateFile(detData->DevicePath, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
                if (comHandle != INVALID_HANDLE_VALUE)
                {
                    //port good, close it
                    ports[ii].availiable = true;
                    CloseHandle(comHandle);
                }
            }
        }
        ii++;
    } while(bok);

    if (detData != NULL)
        free(detData);

    if (devInfo != INVALID_HANDLE_VALUE)
        SetupDiDestroyDeviceInfoList(devInfo);

    return ports;
}
 
USB LCD Displays - Graphic and Character LCDs with a Keypad
Top