⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 linux_dev.cpp

📁 这是在PCA下的基于IPP库示例代码例子,在网上下了IPP的库之后,设置相关参数就可以编译该代码.
💻 CPP
字号:
/*//////////////////////////////////////////////////////////////////////////////////                  INTEL CORPORATION PROPRIETARY INFORMATION//     This software is supplied under the terms of a license agreement or//     nondisclosure agreement with Intel Corporation and may not be copied//     or disclosed except in accordance with the terms of that agreement.//          Copyright(c) 2003-2005 Intel Corporation. All Rights Reserved.//*//*    This file contains class covering Linux /dev situated devices interface*/#ifdef LINUX32#include "linux_dev.h"#include "vm_debug.h"#include <sys/ioctl.h>#include <unistd.h>#include <fcntl.h>#include <vm_debug.h>UMC::StatusUMC::LinuxDev::Init(vm_char* szDevName, int iMode){    Status umcRes = UMC_OK;    assert(NULL != szDevName);    Close();    m_iHandle = open(szDevName, iMode);    if (-1 == m_iHandle) {        vm_debug_trace(7,__VM_STRING("LinuxDev::Init: %s device open error\n"),                                                                szDevName);        umcRes = UMC_FAILED_TO_OPEN_DEVICE;    }    else    {   m_iMode = iMode;    }    return umcRes;}UMC::StatusUMC::LinuxDev::Read(vm_byte* pbData, vm_var32 uiDataSize, vm_var32* puiReadSize){    Status umcRes = UMC_OK;    assert(-1 != m_iHandle);    assert(NULL != pbData);    assert(0 != uiDataSize);    if (NULL != puiReadSize)    {   *puiReadSize = 0;   }    ssize_t readRes = read(m_iHandle, pbData, uiDataSize);    switch (readRes) {    case 0:        umcRes = UMC_END_OF_STREAM;        break;    case -1:        umcRes = UMC_OPERATION_FAILED;        vm_debug_trace(7,__VM_STRING("LinuxDev::Read: read error\n"));        break;    default:        if (NULL != puiReadSize)        {   *puiReadSize = readRes; }    }    return umcRes;}UMC::StatusUMC::LinuxDev::Write(vm_byte* pbBuffer, vm_var32 uiBufSize, vm_var32* puiWroteSize){    Status umcRes = UMC_OK;    assert(-1 != m_iHandle);    assert(NULL != pbBuffer);    assert(0 != uiBufSize);    if (NULL != puiWroteSize)    {   *puiWroteSize = 0;   }    ssize_t readRes = write(m_iHandle, pbBuffer, uiBufSize);    if (-1 == readRes) {        umcRes = UMC_OPERATION_FAILED;        vm_debug_trace(7,__VM_STRING("LinuxDev::Read: read error\n"));    } else if (NULL != puiWroteSize)    {   *puiWroteSize = readRes; }    return umcRes;}UMC::StatusUMC::LinuxDev::Ioctl(int iReqCode){    Status umcRes = UMC_OK;    assert(-1 != m_iHandle);    int iRes = ioctl(m_iHandle, iReqCode);    if (-1 == iRes) {   umcRes = UMC_OPERATION_FAILED;    }    return umcRes;}UMC::StatusUMC::LinuxDev::Ioctl(int iReqCode, vm_var32 uiParam){    Status umcRes = UMC_OK;    assert(-1 != m_iHandle);    int iRes = ioctl(m_iHandle, iReqCode, uiParam);    if (-1 == iRes) {   umcRes = UMC_OPERATION_FAILED;    }    return umcRes;}voidUMC::LinuxDev::Close(){    if (-1 != m_iHandle) {        close(m_iHandle);        m_iHandle = -1;        m_iMode = 0;    }}#endif // LINUX32

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -