当前位置: 首页>>代码示例>>C++>>正文


C++ DeviceInterface::deviceGetInterface方法代码示例

本文整理汇总了C++中DeviceInterface::deviceGetInterface方法的典型用法代码示例。如果您正苦于以下问题:C++ DeviceInterface::deviceGetInterface方法的具体用法?C++ DeviceInterface::deviceGetInterface怎么用?C++ DeviceInterface::deviceGetInterface使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DeviceInterface的用法示例。


在下文中一共展示了DeviceInterface::deviceGetInterface方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: printDeviceUsageLine

/**
 * @private
 */
void printDeviceUsageLine(OutputStream* outputStream, unsigned char header, Device* device, bool showOnlyProblem) {
    DeviceInterface* deviceInterface = device->deviceInterface;

    int argumentLength = deviceInterface->deviceGetInterface(header, DEVICE_MODE_INPUT, true);
    int resultLength = deviceInterface->deviceGetInterface(header, DEVICE_MODE_OUTPUT, true);
    if (showOnlyProblem) {
        OutputStream nullOutputStream;
        initNullOutputStream(&nullOutputStream);
        bool ok = printMethodOrNotificationMetaData(&nullOutputStream, deviceInterface, header, argumentLength, resultLength, false);
        // If there is a problem, we relaunch with a real outputStream
        if (!ok) {
            printMethodOrNotificationMetaData(outputStream, deviceInterface, header, argumentLength, resultLength, false);
        }
    }
    else{
        printMethodOrNotificationMetaData(outputStream, deviceInterface, header, argumentLength, resultLength, false);
    }
}
开发者ID:svanacker,项目名称:cen-electronic,代码行数:21,代码来源:deviceUsage.c

示例2: printDeviceNotification

/**
 * @private
 */
void printDeviceNotification(OutputStream* outputStream, Device* device) {
	unsigned char header;
	// Not all Device have notification, so we check it before
	for (header = 32; header < 127; header++) {
		DeviceInterface* deviceInterface = device->deviceInterface;
		int argumentLength = deviceInterface->deviceGetInterface(header, DEVICE_MODE_NOTIFY, true);
		if (argumentLength != DEVICE_HEADER_NOT_HANDLED) {
			printDeviceHeader(outputStream, device);
			break;
		}
	}

    // We start after special characters and use only ANSI chars
    for (header = 32; header < 127; header++) {
        printDeviceNotificationLine(outputStream, header, device);
    }
}
开发者ID:svanacker,项目名称:cen-electronic,代码行数:20,代码来源:deviceUsage.c

示例3: printDeviceNotificationLine

/**
 * @private
 */
void printDeviceNotificationLine(OutputStream* outputStream, unsigned char header, Device* device) {
    DeviceInterface* deviceInterface = device->deviceInterface;

    int argumentLength = deviceInterface->deviceGetInterface(header, DEVICE_MODE_NOTIFY, true);
    printMethodOrNotificationMetaData(outputStream, deviceInterface, header, argumentLength, 0, true);
}
开发者ID:svanacker,项目名称:cen-electronic,代码行数:9,代码来源:deviceUsage.c

示例4: handleStreamInstruction

bool handleStreamInstruction(Buffer* inputBuffer,
                            Buffer* outputBuffer,
                            OutputStream* outputStream,
                            filterCharFunction* inputFilterChar,
                            filterCharFunction* outputFilterChar) {

    if (inputBuffer == NULL) {
        writeError(DRIVER_STREAM_LISTENER_INPUT_BUFFER_NULL);
        return false;
    }
    if (outputBuffer == NULL) {
        writeError(DRIVER_STREAM_LISTENER_OUTPUT_BUFFER_NULL);
        return false;
    }

    // Try to clear the buffer if needed ('z' char)
    if (clearBufferIfNeeded(inputBuffer)) {
        return false;
    }

    // We received data
    int inputBufferCount = getBufferElementsCount(inputBuffer);

    if (inputBufferCount > 0) {

        if (filterFirstNextChar(inputBuffer, inputFilterChar)) {
            return false;
        }

        // As there is clear of char filtering, we must reload the size of the buffer
        int bufferSize = getBufferElementsCount(inputBuffer);

        if (bufferSize < DEVICE_HEADER_LENGTH) {
            return false;
        }

        // Get the header
        unsigned char deviceHeader = bufferGetCharAtIndex(inputBuffer, DEVICE_HEADER_INDEX);

        // Manage the dispatcher specifier (3 chars : Ex j01 before real command ...)
        unsigned char specifyDispatcherLength = 0;
        if (deviceHeader == DATA_DISPATCHER_DEVICE_HEADER) {
            specifyDispatcherLength += DISPATCHER_COMMAND_AND_INDEX_HEADER_LENGTH;
        }

        // Check if enough data
        if (bufferSize < specifyDispatcherLength + DEVICE_AND_COMMAND_HEADER_LENGTH) {
            return false;
        }

        // Reload the deviceHeader to take the dispatcher specifier if any
        deviceHeader = bufferGetCharAtIndex(inputBuffer, specifyDispatcherLength + DEVICE_HEADER_INDEX);
        unsigned char commandHeader = bufferGetCharAtIndex(inputBuffer, specifyDispatcherLength + COMMAND_HEADER_INDEX);

        // find the device corresponding to this header. It must at least be declared in local or in remote !
        unsigned char dataSize = bufferSize - specifyDispatcherLength;
        const Device* device = deviceDataDispatcherFindDevice(deviceHeader, commandHeader, dataSize, DEVICE_MODE_INPUT);

        // if the device was not found
        if (device == NULL) {
            return false;
        }

        // At this moment, device Interface is found
        DeviceInterface* deviceInterface = device->deviceInterface;

        // We must send device specifyDispatcherLength + Header + commandHeader + data => + 2
        int dataToTransferCount = deviceInterface->deviceGetInterface(commandHeader, DEVICE_MODE_INPUT, false) + specifyDispatcherLength + DEVICE_AND_COMMAND_HEADER_LENGTH;

        if (bufferSize < dataToTransferCount) {
            return false;
        }

        // We must receive ack + device header + command header + data => + 3
        int dataToReceiveCount = deviceInterface->deviceGetInterface(commandHeader, DEVICE_MODE_OUTPUT, false) + ACK_LENGTH + DEVICE_AND_COMMAND_HEADER_LENGTH;

        InputStream* bufferedInputStream = getInputStream(inputBuffer);
        OutputStream* bufferedOutputStream = getOutputStream(outputBuffer);

        TransmitMode transmitMode = device->transmitMode;

        // we handle locally the request
        if (specifyDispatcherLength == 0 && transmitMode == TRANSMIT_LOCAL) {

            // We need the implementation for local mode
            DeviceDescriptor* deviceDescriptor = device->descriptor;
            if (deviceDescriptor == NULL) {
                writeError(NO_DEVICE_DESC_FOUND_FOR);
                append(getErrorOutputStreamLogger(), deviceHeader);
                append(getErrorOutputStreamLogger(), commandHeader);
                return false;
            }

            // remove the first chars corresponding to the device header and command Header
            bufferClearLastChars(inputBuffer, DEVICE_AND_COMMAND_HEADER_LENGTH);

            // Call to the device
            deviceDescriptor->deviceHandleRawData(commandHeader, bufferedInputStream, bufferedOutputStream);

        } // we forward the request through Remote Operation with Dispatcher
//.........这里部分代码省略.........
开发者ID:Aveline67,项目名称:cen-electronic,代码行数:101,代码来源:driverStreamListener.c


注:本文中的DeviceInterface::deviceGetInterface方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。