资源简介

ZigBee Sensor Monitor 源代码

资源截图

代码片段和文件信息

//***********************************************************************************
//*         ****
//*         ****
//*         ******o****
//*    ********_///_****        TEXAS INSTRUMENTS
//*     ******/_//_/*****
//*      ** ***(_/*****         ComPort.cpp
//*          *********
//*           *****
//*            ***
//*
//* Copyright (C) 2007-2009 Texas Instruments. All rights reserved.
//*
//* This file may be used under the terms of the GNU General Public
//* License version 2.0 as published by the Free Software Foundation
//* and appearing in the file “GNU GENERAL PUBLIC LICENSE.txt“ included in the 
//* packaging of this file.  
//*
//* This file is provided AS IS with NO WARRANTY OF ANY KIND INCLUDING THE
//* WARRANTY OF DESIGN MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
//***********************************************************************************
//* Compiler: MSVC++ 2005/2008 Express
//* Target platform: Windows+QT
//***********************************************************************************

#include 

#define _WIN32_DCOM
#include 
using namespace std;
#include 
#pragma comment(lib “WbemUuid.Lib“)
#include 
#include 
#include 

#include “comport.h“

// Definition of the functions in setupapi.dll
typedef HKEY (__stdcall SETUPDIOPENDEVREGKEY)(HDEVINFO PSP_DEVINFO_DATA DWORD DWORD DWORD REGSAM);
typedef BOOL (__stdcall SETUPDIDESTROYDEVICEINFOLIST)(HDEVINFO);
typedef BOOL (__stdcall SETUPDIENUMDEVICEINFO)(HDEVINFO DWORD PSP_DEVINFO_DATA);
typedef HDEVINFO (__stdcall SETUPDIGETCLASSDEVS)(LPGUID LPCTSTR HWND DWORD);
typedef BOOL (__stdcall SETUPDIGETDEVICEREGISTRYPROPERTY)(HDEVINFO PSP_DEVINFO_DATA DWORD PDWORD PBYTE DWORD PDWORD);

DEFINE_GUID(GUID_DEVINTERFACE_COMPORT 0x86E0D1E0L 0x8089
   0x11D0 0x9C 0xE4 0x08 0x00 0x3E 0x30 0x1F 0x73);


/** \brief Constructor
 *
 */
ComPort::ComPort(Qobject *pParent)
{

    //Initialize COM (Required by WMI)
CoInitialize(NULL);

HRESULT hr = CoInitializeSecurity(NULL -1 NULL NULL RPC_C_AUTHN_LEVEL_DEFAULT/*PKT_INTEGRITY*/ RPC_C_IMP_LEVEL_IMPERSONATE NULL 0 NULL);
if (FAILED(hr) )
{
    CoUninitialize();
}

    connect(&comPortThread SIGNAL(packetReady()) pParent SLOT(handlePacket()));

}

//-----------------------------------------------------------------------------
/** \brief Enumeration of COM port
 *
 * The enumeration of the serial COM port is executed with two methods:
 * 1. With the use of the setupapi.dll library.
 * 2. With the use of the Window Management Instrumentation (WMI)
 *
 * If both metods fails this function will return an error.
 */
//-----------------------------------------------------------------------------

int ComPort::Enum(QStringList &portList)
{
    int result = CP_ERROR;

    printf(“Start enumeration of serial port\n“);

    result = EnumSetupapi(

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     文件       17925  2010-02-11 13:23  comport.cpp
     文件        2055  2010-02-11 13:23  comport.h
     文件        1799  2010-02-11 13:23  comportcombo.cpp
     文件        1481  2010-02-11 13:23  comportcombo.h
     文件       14187  2010-02-11 13:23  comportthread.cpp
     文件        3515  2010-02-11 13:23  comportthread.h
     文件        3508  2010-02-11 13:23  edge.cpp
     文件        1756  2010-02-11 13:23  edge.h
     文件         315  2010-02-11 13:23  enumport.cpp
     文件         251  2010-02-11 13:23  enumport.h
     文件       16296  2010-02-11 13:22  GNU GENERAL PUBLIC LICENSE.txt
     目录           0  2010-03-18 22:32  images\
     文件       14161  2010-02-11 13:22  images\ButtonAbout.png
     文件       14176  2010-02-11 13:22  images\ButtonConnected.png
     文件       10978  2010-02-11 13:22  images\ButtonDisconnected.png
     文件       12225  2010-02-11 13:22  images\Buttonhelp.png
     文件       10960  2010-02-11 13:22  images\ButtonNew.png
     文件       11136  2010-02-11 13:22  images\ButtonPause.png
     文件       11310  2010-02-11 13:22  images\ButtonPlay.png
     文件       14856  2010-02-11 13:22  images\ButtonPlayGreen.png
     文件       14472  2010-02-11 13:22  images\ButtonRefresh.png
     文件       15276  2010-02-11 13:22  images\ButtonSettingsBlue.png
     文件        9851  2010-02-11 13:22  images\Buttonstop.png
     文件       44422  2010-02-11 13:22  images\chip_2.png
     文件        1771  2010-02-11 13:22  images\fileopen.png
     文件        1022  2010-02-11 13:22  images\filesave.png
     文件        3638  2010-02-11 13:22  images\ti.ico
     文件       18000  2010-02-11 13:22  images\ti_banner.png
     文件        4181  2010-02-11 13:22  images\ti_logo_red.png
     文件        8061  2010-02-11 13:23  iohandler.cpp
     文件        3101  2010-02-11 13:23  iohandler.h
............此处省略27个文件信息

评论

共有 条评论