[an error occurred while processing this directive]
Во - нашел - по usbio.sys опять: (+)
(«Телесистемы»: Конференция «Микроконтроллеры и их применение»)

миниатюрный аудио-видеорекордер mAVR

Отправлено SM 04 ноября 2002 г. 12:00
В ответ на: Не знаю какой драйвер, но если usbio.sys - то там специальный DeviceIoControl есть - 'bind pipe to handle' отправлено SM 04 ноября 2002 г. 11:34

IoCtlSync - это тот-же DeviceIoControl, но с ожиданием заврешения.


// open the device, in overlapped mode
DevHandle = CreateFile(
DevDetail->DevicePath,
GENERIC_READ | GENERIC_WRITE, // access mode
FILE_SHARE_WRITE | FILE_SHARE_READ, // share mode
NULL, // security desc.
OPEN_EXISTING, // how to create
FILE_FLAG_OVERLAPPED, // file attributes
NULL // template file
);
if ( DevHandle == INVALID_HANDLE_VALUE ) {
printf("Unable to open the USBIO device\n");
fclose(OutputFile);
free(DevDetail);
SetupDiDestroyDeviceInfoList(DevList);
return 1;
}
printf("Device opened\n");

// free resources
free(DevDetail);
DevDetail = NULL;
SetupDiDestroyDeviceInfoList(DevList);
DevList = NULL;


// configure the USB device
ZeroMemory(&Config,sizeof(Config));
Config.ConfigurationIndex = CONFIG_INDEX;
Config.NbOfInterfaces = CONFIG_NB_OF_INTERFACES;
Config.InterfaceList[0].InterfaceIndex = CONFIG_INTERFACE;
Config.InterfaceList[0].AlternateSettingIndex = CONFIG_ALT_SETTING;
Config.InterfaceList[0].MaximumTransferSize = CONFIG_TRAN_SIZE;
// send the configuration request
Status = IoctlSync(
DevHandle,
IOCTL_USBIO_SET_CONFIGURATION,
&Config,
sizeof(USBIO_SET_CONFIGURATION),
NULL,
0,
NULL
);
if ( Status != USBIO_ERR_SUCCESS ) {
printf("SET_CONFIGURATION failed, status=0x%08X.\n",Status);
CloseHandle(DevHandle);
fclose(OutputFile);
return 1;
}
printf("Device configured\n");

// bind the handle to a pipe
// Note: a handle can be bound to one pipe only
ZeroMemory(&BindPipe,sizeof(BindPipe));
BindPipe.EndpointAddress = (UCHAR)EndpointAddress;
// send bind request to USBIO
Status = IoctlSync(
DevHandle,
IOCTL_USBIO_BIND_PIPE,
&BindPipe,
sizeof(USBIO_BIND_PIPE),
NULL,
0,
NULL
);
if ( Status != USBIO_ERR_SUCCESS ) {
printf("Unable to bind pipe 0x%02X, status=0x%08X.\n",EndpointAddress,Status);
CloseHandle(DevHandle);
fclose(OutputFile);
return 1;
}
printf("Pipe bound to EP 0x%02X\n",EndpointAddress);


Составить ответ  |||  Конференция  |||  Архив

Ответы



Перейти к списку ответов  |||  Конференция  |||  Архив  |||  Главная страница  |||  Содержание  |||  Без кадра

E-mail: info@telesys.ru