hi,
I have currently used K8055N module and have used the K8055N dll,
I wish to know, if there is any listing of the source code for K8055N dll.
I am trying to write to the k8055 module, using Setup API c++
using this code
[code]
//global variables
HANDLE hdl_device;
HIDD_ATTRIBUTES hid_dev_attributes;
PSP_DEVICE_INTERFACE_DETAIL_DATA ptr_detail_data;
HDEVINFO hdl_dev_info;
GUID hid_guid;
HANDLE hdl_io_event;
OVERLAPPED overlap_io;
HidD_GetHidGuid(&hid_guid);
//get usb function
// Get enumerator handle for the specified ClassGuid
hdl_dev_info = SetupDiGetClassDevs(&hid_guid,
NULL,
NULL,
DIGCF_PRESENT | DIGCF_INTERFACEDEVICE );
if(hdl_dev_info)
{MessageBox(L"WORKING");
}
unsigned int interf_indexer = 0;
SP_DEVICE_INTERFACE_DATA dev_info_data;
dev_info_data.cbSize = sizeof(SP_DEVICE_INTERFACE_DATA);
// populate theInterfaceData which contains device class information
SetupDiEnumDeviceInterfaces(hdl_dev_info,
0,
&hid_guid,
interf_indexer,
&dev_info_data);
DWORD length;
// This is normally used to obtain the device path information using theInterfaceData obtained above
SetupDiGetDeviceInterfaceDetail(
hdl_dev_info,
&dev_info_data,
NULL,
0,
&length,
0 );
ptr_detail_data = reinterpret_cast<PSP_DEVICE_INTERFACE_DETAIL_DATA>
(new unsigned char[length]);
ptr_detail_data->cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA);
bool result = SetupDiGetDeviceInterfaceDetail(hdl_dev_info,
&dev_info_data,
ptr_detail_data,
length,
NULL,
NULL );
if (!result)
{
DWORD last_err = GetLastError();
delete[] ptr_detail_data;
ptr_detail_data = 0;
SetupDiDestroyDeviceInfoList(hdl_dev_info);
hdl_dev_info = 0;
CloseHandle(hdl_io_event);
hdl_io_event = 0;
}
hdl_device = CreateFile(
ptr_detail_data->DevicePath,
GENERIC_WRITE | GENERIC_READ,
FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL,
OPEN_EXISTING,
FILE_FLAG_OVERLAPPED,
NULL);
if (hdl_device != INVALID_HANDLE_VALUE)
{MessageBox(L"WORKING!!");
}
int str = 3;
DWORD bytesWritten;
bool y=WriteFile(ptr_detail_data->DevicePath, (char *)str, sizeof(str), &bytesWritten, NULL);
if(y==false)
{MessageBox(L"write failed!");
}
[/code]
I got a handle to it, but write fails.
Just learn a bit of Setup API, and I would like to know, how to use Setup API or DeviceEntry()
to access and write to K8055N to do the same as
opendevice();
SetDigitalChannel(5);
ClearDigitalChannel(5);
Thanks inadvance
derek