本文整理汇总了C++中SerialDevice::Init方法的典型用法代码示例。如果您正苦于以下问题:C++ SerialDevice::Init方法的具体用法?C++ SerialDevice::Init怎么用?C++ SerialDevice::Init使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SerialDevice
的用法示例。
在下文中一共展示了SerialDevice::Init方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
status_t
usb_serial_device_added(usb_device device, void **cookie)
{
TRACE_FUNCALLS("> usb_serial_device_added(0x%08x, 0x%08x)\n", device, cookie);
status_t status = B_OK;
const usb_device_descriptor *descriptor
= gUSBModule->get_device_descriptor(device);
TRACE_ALWAYS("probing device: 0x%04x/0x%04x\n", descriptor->vendor_id,
descriptor->product_id);
*cookie = NULL;
SerialDevice *serialDevice = SerialDevice::MakeDevice(device,
descriptor->vendor_id, descriptor->product_id);
const usb_configuration_info *configuration;
for (int i = 0; i < descriptor->num_configurations; i++) {
configuration = gUSBModule->get_nth_configuration(device, i);
if (configuration == NULL)
continue;
status = serialDevice->AddDevice(configuration);
if (status == B_OK) {
// Found!
break;
}
}
if (status < B_OK) {
delete serialDevice;
return status;
}
acquire_sem(gDriverLock);
for (int32 i = 0; i < DEVICES_COUNT; i++) {
if (gSerialDevices[i] != NULL)
continue;
status = serialDevice->Init();
if (status < B_OK) {
delete serialDevice;
return status;
}
gSerialDevices[i] = serialDevice;
*cookie = serialDevice;
release_sem(gDriverLock);
TRACE_ALWAYS("%s (0x%04x/0x%04x) added\n", serialDevice->Description(),
descriptor->vendor_id, descriptor->product_id);
return B_OK;
}
release_sem(gDriverLock);
return B_ERROR;
}