• 冯孟庭
    了解作者
  • QT
    开发工具
  • 20KB
    文件大小
  • zip
    文件格式
  • 0
    收藏次数
  • 1 积分
    下载积分
  • 6
    下载次数
  • 2016-04-12 10:43
    上传日期
接受GPS数据的qt工程 ,可用于linux
QtGps.zip
  • QtGps
  • qextserialport.cpp
    3.2KB
  • mainwindow.cpp
    3.2KB
  • mainwindow.ui
    7.8KB
  • mainwindow.h
    994B
  • QtGps.pro.user
    7.8KB
  • win_qextserialport.h
    4.4KB
  • win_qextserialport.cpp
    34KB
  • main.cpp
    282B
  • qextserialport.h
    867B
  • QtGps.pro
    485B
  • qextserialbase.h
    6.7KB
  • qextserialbase.cpp
    6.4KB
内容介绍
//#include <stdio.h> //#include <Process.h> //#include <QCoreApplication> //#include <QEvent> #include <QReadWriteLock> #include "win_qextserialport.h" /*! \fn Win_QextSerialPort::Win_QextSerialPort() Default constructor. Note that the name of the device used by a Win_QextSerialPort constructed with this constructor will be determined by #defined constants, or lack thereof - the default behavior is the same as _TTY_LINUX_. Possible naming conventions and their associated constants are: \verbatim Constant Used By Naming Convention ---------- ------------- ------------------------ _TTY_WIN_ Windows COM1, COM2 _TTY_IRIX_ SGI/IRIX /dev/ttyf1, /dev/ttyf2 _TTY_HPUX_ HP-UX /dev/tty1p0, /dev/tty2p0 _TTY_SUN_ SunOS/Solaris /dev/ttya, /dev/ttyb _TTY_DIGITAL_ Digital UNIX /dev/tty01, /dev/tty02 _TTY_FREEBSD_ FreeBSD /dev/ttyd0, /dev/ttyd1 _TTY_LINUX_ Linux /dev/ttyS0, /dev/ttyS1 <none> Linux /dev/ttyS0, /dev/ttyS1 \endverbatim This constructor associates the object with the first port on the system, e.g. COM1 for Windows platforms. See the other constructor if you need a port other than the first. */ Win_QextSerialPort::Win_QextSerialPort(): QextSerialBase() { Win_Handle=INVALID_HANDLE_VALUE; init(); } /*!Win_QextSerialPort::Win_QextSerialPort(const Win_QextSerialPort&) Copy constructor. */ Win_QextSerialPort::Win_QextSerialPort(const Win_QextSerialPort& s): QextSerialBase(s.port) { Win_Handle=INVALID_HANDLE_VALUE; _queryMode = s._queryMode; _bytesToWrite = s._bytesToWrite; bytesToWriteLock = new QReadWriteLock; overlapThread = new Win_QextSerialThread(this); memcpy(& overlap, & s.overlap, sizeof(OVERLAPPED)); memcpy(& overlapWrite, & s.overlapWrite, sizeof(OVERLAPPED)); setOpenMode(s.openMode()); lastErr=s.lastErr; port = s.port; Settings.FlowControl=s.Settings.FlowControl; Settings.Parity=s.Settings.Parity; Settings.DataBits=s.Settings.DataBits; Settings.StopBits=s.Settings.StopBits; Settings.BaudRate=s.Settings.BaudRate; Win_Handle=s.Win_Handle; memcpy(&Win_CommConfig, &s.Win_CommConfig, sizeof(COMMCONFIG)); memcpy(&Win_CommTimeouts, &s.Win_CommTimeouts, sizeof(COMMTIMEOUTS)); if (s.overlapThread->isRunning()) overlapThread->start(); } /*! \fn Win_QextSerialPort::Win_QextSerialPort(const QString & name) Constructs a serial port attached to the port specified by devName. devName is the name of the device, which is windowsystem-specific, e.g."COM2" or "/dev/ttyS0". */ Win_QextSerialPort::Win_QextSerialPort(const QString & name, QextSerialBase::QueryMode mode): QextSerialBase(name) { Win_Handle=INVALID_HANDLE_VALUE; setQueryMode(mode); init(); } /*! \fn Win_QextSerialPort::Win_QextSerialPort(const PortSettings& settings) Constructs a port with default name and specified settings. */ Win_QextSerialPort::Win_QextSerialPort(const PortSettings& settings, QextSerialBase::QueryMode mode) { Win_Handle=INVALID_HANDLE_VALUE; setBaudRate(settings.BaudRate); setDataBits(settings.DataBits); setStopBits(settings.StopBits); setParity(settings.Parity); setFlowControl(settings.FlowControl); setTimeout(settings.Timeout_Millisec); setQueryMode(mode); init(); } /*! \fn Win_QextSerialPort::Win_QextSerialPort(const QString & name, const PortSettings& settings) Constructs a port with specified name and settings. */ Win_QextSerialPort::Win_QextSerialPort(const QString & name, const PortSettings& settings, QextSerialBase::QueryMode mode) { Win_Handle=INVALID_HANDLE_VALUE; setPortName(name); setBaudRate(settings.BaudRate); setDataBits(settings.DataBits); setStopBits(settings.StopBits); setParity(settings.Parity); setFlowControl(settings.FlowControl); setTimeout(settings.Timeout_Millisec); setQueryMode(mode); init(); } void Win_QextSerialPort::init() { _bytesToWrite = 0; overlap.Internal = 0; overlap.InternalHigh = 0; overlap.Offset = 0; overlap.OffsetHigh = 0; overlap.hEvent = CreateEvent(NULL, true, false, NULL); overlapThread = new Win_QextSerialThread(this); bytesToWriteLock = new QReadWriteLock; } /*! \fn Win_QextSerialPort::~Win_QextSerialPort() Standard destructor. */ Win_QextSerialPort::~Win_QextSerialPort() { if (isOpen()) { close(); } CloseHandle(overlap.hEvent); delete overlapThread; delete bytesToWriteLock; } /*! \fn Win_QextSerialPort& Win_QextSerialPort::operator=(const Win_QextSerialPort& s) overrides the = operator */ Win_QextSerialPort& Win_QextSerialPort::operator=(const Win_QextSerialPort& s) { setOpenMode(s.openMode()); _queryMode = s._queryMode; _bytesToWrite = s._bytesToWrite; bytesToWriteLock = new QReadWriteLock; overlapThread = new Win_QextSerialThread(this); memcpy(& overlap, & s.overlap, sizeof(OVERLAPPED)); memcpy(& overlapWrite, & s.overlapWrite, sizeof(OVERLAPPED)); lastErr=s.lastErr; port = s.port; Settings.FlowControl=s.Settings.FlowControl; Settings.Parity=s.Settings.Parity; Settings.DataBits=s.Settings.DataBits; Settings.StopBits=s.Settings.StopBits; Settings.BaudRate=s.Settings.BaudRate; Win_Handle=s.Win_Handle; memcpy(&Win_CommConfig, &s.Win_CommConfig, sizeof(COMMCONFIG)); memcpy(&Win_CommTimeouts, &s.Win_CommTimeouts, sizeof(COMMTIMEOUTS)); if (s.overlapThread->isRunning()) overlapThread->start(); return *this; } /*! \fn bool Win_QextSerialPort::open(OpenMode mode) Opens a serial port. Note that this function does not specify which device to open. If you need to open a device by name, see Win_QextSerialPort::open(const char*). This function has no effect if the port associated with the class is already open. The port is also configured to the current settings, as stored in the Settings structure. */ bool Win_QextSerialPort::open(OpenMode mode) { unsigned long confSize = sizeof(COMMCONFIG); Win_CommConfig.dwSize = confSize; DWORD dwFlagsAndAttributes = 0; if (queryMode() == QextSerialBase::EventDriven) dwFlagsAndAttributes += FILE_FLAG_OVERLAPPED; LOCK_MUTEX(); if (mode == QIODevice::NotOpen) return isOpen(); if (!isOpen()) { /*open the port*/ Win_Handle=CreateFileA(port.toAscii(), GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, dwFlagsAndAttributes, NULL); if (Win_Handle!=INVALID_HANDLE_VALUE) { /*configure port settings*/ GetCommConfig(Win_Handle, &Win_CommConfig, &confSize); GetCommState(Win_Handle, &(Win_CommConfig.dcb)); /*set up parameters*/ Win_CommConfig.dcb.fBinary=TRUE; Win_CommConfig.dcb.fInX=FALSE; Win_CommConfig.dcb.fOutX=FALSE; Win_CommConfig.dcb.fAbortOnError=FALSE; Win_CommConfig.dcb.fNull=FALSE; setBaudRate(Settings.BaudRate); setDataBits(Settings.DataBits); setStopBits(Settings.StopBits); setParity(Settings.Parity); setFlowControl(Settings.FlowControl); setTimeout(Settings.Timeout_Millisec); SetCommConfig(Win_Handle, &Win_CommConfig, sizeof(COMMCONFIG)); //init event driven approach if (queryMode() == QextSerialBase::EventDriven) { Win_CommTimeouts.ReadIntervalTimeout = MAXDWORD; Win_CommTimeouts.ReadTotalTimeoutMultiplier = 0; Win_CommTimeouts.ReadTotalTimeoutConstant = 0; Win_CommTimeouts.WriteTotalTimeoutMultiplier = 0; Win_CommTimeouts.WriteTotalTimeoutConstant = 0; SetCommTimeouts(Win_Handle, &Win_CommTimeouts);
评论
    相关推荐
    • GPS-QT4.rar
      XC2440开发板提供的GPS程序,用QT4进行设计的,运行子啊Embedded Linux系统中。。
    • GPS.rar
      嵌入式系統PXA310實作GPS定位顯示
    • QtGps.rar
      qt实现的飞信部分功能,应用网络传输!
    • gps.zip
      实现GPS的信息读取定位时间的读取 在QT平台上 对初学者帮助很大
    • GPS导航仪模拟程序(LINUX
      模拟GPS导航仪的定位功能。通过Linux平台实现程序代码的编写,用QT做的图形界面,实现解析GPS数据包的功能。
    • ARM-LINUX-GPS
      是在arm平台下的,linux系统的GPS程序 ARM-LINUX-GPS
    • 嵌入式linuxQT开发GPRS源码
      是基于嵌入式linuxQT开发的gprs源码,并且源码里面最重要还有一份QT界面的控件说明文档等等,源码经测试,直接可编译使用
    • 嵌入式linuxQT4开发GPS定位源码
      是基于嵌入式linuxQT4开发的gps定位源码,里面源码中程序启动后,设置好 波特率和 com,点击 read 按钮,将读取卫星定位信息,如经度纬度时间高度等信息等等,经测试,直接可编译使用
    • QtGps.rar
      实现了windows下通过串口等获取gps的经纬度数据
    • NS2example.rar
      在ns2下实现无线传感器网络仿真,多个节点进行网络活动