本文整理汇总了C++中SerialDevice类的典型用法代码示例。如果您正苦于以下问题:C++ SerialDevice类的具体用法?C++ SerialDevice怎么用?C++ SerialDevice使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SerialDevice类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: scan_isa_hardcoded
// until we support ISA device enumeration from PnP BIOS or ACPI,
// we have to probe the 4 default COM ports...
status_t
scan_isa_hardcoded()
{
#ifdef HANDLE_ISA_COM
int i;
bool serialDebug = get_safemode_boolean("serial_debug_output", true);
for (i = 0; i < 4; i++) {
// skip the port used for kernel debugging...
if (serialDebug && sHardcodedPorts[i].ioBase == gKernelDebugPort) {
TRACE_ALWAYS("Skipping port %d as it is used for kernel debug.\n", i);
continue;
}
SerialDevice *device;
device = new(std::nothrow) SerialDevice(&sSupportedDevices[0],
sHardcodedPorts[i].ioBase, sHardcodedPorts[i].irq);
if (device != NULL && device->Probe())
pc_serial_insert_device(device);
else
delete device;
}
#endif
return B_OK;
}
开发者ID:Sylvain78,项目名称:haiku,代码行数:27,代码来源:Driver.cpp
示例2: pc_serial_device_removed
status_t
pc_serial_device_removed(void *cookie)
{
TRACE_FUNCALLS("> pc_serial_device_removed(0x%08x)\n", cookie);
acquire_sem(gDriverLock);
SerialDevice *device = (SerialDevice *)cookie;
for (int32 i = 0; i < DEVICES_COUNT; i++) {
if (gSerialDevices[i] == device) {
if (device->IsOpen()) {
// the device will be deleted upon being freed
device->Removed();
} else {
delete device;
gSerialDevices[i] = NULL;
}
break;
}
}
release_sem(gDriverLock);
TRACE_FUNCRET("< pc_serial_device_removed() returns\n");
return B_OK;
}
开发者ID:illahaha,项目名称:haiku,代码行数:25,代码来源:Driver.cpp
示例3: usb_serial_close
/* usb_serial_close - handle close() calls */
static status_t
usb_serial_close(void *cookie)
{
TRACE_FUNCALLS("> usb_serial_close(0x%08x)\n", cookie);
SerialDevice *device = (SerialDevice *)cookie;
return device->Close();
}
开发者ID:mmanley,项目名称:Antares,代码行数:8,代码来源:Driver.cpp
示例4: usb_serial_deselect
/* usb_serial_deselect - handle select exit */
static status_t
usb_serial_deselect(void *cookie, uint8 event, selectsync *sync)
{
TRACE_FUNCALLS("> usb_serial_deselect(0x%08x, 0x%08x, %p)\n",
cookie, event, sync);
SerialDevice *device = (SerialDevice *)cookie;
return device->DeSelect(event, sync);
}
开发者ID:mmanley,项目名称:Antares,代码行数:9,代码来源:Driver.cpp
示例5: usb_serial_control
/* usb_serial_control - handle ioctl calls */
static status_t
usb_serial_control(void *cookie, uint32 op, void *arg, size_t length)
{
TRACE_FUNCALLS("> usb_serial_control(0x%08x, 0x%08x, 0x%08x, %d)\n",
cookie, op, arg, length);
SerialDevice *device = (SerialDevice *)cookie;
return device->Control(op, arg, length);
}
开发者ID:mmanley,项目名称:Antares,代码行数:9,代码来源:Driver.cpp
示例6: usb_serial_read
/* usb_serial_read - handle read() calls */
static status_t
usb_serial_read(void *cookie, off_t position, void *buffer, size_t *numBytes)
{
TRACE_FUNCALLS("> usb_serial_read(0x%08x, %Ld, 0x%08x, %d)\n", cookie,
position, buffer, *numBytes);
SerialDevice *device = (SerialDevice *)cookie;
return device->Read((char *)buffer, numBytes);
}
开发者ID:mmanley,项目名称:Antares,代码行数:9,代码来源:Driver.cpp
示例7: usb_serial_device_added
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;
}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:58,代码来源:Driver.cpp
示例8: usb_serial_close
/* usb_serial_close - handle close() calls */
static status_t
usb_serial_close(void *cookie)
{
TRACE_FUNCALLS("> usb_serial_close(0x%08x)\n", cookie);
SerialDevice *device = (SerialDevice *)cookie;
status_t status = device->Close();
TRACE_FUNCRET("< usb_serial_close() returns: 0x%08x\n", status);
return status;
}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:10,代码来源:Driver.cpp
示例9: usb_serial_deselect
/* usb_serial_deselect - handle select exit */
static status_t
usb_serial_deselect(void *cookie, uint8 event, selectsync *sync)
{
TRACE_FUNCALLS("> usb_serial_deselect(0x%08x, 0x%08x, %p)\n",
cookie, event, sync);
SerialDevice *device = (SerialDevice *)cookie;
status_t status = device->DeSelect(event, sync);
TRACE_FUNCRET("< usb_serial_deselect() returns: 0x%08x\n", status);
return status;
}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:11,代码来源:Driver.cpp
示例10: usb_serial_control
/* usb_serial_control - handle ioctl calls */
static status_t
usb_serial_control(void *cookie, uint32 op, void *arg, size_t length)
{
TRACE_FUNCALLS("> usb_serial_control(0x%08x, 0x%08x, 0x%08x, %d)\n",
cookie, op, arg, length);
SerialDevice *device = (SerialDevice *)cookie;
status_t status = device->Control(op, arg, length);
TRACE_FUNCRET("< usb_serial_control() returns: 0x%08x\n", status);
return status;
}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:11,代码来源:Driver.cpp
示例11:
int32
SerialDevice::DeviceThread(void *data)
{
SerialDevice *device = (SerialDevice *)data;
while (!device->fStopDeviceThread) {
status_t status = gUSBModule->queue_bulk(device->fReadPipe,
device->fReadBuffer, device->fReadBufferSize,
device->ReadCallbackFunction, data);
if (status < B_OK) {
TRACE_ALWAYS("device thread: queueing failed with error: 0x%08x\n", status);
break;
}
status = acquire_sem_etc(device->fDoneRead, 1, B_CAN_INTERRUPT, 0);
if (status < B_OK) {
TRACE_ALWAYS("device thread: failed to get read done sem 0x%08x\n", status);
break;
}
if (device->fStatusRead != B_OK) {
TRACE("device thread: device status error 0x%08x\n",
device->fStatusRead);
if (gUSBModule->clear_feature(device->fReadPipe,
USB_FEATURE_ENDPOINT_HALT) != B_OK) {
TRACE_ALWAYS("device thread: failed to clear halt feature\n");
break;
}
}
char *buffer = device->fReadBuffer;
size_t readLength = device->fActualLengthRead;
device->OnRead(&buffer, &readLength);
if (readLength == 0)
continue;
ddrover *ddr = gTTYModule->ddrstart(NULL);
if (!ddr) {
TRACE_ALWAYS("device thread: ddrstart problem\n");
return B_NO_MEMORY;
}
while (device->fInputStopped)
snooze(100);
gTTYModule->ttyilock(&device->fTTY, ddr, true);
for (size_t i = 0; i < readLength; i++)
gTTYModule->ttyin(&device->fTTY, ddr, buffer[i]);
gTTYModule->ttyilock(&device->fTTY, ddr, false);
gTTYModule->ddrdone(ddr);
}
return B_OK;
}
开发者ID:luciang,项目名称:haiku,代码行数:55,代码来源:SerialDevice.cpp
示例12: usb_serial_write
/* usb_serial_write - handle write() calls */
static status_t
usb_serial_write(void *cookie, off_t position, const void *buffer,
size_t *numBytes)
{
TRACE_FUNCALLS("> usb_serial_write(0x%08x, %Ld, 0x%08x, %d)\n", cookie,
position, buffer, *numBytes);
SerialDevice *device = (SerialDevice *)cookie;
status_t status = device->Write((const char *)buffer, numBytes);
TRACE_FUNCRET("< usb_serial_write() returns: 0x%08x\n", status);
return status;
}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:12,代码来源:Driver.cpp
示例13: scan_isa_hardcoded
// until we support ISA device enumeration from PnP BIOS or ACPI,
// we have to probe the 4 default COM ports...
status_t
scan_isa_hardcoded()
{
#ifdef HANDLE_ISA_COM
int i;
for (i = 0; i < 4; i++) {
// skip the port used for kernel debugging...
if (sHardcodedPorts[i].ioBase == gKernelDebugPort)
continue;
SerialDevice *device;
device = new(std::nothrow) SerialDevice(&sSupportedDevices[0],
sHardcodedPorts[i].ioBase, sHardcodedPorts[i].irq);
if (device != NULL && device->Probe())
pc_serial_insert_device(device);
else
delete device;
}
#endif
return B_OK;
}
开发者ID:illahaha,项目名称:haiku,代码行数:24,代码来源:Driver.cpp
示例14: usb_serial_free
/* usb_serial_free - called after last device is closed, and all i/o complete. */
static status_t
usb_serial_free(void *cookie)
{
TRACE_FUNCALLS("> usb_serial_free(0x%08x)\n", cookie);
SerialDevice *device = (SerialDevice *)cookie;
acquire_sem(gDriverLock);
status_t status = device->Free();
if (device->IsRemoved()) {
for (int32 i = 0; i < DEVICES_COUNT; i++) {
if (gSerialDevices[i] == device) {
// the device is removed already but as it was open the
// removed hook has not deleted the object
delete device;
gSerialDevices[i] = NULL;
break;
}
}
}
release_sem(gDriverLock);
return status;
}
开发者ID:mmanley,项目名称:Antares,代码行数:23,代码来源:Driver.cpp
示例15: SerialDevice
/*
*------------------------------------------------------------------------
* Method:
* Purpose:
* Input:
* Output:
* Author:
* Created:
* Remarks:
* Bugs:
*------------------------------------------------------------------------
*/
SerialDevice *SerialDevice::open(const string& port)
{
SerialDevice *dev = 0;
if (dev_map.count(port) == 0)
{
dev_map[port] = new SerialDevice(port);
}
dev = dev_map[port];
if (dev->use_count++ == 0)
{
if (!dev->openPort())
{
delete dev;
dev = 0;
}
}
return dev;
} /* SerialDevice::instance */
开发者ID:8cH9azbsFifZ,项目名称:svxlink,代码行数:34,代码来源:AsyncSerialDevice.cpp
注:本文中的SerialDevice类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论