mirror of
https://gitee.com/drabel/LibQQt.git
synced 2025-01-04 10:18:44 +08:00
fix macx macro missing
This commit is contained in:
parent
1ddd6ac321
commit
64f03d3f34
@ -3,6 +3,7 @@ CONFIG += ordered
|
|||||||
SUBDIRS += \
|
SUBDIRS += \
|
||||||
src/qqt.pro \
|
src/qqt.pro \
|
||||||
examples/qqtframe \
|
examples/qqtframe \
|
||||||
|
examples/qqtframe2 \
|
||||||
# examples/animationframe \
|
# examples/animationframe \
|
||||||
# examples/cmdwidget \
|
# examples/cmdwidget \
|
||||||
# examples/qqtliveplayer \
|
# examples/qqtliveplayer \
|
||||||
@ -10,6 +11,6 @@ SUBDIRS += \
|
|||||||
# examples/qqtftpclient \
|
# examples/qqtftpclient \
|
||||||
# examples/qqthttpclient \
|
# examples/qqthttpclient \
|
||||||
# examples/qqtwebkit
|
# examples/qqtwebkit
|
||||||
examples/qqtframe2
|
|
||||||
|
|
||||||
#include(src/qqt.pri)
|
#include(src/qqt.pri)
|
||||||
|
@ -18,11 +18,6 @@ QT += core gui network sql xml
|
|||||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets printsupport serialport
|
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets printsupport serialport
|
||||||
greaterThan(QT_MAJOR_VERSION, 4): DEFINES += __QT5__
|
greaterThan(QT_MAJOR_VERSION, 4): DEFINES += __QT5__
|
||||||
|
|
||||||
TARGET = QtBuildTool
|
|
||||||
TEMPLATE = app
|
|
||||||
macx {
|
|
||||||
CONFIG += app_bundle
|
|
||||||
}
|
|
||||||
|
|
||||||
QT_KIT = $$(QKIT)
|
QT_KIT = $$(QKIT)
|
||||||
message($${QT_KIT} Defined in $${TARGET})
|
message($${QT_KIT} Defined in $${TARGET})
|
||||||
@ -43,6 +38,12 @@ equals(QT_KIT, MIPS32) {
|
|||||||
DEFINES += __ANDROID__
|
DEFINES += __ANDROID__
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TARGET = QtBuildTool
|
||||||
|
TEMPLATE = app
|
||||||
|
equals(QT_KIT, macOS) {
|
||||||
|
CONFIG += app_bundle
|
||||||
|
}
|
||||||
|
|
||||||
CONFIG(debug, debug|release) {
|
CONFIG(debug, debug|release) {
|
||||||
} else {
|
} else {
|
||||||
DEFINES -= QT_NO_DEBUG_OUTPUT
|
DEFINES -= QT_NO_DEBUG_OUTPUT
|
||||||
@ -72,7 +73,7 @@ INCLUDEPATH += $$PWD \
|
|||||||
$$PWD/../../src/frame
|
$$PWD/../../src/frame
|
||||||
|
|
||||||
#include(../../src/qqt.pri)
|
#include(../../src/qqt.pri)
|
||||||
macx {
|
equals(QT_KIT, macOS) {
|
||||||
LIBS += -F/Users/abel/Develop/c0-buildstation/a0-qqtfoundation/MacOS/Release/src/bin
|
LIBS += -F/Users/abel/Develop/c0-buildstation/a0-qqtfoundation/MacOS/Release/src/bin
|
||||||
LIBS += -framework QQt
|
LIBS += -framework QQt
|
||||||
}
|
}
|
||||||
@ -97,7 +98,7 @@ can_install:equals(QT_KIT, MIPS32) {
|
|||||||
target.path = /Application
|
target.path = /Application
|
||||||
INSTALLS += target
|
INSTALLS += target
|
||||||
} else: unix {
|
} else: unix {
|
||||||
macx{
|
equals(QT_KIT, macOS){
|
||||||
target.path = /Applications
|
target.path = /Applications
|
||||||
INSTALLS += target
|
INSTALLS += target
|
||||||
}
|
}
|
||||||
|
@ -20,9 +20,6 @@ greaterThan(QT_MAJOR_VERSION, 4): DEFINES += __QT5__
|
|||||||
|
|
||||||
TARGET = qqtframe2
|
TARGET = qqtframe2
|
||||||
TEMPLATE = app
|
TEMPLATE = app
|
||||||
macx {
|
|
||||||
CONFIG += app_bundle
|
|
||||||
}
|
|
||||||
|
|
||||||
QT_KIT = $$(QKIT)
|
QT_KIT = $$(QKIT)
|
||||||
message($${QT_KIT} Defined in $${TARGET})
|
message($${QT_KIT} Defined in $${TARGET})
|
||||||
@ -42,6 +39,9 @@ equals(QT_KIT, MIPS32) {
|
|||||||
} else:equals(QT_KIT, Android) {
|
} else:equals(QT_KIT, Android) {
|
||||||
DEFINES += __ANDROID__
|
DEFINES += __ANDROID__
|
||||||
}
|
}
|
||||||
|
equals(QT_KIT, macOS) {
|
||||||
|
CONFIG += app_bundle
|
||||||
|
}
|
||||||
|
|
||||||
CONFIG(debug, debug|release) {
|
CONFIG(debug, debug|release) {
|
||||||
} else {
|
} else {
|
||||||
@ -72,7 +72,7 @@ INCLUDEPATH += $$PWD \
|
|||||||
$$PWD/../../src/frame
|
$$PWD/../../src/frame
|
||||||
|
|
||||||
#include(../../src/qqt.pri)
|
#include(../../src/qqt.pri)
|
||||||
macx {
|
equals(QT_KIT, macOS) {
|
||||||
LIBS += -F/Users/abel/Develop/c0-buildstation/a0-qqtfoundation/MacOS/Release/src/bin
|
LIBS += -F/Users/abel/Develop/c0-buildstation/a0-qqtfoundation/MacOS/Release/src/bin
|
||||||
LIBS += -framework QQt
|
LIBS += -framework QQt
|
||||||
}
|
}
|
||||||
@ -97,7 +97,7 @@ can_install:equals(QT_KIT, MIPS32) {
|
|||||||
target.path = /Application
|
target.path = /Application
|
||||||
INSTALLS += target
|
INSTALLS += target
|
||||||
} else: unix {
|
} else: unix {
|
||||||
macx{
|
equals(QT_KIT, macOS){
|
||||||
target.path = /Applications
|
target.path = /Applications
|
||||||
INSTALLS += target
|
INSTALLS += target
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ HEADERS += $$PWD/qqtapp.h $$PWD/qqtwindow.h \
|
|||||||
FORMS += $$PWD/qqtwindow.ui
|
FORMS += $$PWD/qqtwindow.ui
|
||||||
|
|
||||||
unix {
|
unix {
|
||||||
macx{
|
equals(QT_KIT, macOS){
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
INCLUDEPATH += /usr/include/x86_64-linux-gnu
|
INCLUDEPATH += /usr/include/x86_64-linux-gnu
|
||||||
|
@ -10,9 +10,6 @@ greaterThan(QT_MAJOR_VERSION, 4): DEFINES += __QT5__
|
|||||||
|
|
||||||
TARGET = qqtframe
|
TARGET = qqtframe
|
||||||
TEMPLATE = app
|
TEMPLATE = app
|
||||||
macx {
|
|
||||||
CONFIG += app_bundle
|
|
||||||
}
|
|
||||||
|
|
||||||
QT_KIT = $$(QKIT)
|
QT_KIT = $$(QKIT)
|
||||||
message($${QT_KIT} Defined in qqtframe)
|
message($${QT_KIT} Defined in qqtframe)
|
||||||
@ -22,15 +19,23 @@ equals(QT_KIT, MIPS32) {
|
|||||||
} else:equals(QT_KIT, LINUX) {
|
} else:equals(QT_KIT, LINUX) {
|
||||||
DEFINES += __LINUX__
|
DEFINES += __LINUX__
|
||||||
} else:equals(QT_KIT, LINUX64) {
|
} else:equals(QT_KIT, LINUX64) {
|
||||||
|
DEFINES += __LINUX__
|
||||||
DEFINES += __LINUX64__
|
DEFINES += __LINUX64__
|
||||||
} else:equals(QT_KIT, WIN) {
|
} else:equals(QT_KIT, WIN) {
|
||||||
DEFINES += __WIN__
|
DEFINES += __WIN__
|
||||||
} else:equals(QT_KIT, WIN64) {
|
} else:equals(QT_KIT, WIN64) {
|
||||||
|
DEFINES += __WIN__
|
||||||
DEFINES += __WIN64__
|
DEFINES += __WIN64__
|
||||||
} else:equals(QT_KIT, macOS) {
|
} else:equals(QT_KIT, macOS) {
|
||||||
DEFINES += __DARWIN__
|
DEFINES += __DARWIN__
|
||||||
} else:equals(QT_KIT, Android) {
|
} else:equals(QT_KIT, Android) {
|
||||||
DEFINES += __ANDROID__
|
DEFINES += __ANDROID__
|
||||||
|
} else:equals(QT_KIT, ANDROIDX86) {
|
||||||
|
DEFINES += __ANDROID__
|
||||||
|
DEFINES += __ANDROIDX86__
|
||||||
|
}
|
||||||
|
equals(QT_KIT, macOS) {
|
||||||
|
CONFIG += app_bundle
|
||||||
}
|
}
|
||||||
|
|
||||||
CONFIG(debug, debug|release) {
|
CONFIG(debug, debug|release) {
|
||||||
@ -62,12 +67,20 @@ INCLUDEPATH += $$PWD \
|
|||||||
$$PWD/../../src/frame
|
$$PWD/../../src/frame
|
||||||
|
|
||||||
#include(../../src/qqt.pri)
|
#include(../../src/qqt.pri)
|
||||||
macx {
|
message(Link QQt to $${TARGET} $${QT_KIT} on $${QMAKE_HOST.os})
|
||||||
|
equals(QMAKE_HOST.os, Darwin) {
|
||||||
|
equals(QT_KIT, macOS) {
|
||||||
LIBS += -F/Users/abel/Develop/c0-buildstation/a0-qqtfoundation/MacOS/Release/src/bin
|
LIBS += -F/Users/abel/Develop/c0-buildstation/a0-qqtfoundation/MacOS/Release/src/bin
|
||||||
LIBS += -framework QQt
|
LIBS += -framework QQt
|
||||||
}
|
} else: equals(QT_KIT, Android) {
|
||||||
equals(QT_KIT, Android) {
|
LIBS += -L/Users/abel/Develop/c0-buildstation/a0-qqtfoundation/Android/Release/src/bin
|
||||||
LIBS += -L/Users/abel/Develop/c0-buildstation/a0-qqtfoundation/Android-arm/Release/src/bin
|
LIBS += -lQQt
|
||||||
|
} else: equals(QT_KIT, ANDROIDX86) {
|
||||||
|
LIBS += -L/Users/abel/Develop/c0-buildstation/a0-qqtfoundation/Android_x86/Release/src/bin
|
||||||
|
LIBS += -lQQt
|
||||||
|
}
|
||||||
|
} else: equals(QMAKE_HOST.os, Linux) {
|
||||||
|
LIBS += -L/mnt/hgfs/abel/Develop/c0-buildstation/a0-qqtfoundation/Linux/Release/src/bin
|
||||||
LIBS += -lQQt
|
LIBS += -lQQt
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,7 +100,7 @@ can_install:equals(QT_KIT, MIPS32) {
|
|||||||
target.path = /Application
|
target.path = /Application
|
||||||
INSTALLS += target
|
INSTALLS += target
|
||||||
} else: unix {
|
} else: unix {
|
||||||
macx{
|
equals(QT_KIT, macOS){
|
||||||
target.path = /Applications
|
target.path = /Applications
|
||||||
INSTALLS += target
|
INSTALLS += target
|
||||||
}
|
}
|
||||||
|
@ -18,12 +18,6 @@ QT += core gui network sql xml
|
|||||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets printsupport serialport
|
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets printsupport serialport
|
||||||
greaterThan(QT_MAJOR_VERSION, 4): DEFINES += __QT5__
|
greaterThan(QT_MAJOR_VERSION, 4): DEFINES += __QT5__
|
||||||
|
|
||||||
TARGET = qqtframe2
|
|
||||||
TEMPLATE = app
|
|
||||||
macx {
|
|
||||||
CONFIG += app_bundle
|
|
||||||
}
|
|
||||||
|
|
||||||
QT_KIT = $$(QKIT)
|
QT_KIT = $$(QKIT)
|
||||||
message($${QT_KIT} Defined in $${TARGET})
|
message($${QT_KIT} Defined in $${TARGET})
|
||||||
equals(QT_KIT, MIPS32) {
|
equals(QT_KIT, MIPS32) {
|
||||||
@ -43,6 +37,13 @@ equals(QT_KIT, MIPS32) {
|
|||||||
DEFINES += __ANDROID__
|
DEFINES += __ANDROID__
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TARGET = qqtframe2
|
||||||
|
TEMPLATE = app
|
||||||
|
|
||||||
|
equals(QT_KIT, macOS) {
|
||||||
|
CONFIG += app_bundle
|
||||||
|
}
|
||||||
|
|
||||||
CONFIG(debug, debug|release) {
|
CONFIG(debug, debug|release) {
|
||||||
} else {
|
} else {
|
||||||
DEFINES -= QT_NO_DEBUG_OUTPUT
|
DEFINES -= QT_NO_DEBUG_OUTPUT
|
||||||
@ -72,12 +73,20 @@ INCLUDEPATH += $$PWD \
|
|||||||
$$PWD/../../src/frame
|
$$PWD/../../src/frame
|
||||||
|
|
||||||
#include(../../src/qqt.pri)
|
#include(../../src/qqt.pri)
|
||||||
macx {
|
message(Link QQt to $${TARGET} $${QT_KIT} on $${QMAKE_HOST.os})
|
||||||
|
equals(QMAKE_HOST.os, Darwin) {
|
||||||
|
equals(QT_KIT, macOS) {
|
||||||
LIBS += -F/Users/abel/Develop/c0-buildstation/a0-qqtfoundation/MacOS/Release/src/bin
|
LIBS += -F/Users/abel/Develop/c0-buildstation/a0-qqtfoundation/MacOS/Release/src/bin
|
||||||
LIBS += -framework QQt
|
LIBS += -framework QQt
|
||||||
}
|
} else: equals(QT_KIT, Android) {
|
||||||
equals(QT_KIT, Android) {
|
LIBS += -L/Users/abel/Develop/c0-buildstation/a0-qqtfoundation/Android/Release/src/bin
|
||||||
LIBS += -L/Users/abel/Develop/c0-buildstation/a0-qqtfoundation/Android-arm/Release/src/bin
|
LIBS += -lQQt
|
||||||
|
} else: equals(QT_KIT, ANDROIDX86) {
|
||||||
|
LIBS += -L/Users/abel/Develop/c0-buildstation/a0-qqtfoundation/Android_x86/Release/src/bin
|
||||||
|
LIBS += -lQQt
|
||||||
|
}
|
||||||
|
} else: equals(QMAKE_HOST.os, Linux) {
|
||||||
|
LIBS += -L/mnt/hgfs/abel/Develop/c0-buildstation/a0-qqtfoundation/Linux/Release/src/bin
|
||||||
LIBS += -lQQt
|
LIBS += -lQQt
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,7 +106,7 @@ can_install:equals(QT_KIT, MIPS32) {
|
|||||||
target.path = /Application
|
target.path = /Application
|
||||||
INSTALLS += target
|
INSTALLS += target
|
||||||
} else: unix {
|
} else: unix {
|
||||||
macx{
|
equals(QT_KIT, macOS) {
|
||||||
target.path = /Applications
|
target.path = /Applications
|
||||||
INSTALLS += target
|
INSTALLS += target
|
||||||
}
|
}
|
||||||
|
6
src/network/qqtbluetoothmanager.cpp
Normal file
6
src/network/qqtbluetoothmanager.cpp
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#include "qqtbluetoothmanager.h"
|
||||||
|
|
||||||
|
QQtBluetoothManager::QQtBluetoothManager(QObject *parent) : QObject(parent)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
17
src/network/qqtbluetoothmanager.h
Normal file
17
src/network/qqtbluetoothmanager.h
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
#ifndef QQTBLUETOOTHMANAGER_H
|
||||||
|
#define QQTBLUETOOTHMANAGER_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
class QQtBluetoothManager : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit QQtBluetoothManager(QObject *parent = nullptr);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // QQTBLUETOOTHMANAGER_H
|
90
src/qqt.pri
90
src/qqt.pri
@ -11,7 +11,7 @@ unix:VERSION = 1.0.0
|
|||||||
|
|
||||||
##Qt version
|
##Qt version
|
||||||
QT += core gui network sql xml
|
QT += core gui network sql xml
|
||||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets printsupport serialport
|
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets printsupport
|
||||||
|
|
||||||
#############
|
#############
|
||||||
##definition
|
##definition
|
||||||
@ -34,17 +34,23 @@ equals(QT_KIT, MIPS32) {
|
|||||||
} else:equals(QT_KIT, LINUX) {
|
} else:equals(QT_KIT, LINUX) {
|
||||||
DEFINES += __LINUX__
|
DEFINES += __LINUX__
|
||||||
} else:equals(QT_KIT, LINUX64) {
|
} else:equals(QT_KIT, LINUX64) {
|
||||||
|
DEFINES += __LINUX__
|
||||||
DEFINES += __LINUX64__
|
DEFINES += __LINUX64__
|
||||||
} else:equals(QT_KIT, WIN) {
|
} else:equals(QT_KIT, WIN) {
|
||||||
DEFINES += __WIN__
|
DEFINES += __WIN__
|
||||||
} else:equals(QT_KIT, WIN64) {
|
} else:equals(QT_KIT, WIN64) {
|
||||||
|
DEFINES += __WIN__
|
||||||
DEFINES += __WIN64__
|
DEFINES += __WIN64__
|
||||||
} else:equals(QT_KIT, macOS) {
|
} else:equals(QT_KIT, macOS) {
|
||||||
DEFINES += __DARWIN__
|
DEFINES += __DARWIN__
|
||||||
} else:equals(QT_KIT, Android) {
|
} else:equals(QT_KIT, Android) {
|
||||||
DEFINES += __ANDROID__
|
DEFINES += __ANDROID__
|
||||||
#TODO:no customplot word printer
|
} else:equals(QT_KIT, ANDROIDX86) {
|
||||||
|
DEFINES += __ANDROID__
|
||||||
|
DEFINES += __ANDROIDX86__
|
||||||
|
#todo:no customplot word printer
|
||||||
}
|
}
|
||||||
|
|
||||||
CONFIG(debug, debug|release) {
|
CONFIG(debug, debug|release) {
|
||||||
} else {
|
} else {
|
||||||
DEFINES -= QT_NO_DEBUG_OUTPUT
|
DEFINES -= QT_NO_DEBUG_OUTPUT
|
||||||
@ -60,7 +66,7 @@ win32 {
|
|||||||
win32 {
|
win32 {
|
||||||
LIBS += -luser32
|
LIBS += -luser32
|
||||||
}else: unix {
|
}else: unix {
|
||||||
macx {
|
equals(QT_KIT, macOS) {
|
||||||
#min macosx target
|
#min macosx target
|
||||||
QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.9
|
QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.9
|
||||||
#deperated
|
#deperated
|
||||||
@ -87,7 +93,6 @@ DESTDIR = bin
|
|||||||
##include directories
|
##include directories
|
||||||
###########################
|
###########################
|
||||||
INCLUDEPATH += $$PWD
|
INCLUDEPATH += $$PWD
|
||||||
INCLUDEPATH += $$PWD/serialport
|
|
||||||
INCLUDEPATH += $$PWD/core
|
INCLUDEPATH += $$PWD/core
|
||||||
INCLUDEPATH += $$PWD/customplot
|
INCLUDEPATH += $$PWD/customplot
|
||||||
INCLUDEPATH += $$PWD/dmmu
|
INCLUDEPATH += $$PWD/dmmu
|
||||||
@ -95,6 +100,7 @@ INCLUDEPATH += $$PWD/frame
|
|||||||
INCLUDEPATH += $$PWD/gui
|
INCLUDEPATH += $$PWD/gui
|
||||||
INCLUDEPATH += $$PWD/multimedia
|
INCLUDEPATH += $$PWD/multimedia
|
||||||
INCLUDEPATH += $$PWD/network
|
INCLUDEPATH += $$PWD/network
|
||||||
|
INCLUDEPATH += $$PWD/network/qextserialport
|
||||||
INCLUDEPATH += $$PWD/pluginwatcher
|
INCLUDEPATH += $$PWD/pluginwatcher
|
||||||
INCLUDEPATH += $$PWD/printsupport
|
INCLUDEPATH += $$PWD/printsupport
|
||||||
INCLUDEPATH += $$PWD/sql
|
INCLUDEPATH += $$PWD/sql
|
||||||
@ -106,7 +112,7 @@ win32 {
|
|||||||
HEADERS += $$PWD/qqtwin.h
|
HEADERS += $$PWD/qqtwin.h
|
||||||
}
|
}
|
||||||
unix {
|
unix {
|
||||||
macx {
|
equals(QT_KIT, macOS) {
|
||||||
HEADERS += $$PWD/qqtdarwin.h
|
HEADERS += $$PWD/qqtdarwin.h
|
||||||
} else {
|
} else {
|
||||||
HEADERS += $$PWD/qqtlinux.h
|
HEADERS += $$PWD/qqtlinux.h
|
||||||
@ -118,13 +124,48 @@ HEADERS += $$PWD/qqt.h \
|
|||||||
$$PWD/qqt-qt.h
|
$$PWD/qqt-qt.h
|
||||||
|
|
||||||
|
|
||||||
#serialport
|
#network
|
||||||
|
equals(QT_KIT, MIPS32) {
|
||||||
|
SOURCES += $$PWD/network/qqtethenetmanager.cpp
|
||||||
|
HEADERS += $$PWD/network/qqtethenetmanager.h
|
||||||
|
}
|
||||||
|
##websocket
|
||||||
|
SOURCES += $$PWD/network/qqtwebclient.cpp \
|
||||||
|
$$PWD/network/qqtftpprotocol.cpp \
|
||||||
|
$$PWD/network/qqthttpprotocol.cpp \
|
||||||
|
$$PWD/network/qqtwebprotocol.cpp
|
||||||
|
HEADERS += $$PWD/network/qqtwebclient.h \
|
||||||
|
$$PWD/network/qqtftpprotocol.h \
|
||||||
|
$$PWD/network/qqthttpprotocol.h \
|
||||||
|
$$PWD/network/qqtwebprotocol.h
|
||||||
|
#tcpsocket
|
||||||
|
SOURCES += \
|
||||||
|
$$PWD/network/qqtclient.cpp \
|
||||||
|
$$PWD/network/qqtserialport.cpp \
|
||||||
|
$$PWD/network/qqtserver.cpp \
|
||||||
|
$$PWD/network/qqtmessage.cpp \
|
||||||
|
$$PWD/network/qqtprotocol.cpp \
|
||||||
|
$$PWD/network/qqtnetwork.cpp
|
||||||
|
HEADERS += \
|
||||||
|
$$PWD/network/qqtclient.h \
|
||||||
|
$$PWD/network/qqtserialport.h \
|
||||||
|
$$PWD/network/qqtserver.h \
|
||||||
|
$$PWD/network/qqtmessage.h \
|
||||||
|
$$PWD/network/qqtprotocol.h \
|
||||||
|
$$PWD/network/qqtnetwork.h
|
||||||
|
#bluetooth
|
||||||
|
SOURCES += \
|
||||||
|
$$PWD/network/qqtbluetoothmanager.cpp
|
||||||
|
HEADERS += \
|
||||||
|
$$PWD/network/qqtbluetoothmanager.h
|
||||||
|
#qserialport
|
||||||
#USE QEXTSERIALPORT
|
#USE QEXTSERIALPORT
|
||||||
#DEFINES += __QTEXTSERIALPORT__
|
#DEFINES += __QTEXTSERIALPORT__
|
||||||
contains (DEFINES, __QTEXTSERIALPORT__) {
|
contains (DEFINES, __QTEXTSERIALPORT__) {
|
||||||
message ( __QTEXTSERIALPORT__ defined in qqtfoundation)
|
message ( __QTEXTSERIALPORT__ Defined in qqtfoundation)
|
||||||
include ( $$PWD/serialport/qextserialport.pri )
|
include ( $$PWD/network/qextserialport/qextserialport.pri )
|
||||||
} else {
|
} else {
|
||||||
|
greaterThan(QT_MAJOR_VERSION, 4): QT += serialport
|
||||||
lessThan(QT_MAJOR_VERSION, 5): CONFIG += serialport
|
lessThan(QT_MAJOR_VERSION, 5): CONFIG += serialport
|
||||||
unix {
|
unix {
|
||||||
DEFINES += _TTY_POSIX_
|
DEFINES += _TTY_POSIX_
|
||||||
@ -232,37 +273,6 @@ HEADERS += \
|
|||||||
SOURCES += $$PWD/multimedia/qqtmplayer.cpp
|
SOURCES += $$PWD/multimedia/qqtmplayer.cpp
|
||||||
HEADERS += $$PWD/multimedia/qqtmplayer.h
|
HEADERS += $$PWD/multimedia/qqtmplayer.h
|
||||||
|
|
||||||
|
|
||||||
#network
|
|
||||||
equals(QT_KIT, MIPS32) {
|
|
||||||
SOURCES += $$PWD/network/qqtethenetmanager.cpp
|
|
||||||
HEADERS += $$PWD/network/qqtethenetmanager.h
|
|
||||||
}
|
|
||||||
##websocket
|
|
||||||
SOURCES += $$PWD/network/qqtwebclient.cpp \
|
|
||||||
$$PWD/network/qqtftpprotocol.cpp \
|
|
||||||
$$PWD/network/qqthttpprotocol.cpp \
|
|
||||||
$$PWD/network/qqtwebprotocol.cpp
|
|
||||||
HEADERS += $$PWD/network/qqtwebclient.h \
|
|
||||||
$$PWD/network/qqtftpprotocol.h \
|
|
||||||
$$PWD/network/qqthttpprotocol.h \
|
|
||||||
$$PWD/network/qqtwebprotocol.h
|
|
||||||
#tcpsocket
|
|
||||||
SOURCES += \
|
|
||||||
$$PWD/network/qqtclient.cpp \
|
|
||||||
$$PWD/network/qqtserialport.cpp \
|
|
||||||
$$PWD/network/qqtserver.cpp \
|
|
||||||
$$PWD/network/qqtmessage.cpp \
|
|
||||||
$$PWD/network/qqtprotocol.cpp \
|
|
||||||
$$PWD/network/qqtnetwork.cpp
|
|
||||||
HEADERS += \
|
|
||||||
$$PWD/network/qqtclient.h \
|
|
||||||
$$PWD/network/qqtserialport.h \
|
|
||||||
$$PWD/network/qqtserver.h \
|
|
||||||
$$PWD/network/qqtmessage.h \
|
|
||||||
$$PWD/network/qqtprotocol.h \
|
|
||||||
$$PWD/network/qqtnetwork.h
|
|
||||||
|
|
||||||
#pluginwatcher
|
#pluginwatcher
|
||||||
contains (DEFINES, QQT_LIBRARY) {
|
contains (DEFINES, QQT_LIBRARY) {
|
||||||
DEFINES += BUILD_QDEVICEWATCHER_LIB
|
DEFINES += BUILD_QDEVICEWATCHER_LIB
|
||||||
@ -272,7 +282,7 @@ win32 {
|
|||||||
else: SOURCES += $$PWD/pluginwatcher/qdevicewatcher_win32.cpp
|
else: SOURCES += $$PWD/pluginwatcher/qdevicewatcher_win32.cpp
|
||||||
}
|
}
|
||||||
unix {
|
unix {
|
||||||
macx {
|
equals(QT_KIT, macOS) {
|
||||||
SOURCES += $$PWD/pluginwatcher/qdevicewatcher_mac.cpp
|
SOURCES += $$PWD/pluginwatcher/qdevicewatcher_mac.cpp
|
||||||
} else {
|
} else {
|
||||||
SOURCES += $$PWD/pluginwatcher/qdevicewatcher_linux.cpp
|
SOURCES += $$PWD/pluginwatcher/qdevicewatcher_linux.cpp
|
||||||
|
12
src/qqt.pro
12
src/qqt.pro
@ -5,10 +5,6 @@
|
|||||||
#-------------------------------------------------
|
#-------------------------------------------------
|
||||||
TARGET = QQt
|
TARGET = QQt
|
||||||
TEMPLATE = lib
|
TEMPLATE = lib
|
||||||
CONFIG += dll
|
|
||||||
macx {
|
|
||||||
CONFIG += lib_bundle
|
|
||||||
}
|
|
||||||
|
|
||||||
#QQT LIBRARY (DLL)
|
#QQT LIBRARY (DLL)
|
||||||
#DEFINES += QQT_LIBRARY
|
#DEFINES += QQT_LIBRARY
|
||||||
@ -17,12 +13,18 @@ DEFINES += QQT_LIBRARY
|
|||||||
|
|
||||||
include ($$PWD/qqt.pri)
|
include ($$PWD/qqt.pri)
|
||||||
|
|
||||||
|
equals(QT_KIT, macOS) {
|
||||||
|
message (build $${TARGET} $${QT_KIT} bundle)
|
||||||
|
CONFIG += dll
|
||||||
|
CONFIG += lib_bundle
|
||||||
|
}
|
||||||
|
|
||||||
############
|
############
|
||||||
##install
|
##install
|
||||||
############
|
############
|
||||||
#CONFIG += can_install
|
#CONFIG += can_install
|
||||||
|
|
||||||
can_install:macx {
|
can_install:equals(QT_KIT, macOS) {
|
||||||
###if install product to same path,use this.
|
###if install product to same path,use this.
|
||||||
target.path = /System/Library/Frameworks
|
target.path = /System/Library/Frameworks
|
||||||
INSTALLS += target
|
INSTALLS += target
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1,63 +0,0 @@
|
|||||||
#ifndef _POSIX_QEXTSERIALPORT_H_
|
|
||||||
#define _POSIX_QEXTSERIALPORT_H_
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <termios.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <sys/time.h>
|
|
||||||
#include <sys/ioctl.h>
|
|
||||||
#include <sys/select.h>
|
|
||||||
#include "qextserialbase.h"
|
|
||||||
|
|
||||||
class Posix_QextSerialPort:public QextSerialBase
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
/*!
|
|
||||||
* This method is a part of constructor.
|
|
||||||
*/
|
|
||||||
void init();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
QFile* Posix_File;
|
|
||||||
struct termios Posix_CommConfig;
|
|
||||||
struct timeval Posix_Timeout;
|
|
||||||
struct timeval Posix_Copy_Timeout;
|
|
||||||
|
|
||||||
virtual qint64 readData(char * data, qint64 maxSize);
|
|
||||||
virtual qint64 writeData(const char * data, qint64 maxSize);
|
|
||||||
|
|
||||||
public:
|
|
||||||
Posix_QextSerialPort();
|
|
||||||
Posix_QextSerialPort(const Posix_QextSerialPort& s);
|
|
||||||
Posix_QextSerialPort(const QString & name, QextSerialBase::QueryMode mode = QextSerialBase::Polling);
|
|
||||||
Posix_QextSerialPort(const PortSettings& settings, QextSerialBase::QueryMode mode = QextSerialBase::Polling);
|
|
||||||
Posix_QextSerialPort(const QString & name, const PortSettings& settings, QextSerialBase::QueryMode mode = QextSerialBase::Polling);
|
|
||||||
Posix_QextSerialPort& operator=(const Posix_QextSerialPort& s);
|
|
||||||
virtual ~Posix_QextSerialPort();
|
|
||||||
|
|
||||||
virtual void setBaudRate(BaudRateType);
|
|
||||||
virtual void setDataBits(DataBitsType);
|
|
||||||
virtual void setParity(ParityType);
|
|
||||||
virtual void setStopBits(StopBitsType);
|
|
||||||
virtual void setFlowControl(FlowType);
|
|
||||||
virtual void setTimeout(long);
|
|
||||||
|
|
||||||
virtual bool open(OpenMode mode);
|
|
||||||
virtual void close();
|
|
||||||
virtual void flush();
|
|
||||||
|
|
||||||
virtual qint64 size() const;
|
|
||||||
virtual qint64 bytesAvailable();
|
|
||||||
|
|
||||||
virtual void ungetChar(char c);
|
|
||||||
|
|
||||||
virtual void translateError(ulong error);
|
|
||||||
|
|
||||||
virtual void setDtr(bool set=true);
|
|
||||||
virtual void setRts(bool set=true);
|
|
||||||
virtual ulong lineStatus();
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,226 +0,0 @@
|
|||||||
#include "qextserialbase.h"
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\fn QextSerialBase::QextSerialBase()
|
|
||||||
Default constructor.
|
|
||||||
*/
|
|
||||||
QextSerialBase::QextSerialBase()
|
|
||||||
: QIODevice()
|
|
||||||
{
|
|
||||||
|
|
||||||
#ifdef _TTY_WIN_
|
|
||||||
setPortName("COM1");
|
|
||||||
|
|
||||||
#elif defined(_TTY_IRIX_)
|
|
||||||
setPortName("/dev/ttyf1");
|
|
||||||
|
|
||||||
#elif defined(_TTY_HPUX_)
|
|
||||||
setPortName("/dev/tty1p0");
|
|
||||||
|
|
||||||
#elif defined(_TTY_SUN_)
|
|
||||||
setPortName("/dev/ttya");
|
|
||||||
|
|
||||||
#elif defined(_TTY_DIGITAL_)
|
|
||||||
setPortName("/dev/tty01");
|
|
||||||
|
|
||||||
#elif defined(_TTY_FREEBSD_)
|
|
||||||
setPortName("/dev/ttyd1");
|
|
||||||
|
|
||||||
#else
|
|
||||||
setPortName("/dev/ttyS0");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
construct();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\fn QextSerialBase::QextSerialBase(const QString & name)
|
|
||||||
Construct a port and assign it to the device specified by the name parameter.
|
|
||||||
*/
|
|
||||||
QextSerialBase::QextSerialBase(const QString & name)
|
|
||||||
: QIODevice()
|
|
||||||
{
|
|
||||||
setPortName(name);
|
|
||||||
construct();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\fn QextSerialBase::~QextSerialBase()
|
|
||||||
Standard destructor.
|
|
||||||
*/
|
|
||||||
QextSerialBase::~QextSerialBase()
|
|
||||||
{
|
|
||||||
delete mutex;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\fn void QextSerialBase::construct()
|
|
||||||
Common constructor function for setting up default port settings.
|
|
||||||
(115200 Baud, 8N1, Hardware flow control where supported, otherwise no flow control, and 0 ms timeout).
|
|
||||||
*/
|
|
||||||
void QextSerialBase::construct()
|
|
||||||
{
|
|
||||||
Settings.BaudRate=BAUD115200;
|
|
||||||
Settings.DataBits=DATA_8;
|
|
||||||
Settings.Parity=PAR_NONE;
|
|
||||||
Settings.StopBits=STOP_1;
|
|
||||||
Settings.FlowControl=FLOW_HARDWARE;
|
|
||||||
Settings.Timeout_Millisec=500;
|
|
||||||
mutex = new QMutex( QMutex::Recursive );
|
|
||||||
setOpenMode(QIODevice::NotOpen);
|
|
||||||
}
|
|
||||||
|
|
||||||
void QextSerialBase::setQueryMode(QueryMode mechanism)
|
|
||||||
{
|
|
||||||
_queryMode = mechanism;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\fn void QextSerialBase::setPortName(const QString & name)
|
|
||||||
Sets the name of the device associated with the object, e.g. "COM1", or "/dev/ttyS0".
|
|
||||||
*/
|
|
||||||
void QextSerialBase::setPortName(const QString & name)
|
|
||||||
{
|
|
||||||
port = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\fn QString QextSerialBase::portName() const
|
|
||||||
Returns the name set by setPortName().
|
|
||||||
*/
|
|
||||||
QString QextSerialBase::portName() const
|
|
||||||
{
|
|
||||||
return port;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\fn BaudRateType QextSerialBase::baudRate(void) const
|
|
||||||
Returns the baud rate of the serial port. For a list of possible return values see
|
|
||||||
the definition of the enum BaudRateType.
|
|
||||||
*/
|
|
||||||
BaudRateType QextSerialBase::baudRate(void) const
|
|
||||||
{
|
|
||||||
return Settings.BaudRate;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\fn DataBitsType QextSerialBase::dataBits() const
|
|
||||||
Returns the number of data bits used by the port. For a list of possible values returned by
|
|
||||||
this function, see the definition of the enum DataBitsType.
|
|
||||||
*/
|
|
||||||
DataBitsType QextSerialBase::dataBits() const
|
|
||||||
{
|
|
||||||
return Settings.DataBits;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\fn ParityType QextSerialBase::parity() const
|
|
||||||
Returns the type of parity used by the port. For a list of possible values returned by
|
|
||||||
this function, see the definition of the enum ParityType.
|
|
||||||
*/
|
|
||||||
ParityType QextSerialBase::parity() const
|
|
||||||
{
|
|
||||||
return Settings.Parity;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\fn StopBitsType QextSerialBase::stopBits() const
|
|
||||||
Returns the number of stop bits used by the port. For a list of possible return values, see
|
|
||||||
the definition of the enum StopBitsType.
|
|
||||||
*/
|
|
||||||
StopBitsType QextSerialBase::stopBits() const
|
|
||||||
{
|
|
||||||
return Settings.StopBits;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\fn FlowType QextSerialBase::flowControl() const
|
|
||||||
Returns the type of flow control used by the port. For a list of possible values returned
|
|
||||||
by this function, see the definition of the enum FlowType.
|
|
||||||
*/
|
|
||||||
FlowType QextSerialBase::flowControl() const
|
|
||||||
{
|
|
||||||
return Settings.FlowControl;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\fn bool QextSerialBase::isSequential() const
|
|
||||||
Returns true if device is sequential, otherwise returns false. Serial port is sequential device
|
|
||||||
so this function always returns true. Check QIODevice::isSequential() documentation for more
|
|
||||||
information.
|
|
||||||
*/
|
|
||||||
bool QextSerialBase::isSequential() const
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\fn bool QextSerialBase::atEnd() const
|
|
||||||
This function will return true if the input buffer is empty (or on error), and false otherwise.
|
|
||||||
Call QextSerialBase::lastError() for error information.
|
|
||||||
*/
|
|
||||||
bool QextSerialBase::atEnd() const
|
|
||||||
{
|
|
||||||
if (size()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\fn qint64 QextSerialBase::readLine(char * data, qint64 maxSize)
|
|
||||||
This function will read a line of buffered input from the port, stopping when either maxSize bytes
|
|
||||||
have been read, the port has no more data available, or a newline is encountered.
|
|
||||||
The value returned is the length of the string that was read.
|
|
||||||
*/
|
|
||||||
qint64 QextSerialBase::readLine(char * data, qint64 maxSize)
|
|
||||||
{
|
|
||||||
qint64 numBytes = bytesAvailable();
|
|
||||||
char* pData = data;
|
|
||||||
|
|
||||||
if (maxSize < 2) //maxSize must be larger than 1
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
/*read a byte at a time for MIN(bytesAvail, maxSize - 1) iterations, or until a newline*/
|
|
||||||
while (pData<(data+numBytes) && --maxSize) {
|
|
||||||
readData(pData, 1);
|
|
||||||
if (*pData++ == '\n') {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*pData='\0';
|
|
||||||
|
|
||||||
/*return size of data read*/
|
|
||||||
return (pData-data);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\fn ulong QextSerialBase::lastError() const
|
|
||||||
Returns the code for the last error encountered by the port, or E_NO_ERROR if the last port
|
|
||||||
operation was successful. Possible error codes are:
|
|
||||||
|
|
||||||
\verbatim
|
|
||||||
Error Explanation
|
|
||||||
--------------------------- -------------------------------------------------------------
|
|
||||||
E_NO_ERROR No Error has occured
|
|
||||||
E_INVALID_FD Invalid file descriptor (port was not opened correctly)
|
|
||||||
E_NO_MEMORY Unable to allocate memory tables (POSIX)
|
|
||||||
E_CAUGHT_NON_BLOCKED_SIGNAL Caught a non-blocked signal (POSIX)
|
|
||||||
E_PORT_TIMEOUT Operation timed out (POSIX)
|
|
||||||
E_INVALID_DEVICE The file opened by the port is not a character device (POSIX)
|
|
||||||
E_BREAK_CONDITION The port detected a break condition
|
|
||||||
E_FRAMING_ERROR The port detected a framing error
|
|
||||||
(usually caused by incorrect baud rate settings)
|
|
||||||
E_IO_ERROR There was an I/O error while communicating with the port
|
|
||||||
E_BUFFER_OVERRUN Character buffer overrun
|
|
||||||
E_RECEIVE_OVERFLOW Receive buffer overflow
|
|
||||||
E_RECEIVE_PARITY_ERROR The port detected a parity error in the received data
|
|
||||||
E_TRANSMIT_OVERFLOW Transmit buffer overflow
|
|
||||||
E_READ_FAILED General read operation failure
|
|
||||||
E_WRITE_FAILED General write operation failure
|
|
||||||
\endverbatim
|
|
||||||
*/
|
|
||||||
ulong QextSerialBase::lastError() const
|
|
||||||
{
|
|
||||||
return lastErr;
|
|
||||||
}
|
|
@ -1,258 +0,0 @@
|
|||||||
#ifndef _QEXTSERIALBASE_H_
|
|
||||||
#define _QEXTSERIALBASE_H_
|
|
||||||
|
|
||||||
#include <QIODevice>
|
|
||||||
#include <QFile>
|
|
||||||
#include <QThread>
|
|
||||||
#include <QMutex>
|
|
||||||
|
|
||||||
/*if all warning messages are turned off, flag portability warnings to be turned off as well*/
|
|
||||||
#ifdef _TTY_NOWARN_
|
|
||||||
#define _TTY_NOWARN_PORT_
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*macros for thread support*/
|
|
||||||
#define LOCK_MUTEX() mutex->lock()
|
|
||||||
#define UNLOCK_MUTEX() mutex->unlock()
|
|
||||||
|
|
||||||
/*macros for warning and debug messages*/
|
|
||||||
#ifdef _TTY_NOWARN_PORT_
|
|
||||||
#define TTY_PORTABILITY_WARNING(s)
|
|
||||||
#else
|
|
||||||
#define TTY_PORTABILITY_WARNING(s) qWarning(s)
|
|
||||||
#endif /*_TTY_NOWARN_PORT_*/
|
|
||||||
#ifdef _TTY_NOWARN_
|
|
||||||
#define TTY_WARNING(s)
|
|
||||||
#else
|
|
||||||
#define TTY_WARNING(s) qWarning(s)
|
|
||||||
#endif /*_TTY_NOWARN_*/
|
|
||||||
|
|
||||||
|
|
||||||
/*line status constants*/
|
|
||||||
#define LS_CTS 0x01
|
|
||||||
#define LS_DSR 0x02
|
|
||||||
#define LS_DCD 0x04
|
|
||||||
#define LS_RI 0x08
|
|
||||||
#define LS_RTS 0x10
|
|
||||||
#define LS_DTR 0x20
|
|
||||||
#define LS_ST 0x40
|
|
||||||
#define LS_SR 0x80
|
|
||||||
|
|
||||||
/*error constants*/
|
|
||||||
#define E_NO_ERROR 0
|
|
||||||
#define E_INVALID_FD 1
|
|
||||||
#define E_NO_MEMORY 2
|
|
||||||
#define E_CAUGHT_NON_BLOCKED_SIGNAL 3
|
|
||||||
#define E_PORT_TIMEOUT 4
|
|
||||||
#define E_INVALID_DEVICE 5
|
|
||||||
#define E_BREAK_CONDITION 6
|
|
||||||
#define E_FRAMING_ERROR 7
|
|
||||||
#define E_IO_ERROR 8
|
|
||||||
#define E_BUFFER_OVERRUN 9
|
|
||||||
#define E_RECEIVE_OVERFLOW 10
|
|
||||||
#define E_RECEIVE_PARITY_ERROR 11
|
|
||||||
#define E_TRANSMIT_OVERFLOW 12
|
|
||||||
#define E_READ_FAILED 13
|
|
||||||
#define E_WRITE_FAILED 14
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* Enums for port settings.
|
|
||||||
*/
|
|
||||||
enum NamingConvention
|
|
||||||
{
|
|
||||||
WIN_NAMES,
|
|
||||||
IRIX_NAMES,
|
|
||||||
HPUX_NAMES,
|
|
||||||
SUN_NAMES,
|
|
||||||
DIGITAL_NAMES,
|
|
||||||
FREEBSD_NAMES,
|
|
||||||
LINUX_NAMES
|
|
||||||
};
|
|
||||||
|
|
||||||
enum BaudRateType
|
|
||||||
{
|
|
||||||
BAUD50, //POSIX ONLY
|
|
||||||
BAUD75, //POSIX ONLY
|
|
||||||
BAUD110,
|
|
||||||
BAUD134, //POSIX ONLY
|
|
||||||
BAUD150, //POSIX ONLY
|
|
||||||
BAUD200, //POSIX ONLY
|
|
||||||
BAUD300,
|
|
||||||
BAUD600,
|
|
||||||
BAUD1200,
|
|
||||||
BAUD1800, //POSIX ONLY
|
|
||||||
BAUD2400,
|
|
||||||
BAUD4800,
|
|
||||||
BAUD9600,
|
|
||||||
BAUD14400, //WINDOWS ONLY
|
|
||||||
BAUD19200,
|
|
||||||
BAUD38400,
|
|
||||||
BAUD56000, //WINDOWS ONLY
|
|
||||||
BAUD57600,
|
|
||||||
BAUD76800, //POSIX ONLY
|
|
||||||
BAUD115200,
|
|
||||||
BAUD128000, //WINDOWS ONLY
|
|
||||||
BAUD256000 //WINDOWS ONLY
|
|
||||||
};
|
|
||||||
|
|
||||||
enum DataBitsType
|
|
||||||
{
|
|
||||||
DATA_5,
|
|
||||||
DATA_6,
|
|
||||||
DATA_7,
|
|
||||||
DATA_8
|
|
||||||
};
|
|
||||||
|
|
||||||
enum ParityType
|
|
||||||
{
|
|
||||||
PAR_NONE,
|
|
||||||
PAR_ODD,
|
|
||||||
PAR_EVEN,
|
|
||||||
PAR_MARK, //WINDOWS ONLY
|
|
||||||
PAR_SPACE
|
|
||||||
};
|
|
||||||
|
|
||||||
enum StopBitsType
|
|
||||||
{
|
|
||||||
STOP_1,
|
|
||||||
STOP_1_5, //WINDOWS ONLY
|
|
||||||
STOP_2
|
|
||||||
};
|
|
||||||
|
|
||||||
enum FlowType
|
|
||||||
{
|
|
||||||
FLOW_OFF,
|
|
||||||
FLOW_HARDWARE,
|
|
||||||
FLOW_XONXOFF
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* structure to contain port settings
|
|
||||||
*/
|
|
||||||
struct PortSettings
|
|
||||||
{
|
|
||||||
BaudRateType BaudRate;
|
|
||||||
DataBitsType DataBits;
|
|
||||||
ParityType Parity;
|
|
||||||
StopBitsType StopBits;
|
|
||||||
FlowType FlowControl;
|
|
||||||
long Timeout_Millisec;
|
|
||||||
};
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* \author Stefan Sander
|
|
||||||
* \author Michal Policht
|
|
||||||
*
|
|
||||||
* A common base class for Win_QextSerialBase, Posix_QextSerialBase and QextSerialPort.
|
|
||||||
*/
|
|
||||||
class QextSerialBase : public QIODevice
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
enum QueryMode {
|
|
||||||
Polling,
|
|
||||||
EventDriven
|
|
||||||
};
|
|
||||||
|
|
||||||
protected:
|
|
||||||
QMutex* mutex;
|
|
||||||
QString port;
|
|
||||||
PortSettings Settings;
|
|
||||||
ulong lastErr;
|
|
||||||
QextSerialBase::QueryMode _queryMode;
|
|
||||||
|
|
||||||
virtual qint64 readData(char * data, qint64 maxSize)=0;
|
|
||||||
virtual qint64 writeData(const char * data, qint64 maxSize)=0;
|
|
||||||
|
|
||||||
public:
|
|
||||||
QextSerialBase();
|
|
||||||
QextSerialBase(const QString & name);
|
|
||||||
virtual ~QextSerialBase();
|
|
||||||
virtual void construct();
|
|
||||||
virtual void setPortName(const QString & name);
|
|
||||||
virtual QString portName() const;
|
|
||||||
|
|
||||||
/**!
|
|
||||||
* Get query mode.
|
|
||||||
* \return query mode.
|
|
||||||
*/
|
|
||||||
inline QextSerialBase::QueryMode queryMode() const { return _queryMode; };
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* Set desired serial communication handling style. You may choose from polling
|
|
||||||
* or event driven approach. This function does nothing when port is open; to
|
|
||||||
* apply changes port must be reopened.
|
|
||||||
*
|
|
||||||
* In event driven approach read() and write() functions are acting
|
|
||||||
* asynchronously. They return immediately and the operation is performed in
|
|
||||||
* the background, so they doesn't freeze the calling thread.
|
|
||||||
* To determine when operation is finished, QextSerialPort runs separate thread
|
|
||||||
* and monitors serial port events. Whenever the event occurs, adequate signal
|
|
||||||
* is emitted.
|
|
||||||
*
|
|
||||||
* When polling is set, read() and write() are acting synchronously. Signals are
|
|
||||||
* not working in this mode and some functions may not be available. The advantage
|
|
||||||
* of polling is that it generates less overhead due to lack of signals emissions
|
|
||||||
* and it doesn't start separate thread to monitor events.
|
|
||||||
*
|
|
||||||
* Generally event driven approach is more capable and friendly, although some
|
|
||||||
* applications may need as low overhead as possible and then polling comes.
|
|
||||||
*
|
|
||||||
* \param mode query mode.
|
|
||||||
*/
|
|
||||||
virtual void setQueryMode(QueryMode mode);
|
|
||||||
|
|
||||||
// virtual void setBlockingRead(bool block) = 0; ///< @todo implement.
|
|
||||||
|
|
||||||
virtual void setBaudRate(BaudRateType)=0;
|
|
||||||
virtual BaudRateType baudRate() const;
|
|
||||||
virtual void setDataBits(DataBitsType)=0;
|
|
||||||
virtual DataBitsType dataBits() const;
|
|
||||||
virtual void setParity(ParityType)=0;
|
|
||||||
virtual ParityType parity() const;
|
|
||||||
virtual void setStopBits(StopBitsType)=0;
|
|
||||||
virtual StopBitsType stopBits() const;
|
|
||||||
virtual void setFlowControl(FlowType)=0;
|
|
||||||
virtual FlowType flowControl() const;
|
|
||||||
virtual void setTimeout(long)=0;
|
|
||||||
|
|
||||||
virtual bool open(OpenMode mode)=0;
|
|
||||||
virtual bool isSequential() const;
|
|
||||||
virtual void close()=0;
|
|
||||||
virtual void flush()=0;
|
|
||||||
|
|
||||||
virtual qint64 size() const=0;
|
|
||||||
virtual qint64 bytesAvailable()=0;
|
|
||||||
virtual bool atEnd() const;
|
|
||||||
|
|
||||||
virtual void ungetChar(char c)=0;
|
|
||||||
virtual qint64 readLine(char * data, qint64 maxSize);
|
|
||||||
|
|
||||||
virtual ulong lastError() const;
|
|
||||||
virtual void translateError(ulong error)=0;
|
|
||||||
|
|
||||||
virtual void setDtr(bool set=true)=0;
|
|
||||||
virtual void setRts(bool set=true)=0;
|
|
||||||
virtual ulong lineStatus()=0;
|
|
||||||
|
|
||||||
signals:
|
|
||||||
/**
|
|
||||||
* This signal is emitted whenever port settings are updated.
|
|
||||||
* \param valid \p true if settings are valid, \p false otherwise.
|
|
||||||
*
|
|
||||||
* @todo implement.
|
|
||||||
*/
|
|
||||||
// void validSettings(bool valid);
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* This signal is emitted whenever dsr line has changed its state. You may
|
|
||||||
* use this signal to check if device is connected.
|
|
||||||
* \param status \p true when DSR signal is on, \p false otherwise.
|
|
||||||
*
|
|
||||||
* \see lineStatus().
|
|
||||||
*/
|
|
||||||
void dsrChanged(bool status);
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,158 +0,0 @@
|
|||||||
/**
|
|
||||||
* @file qextserialenumerator.cpp
|
|
||||||
* @author Michał Policht
|
|
||||||
* @see QextSerialEnumerator
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "qextserialenumerator.h"
|
|
||||||
|
|
||||||
#if defined ( _TTY_WIN_ )
|
|
||||||
#include <objbase.h>
|
|
||||||
#include <initguid.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef _TTY_WIN_
|
|
||||||
//this is serial port GUID
|
|
||||||
#ifndef GUID_CLASS_COMPORT
|
|
||||||
DEFINE_GUID(GUID_CLASS_COMPORT, 0x86e0d1e0L, 0x8089, 0x11d0, 0x9c, 0xe4, 0x08, 0x00, 0x3e, 0x30, 0x1f, 0x73);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Gordon Schumacher's macros for TCHAR -> QString conversions and vice versa */
|
|
||||||
#ifdef UNICODE
|
|
||||||
#define QStringToTCHAR(x) (wchar_t*) x.utf16()
|
|
||||||
#define PQStringToTCHAR(x) (wchar_t*) x->utf16()
|
|
||||||
#define TCHARToQString(x) QString::fromUtf16((ushort*)(x))
|
|
||||||
#define TCHARToQStringN(x,y) QString::fromUtf16((ushort*)(x),(y))
|
|
||||||
#else
|
|
||||||
#define QStringToTCHAR(x) x.local8Bit().constData()
|
|
||||||
#define PQStringToTCHAR(x) x->local8Bit().constData()
|
|
||||||
#define TCHARToQString(x) QString::fromLocal8Bit((x))
|
|
||||||
#define TCHARToQStringN(x,y) QString::fromLocal8Bit((x),(y))
|
|
||||||
#endif /*UNICODE*/
|
|
||||||
|
|
||||||
|
|
||||||
//static
|
|
||||||
QString QextSerialEnumerator::getRegKeyValue(HKEY key, LPCTSTR property)
|
|
||||||
{
|
|
||||||
DWORD size = 0;
|
|
||||||
RegQueryValueEx(key, property, NULL, NULL, NULL, & size);
|
|
||||||
BYTE * buff = new BYTE[size];
|
|
||||||
if (RegQueryValueEx(key, property, NULL, NULL, buff, & size) == ERROR_SUCCESS) {
|
|
||||||
return TCHARToQStringN(buff, size);
|
|
||||||
delete [] buff;
|
|
||||||
} else {
|
|
||||||
qWarning("QextSerialEnumerator::getRegKeyValue: can not obtain value from registry");
|
|
||||||
delete [] buff;
|
|
||||||
return QString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//static
|
|
||||||
QString QextSerialEnumerator::getDeviceProperty(HDEVINFO devInfo, PSP_DEVINFO_DATA devData, DWORD property)
|
|
||||||
{
|
|
||||||
DWORD buffSize = 0;
|
|
||||||
SetupDiGetDeviceRegistryProperty(devInfo, devData, property, NULL, NULL, 0, & buffSize);
|
|
||||||
BYTE * buff = new BYTE[buffSize];
|
|
||||||
if (!SetupDiGetDeviceRegistryProperty(devInfo, devData, property, NULL, buff, buffSize, NULL))
|
|
||||||
qCritical("Can not obtain property: %ld from registry", property);
|
|
||||||
QString result = TCHARToQString(buff);
|
|
||||||
delete [] buff;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
//static
|
|
||||||
void QextSerialEnumerator::setupAPIScan(QList<QextPortInfo> & infoList)
|
|
||||||
{
|
|
||||||
HDEVINFO devInfo = INVALID_HANDLE_VALUE;
|
|
||||||
GUID * guidDev = (GUID *) & GUID_CLASS_COMPORT;
|
|
||||||
|
|
||||||
devInfo = SetupDiGetClassDevs(guidDev, NULL, NULL, DIGCF_PRESENT | DIGCF_DEVICEINTERFACE);
|
|
||||||
if(devInfo == INVALID_HANDLE_VALUE) {
|
|
||||||
qCritical("SetupDiGetClassDevs failed. Error code: %ld", GetLastError());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
//enumerate the devices
|
|
||||||
bool ok = true;
|
|
||||||
SP_DEVICE_INTERFACE_DATA ifcData;
|
|
||||||
ifcData.cbSize = sizeof(SP_DEVICE_INTERFACE_DATA);
|
|
||||||
SP_DEVICE_INTERFACE_DETAIL_DATA * detData = NULL;
|
|
||||||
DWORD detDataSize = 0;
|
|
||||||
DWORD oldDetDataSize = 0;
|
|
||||||
|
|
||||||
for (DWORD i = 0; ok; i++) {
|
|
||||||
ok = SetupDiEnumDeviceInterfaces(devInfo, NULL, guidDev, i, &ifcData);
|
|
||||||
if (ok) {
|
|
||||||
SP_DEVINFO_DATA devData = {sizeof(SP_DEVINFO_DATA)};
|
|
||||||
//check for required detData size
|
|
||||||
SetupDiGetDeviceInterfaceDetail(devInfo, & ifcData, NULL, 0, & detDataSize, & devData);
|
|
||||||
//if larger than old detData size then reallocate the buffer
|
|
||||||
if (detDataSize > oldDetDataSize) {
|
|
||||||
delete [] detData;
|
|
||||||
detData = (SP_DEVICE_INTERFACE_DETAIL_DATA *) new char[detDataSize];
|
|
||||||
detData->cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA);
|
|
||||||
oldDetDataSize = detDataSize;
|
|
||||||
}
|
|
||||||
//check the details
|
|
||||||
if (SetupDiGetDeviceInterfaceDetail(devInfo, & ifcData, detData, detDataSize,
|
|
||||||
NULL, & devData)) {
|
|
||||||
// Got a device. Get the details.
|
|
||||||
QextPortInfo info;
|
|
||||||
info.friendName = getDeviceProperty(devInfo, & devData, SPDRP_FRIENDLYNAME);
|
|
||||||
info.physName = getDeviceProperty(devInfo, & devData, SPDRP_PHYSICAL_DEVICE_OBJECT_NAME);
|
|
||||||
info.enumName = getDeviceProperty(devInfo, & devData, SPDRP_ENUMERATOR_NAME);
|
|
||||||
//anyway, to get the port name we must still open registry directly :( ???
|
|
||||||
//Eh...
|
|
||||||
HKEY devKey = SetupDiOpenDevRegKey(devInfo, & devData, DICS_FLAG_GLOBAL, 0,
|
|
||||||
DIREG_DEV, KEY_READ);
|
|
||||||
info.portName = getRegKeyValue(devKey, TEXT("PortName"));
|
|
||||||
RegCloseKey(devKey);
|
|
||||||
infoList.append(info);
|
|
||||||
} else {
|
|
||||||
qCritical("SetupDiGetDeviceInterfaceDetail failed. Error code: %ld", GetLastError());
|
|
||||||
delete [] detData;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (GetLastError() != ERROR_NO_MORE_ITEMS) {
|
|
||||||
delete [] detData;
|
|
||||||
qCritical("SetupDiEnumDeviceInterfaces failed. Error code: %ld", GetLastError());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
delete [] detData;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /*_TTY_WIN_*/
|
|
||||||
|
|
||||||
|
|
||||||
//static
|
|
||||||
QList<QextPortInfo> QextSerialEnumerator::getPorts()
|
|
||||||
{
|
|
||||||
QList<QextPortInfo> ports;
|
|
||||||
|
|
||||||
#ifdef _TTY_WIN_
|
|
||||||
OSVERSIONINFO vi;
|
|
||||||
vi.dwOSVersionInfoSize = sizeof(vi);
|
|
||||||
if (!::GetVersionEx(&vi)) {
|
|
||||||
qCritical("Could not get OS version.");
|
|
||||||
return ports;
|
|
||||||
}
|
|
||||||
// Handle windows 9x and NT4 specially
|
|
||||||
if (vi.dwMajorVersion < 5) {
|
|
||||||
qCritical("Enumeration for this version of Windows is not implemented yet");
|
|
||||||
/* if (vi.dwPlatformId == VER_PLATFORM_WIN32_NT)
|
|
||||||
EnumPortsWNt4(ports);
|
|
||||||
else
|
|
||||||
EnumPortsW9x(ports);*/
|
|
||||||
} else //w2k or later
|
|
||||||
setupAPIScan(ports);
|
|
||||||
#endif /*_TTY_WIN_*/
|
|
||||||
#ifdef _TTY_POSIX_
|
|
||||||
qCritical("Enumeration for POSIX systems is not implemented yet.");
|
|
||||||
#endif /*_TTY_POSIX_*/
|
|
||||||
|
|
||||||
return ports;
|
|
||||||
}
|
|
@ -1,75 +0,0 @@
|
|||||||
/*!
|
|
||||||
* \file qextserialenumerator.h
|
|
||||||
* \author Michal Policht
|
|
||||||
* \see QextSerialEnumerator
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _QEXTSERIALENUMERATOR_H_
|
|
||||||
#define _QEXTSERIALENUMERATOR_H_
|
|
||||||
|
|
||||||
|
|
||||||
#include <QString>
|
|
||||||
#include <QList>
|
|
||||||
|
|
||||||
#ifdef _TTY_WIN_
|
|
||||||
#include <windows.h>
|
|
||||||
#include <setupapi.h>
|
|
||||||
#endif /*_TTY_WIN_*/
|
|
||||||
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* Structure containing port information.
|
|
||||||
*/
|
|
||||||
struct QextPortInfo {
|
|
||||||
QString portName; ///< Port name.
|
|
||||||
QString physName; ///< Physical name.
|
|
||||||
QString friendName; ///< Friendly name.
|
|
||||||
QString enumName; ///< Enumerator name.
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* Serial port enumerator. This class provides list of ports available in the system.
|
|
||||||
*
|
|
||||||
* Windows implementation is based on Zach Gorman's work from
|
|
||||||
* <a href="http://www.codeproject.com">The Code Project</a> (http://www.codeproject.com/system/setupdi.asp).
|
|
||||||
*/
|
|
||||||
class QextSerialEnumerator
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
#ifdef _TTY_WIN_
|
|
||||||
/*!
|
|
||||||
* Get value of specified property from the registry.
|
|
||||||
* \param key handle to an open key.
|
|
||||||
* \param property property name.
|
|
||||||
* \return property value.
|
|
||||||
*/
|
|
||||||
static QString getRegKeyValue(HKEY key, LPCTSTR property);
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* Get specific property from registry.
|
|
||||||
* \param devInfo pointer to the device information set that contains the interface
|
|
||||||
* and its underlying device. Returned by SetupDiGetClassDevs() function.
|
|
||||||
* \param devData pointer to an SP_DEVINFO_DATA structure that defines the device instance.
|
|
||||||
* this is returned by SetupDiGetDeviceInterfaceDetail() function.
|
|
||||||
* \param property registry property. One of defined SPDRP_* constants.
|
|
||||||
* \return property string.
|
|
||||||
*/
|
|
||||||
static QString getDeviceProperty(HDEVINFO devInfo, PSP_DEVINFO_DATA devData, DWORD property);
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* Search for serial ports using setupapi.
|
|
||||||
* \param infoList list with result.
|
|
||||||
*/
|
|
||||||
static void setupAPIScan(QList<QextPortInfo> & infoList);
|
|
||||||
#endif /*_TTY_WIN_*/
|
|
||||||
|
|
||||||
public:
|
|
||||||
/*!
|
|
||||||
* Get list of ports.
|
|
||||||
* \return list of ports currently available in the system.
|
|
||||||
*/
|
|
||||||
static QList<QextPortInfo> getPorts();
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif /*_QEXTSERIALENUMERATOR_H_*/
|
|
@ -1,106 +0,0 @@
|
|||||||
|
|
||||||
/*!
|
|
||||||
\class QextSerialPort
|
|
||||||
\author Stefan Sander
|
|
||||||
\author Michal Policht
|
|
||||||
|
|
||||||
A cross-platform serial port class.
|
|
||||||
This class encapsulates a serial port on both POSIX and Windows systems. The user will be
|
|
||||||
notified of errors and possible portability conflicts at run-time by default - this behavior can
|
|
||||||
be turned off by defining _TTY_NOWARN_ (to turn off all warnings) or _TTY_NOWARN_PORT_ (to turn
|
|
||||||
off portability warnings) in the project.
|
|
||||||
|
|
||||||
You may choose from polling or event driven API. For details check setQueryMode() documentation.
|
|
||||||
|
|
||||||
\note
|
|
||||||
On Windows NT/2000/XP this class uses Win32 serial port functions by default. The user may
|
|
||||||
select POSIX behavior under NT, 2000, or XP ONLY by defining _TTY_POSIX_ in the project. I can
|
|
||||||
make no guarantees as to the quality of POSIX support under NT/2000 however.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include "qextserialport.h"
|
|
||||||
|
|
||||||
/*!
|
|
||||||
Default constructor. Note that the naming convention used by a 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
|
|
||||||
|
|
||||||
The object will be associated with the first port in the system, e.g. COM1 on Windows systems.
|
|
||||||
See the other constructors if you need to use a port other than the first.
|
|
||||||
*/
|
|
||||||
QextSerialPort::QextSerialPort()
|
|
||||||
: QextBaseType()
|
|
||||||
{}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
Constructs a serial port attached to the port specified by name.
|
|
||||||
name is the name of the device, which is windowsystem-specific,
|
|
||||||
e.g."COM1" or "/dev/ttyS0".
|
|
||||||
|
|
||||||
\see setQueryMode().
|
|
||||||
*/
|
|
||||||
QextSerialPort::QextSerialPort(const QString & name, QueryMode mode)
|
|
||||||
: QextBaseType(name, mode)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
Constructs a port with default name and settings specified by the settings parameter.
|
|
||||||
|
|
||||||
\see setQueryMode().
|
|
||||||
*/
|
|
||||||
QextSerialPort::QextSerialPort(PortSettings const& settings, QueryMode mode)
|
|
||||||
: QextBaseType(settings, mode)
|
|
||||||
{}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
Constructs a port with the name and settings specified.
|
|
||||||
|
|
||||||
\see setQueryMode().
|
|
||||||
*/
|
|
||||||
QextSerialPort::QextSerialPort(const QString & name, PortSettings const& settings, QueryMode mode)
|
|
||||||
: QextBaseType(name, settings, mode)
|
|
||||||
{}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
Copy constructor.
|
|
||||||
|
|
||||||
\deprecated
|
|
||||||
*/
|
|
||||||
QextSerialPort::QextSerialPort(const QextSerialPort& s)
|
|
||||||
: QextBaseType(s)
|
|
||||||
{}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\fn QextSerialPort& QextSerialPort::operator=(const QextSerialPort& s)
|
|
||||||
Overrides the = operator.
|
|
||||||
|
|
||||||
\deprecated
|
|
||||||
*/
|
|
||||||
QextSerialPort& QextSerialPort::operator=(const QextSerialPort& s)
|
|
||||||
{
|
|
||||||
return (QextSerialPort&)QextBaseType::operator=(s);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\fn QextSerialPort::~QextSerialPort()
|
|
||||||
Standard destructor.
|
|
||||||
*/
|
|
||||||
QextSerialPort::~QextSerialPort()
|
|
||||||
{}
|
|
@ -1,33 +0,0 @@
|
|||||||
|
|
||||||
#ifndef _QEXTSERIALPORT_H_
|
|
||||||
#define _QEXTSERIALPORT_H_
|
|
||||||
|
|
||||||
/*POSIX CODE*/
|
|
||||||
#ifdef _TTY_POSIX_
|
|
||||||
#include "posix_qextserialport.h"
|
|
||||||
#define QextBaseType Posix_QextSerialPort
|
|
||||||
|
|
||||||
/*MS WINDOWS CODE*/
|
|
||||||
#else
|
|
||||||
#include "win_qextserialport.h"
|
|
||||||
#define QextBaseType Win_QextSerialPort
|
|
||||||
#endif
|
|
||||||
|
|
||||||
class QextSerialPort: public QextBaseType
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
typedef QextSerialBase::QueryMode QueryMode;
|
|
||||||
|
|
||||||
QextSerialPort();
|
|
||||||
QextSerialPort(const QString & name, QueryMode mode = QextSerialPort::Polling);
|
|
||||||
QextSerialPort(PortSettings const& s, QueryMode mode = QextSerialPort::Polling);
|
|
||||||
QextSerialPort(const QString & name, PortSettings const& s, QueryMode mode = QextSerialPort::Polling);
|
|
||||||
QextSerialPort(const QextSerialPort& s);
|
|
||||||
QextSerialPort& operator=(const QextSerialPort&);
|
|
||||||
virtual ~QextSerialPort();
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,33 +0,0 @@
|
|||||||
|
|
||||||
CONFIG += debug_and_release
|
|
||||||
CONFIG += qt
|
|
||||||
CONFIG += warn_on
|
|
||||||
CONFIG += thread
|
|
||||||
|
|
||||||
|
|
||||||
OBJECTS_DIR = obj
|
|
||||||
MOC_DIR = obj/moc.cpp
|
|
||||||
UI_DIR = obj/ui.h
|
|
||||||
RCC_DIR = qrc
|
|
||||||
#user directory
|
|
||||||
DESTDIR = bin
|
|
||||||
|
|
||||||
DEPENDPATH += $$PWD
|
|
||||||
INCLUDEPATH += $$PWD
|
|
||||||
HEADERS += $$PWD/qextserialbase.h \
|
|
||||||
$$PWD/qextserialport.h \
|
|
||||||
$$PWD/qextserialenumerator.h
|
|
||||||
SOURCES += $$PWD/qextserialbase.cpp \
|
|
||||||
$$PWD/qextserialport.cpp \
|
|
||||||
$$PWD/qextserialenumerator.cpp
|
|
||||||
|
|
||||||
unix:HEADERS += $$PWD/posix_qextserialport.h
|
|
||||||
unix:SOURCES += $$PWD/posix_qextserialport.cpp
|
|
||||||
unix:DEFINES += _TTY_POSIX_
|
|
||||||
|
|
||||||
|
|
||||||
win32:HEADERS += $$PWD/win_qextserialport.h
|
|
||||||
win32:SOURCES += $$PWD/win_qextserialport.cpp
|
|
||||||
win32:DEFINES += _TTY_WIN_
|
|
||||||
win32:LIBS += -lsetupapi
|
|
||||||
|
|
@ -1,49 +0,0 @@
|
|||||||
PROJECT = qextserialport
|
|
||||||
TEMPLATE = lib
|
|
||||||
|
|
||||||
CONFIG += debug_and_release
|
|
||||||
|
|
||||||
CONFIG += qt
|
|
||||||
CONFIG += warn_on
|
|
||||||
CONFIG += thread
|
|
||||||
|
|
||||||
CONFIG += dll
|
|
||||||
#CONFIG += staticlib
|
|
||||||
|
|
||||||
QT -= gui
|
|
||||||
|
|
||||||
OBJECTS_DIR = build/obj
|
|
||||||
MOC_DIR = build/moc
|
|
||||||
DEPENDDIR = .
|
|
||||||
INCLUDEDIR = .
|
|
||||||
HEADERS = qextserialbase.h \
|
|
||||||
qextserialport.h \
|
|
||||||
qextserialenumerator.h
|
|
||||||
SOURCES = qextserialbase.cpp \
|
|
||||||
qextserialport.cpp \
|
|
||||||
qextserialenumerator.cpp
|
|
||||||
|
|
||||||
unix:HEADERS += posix_qextserialport.h
|
|
||||||
unix:SOURCES += posix_qextserialport.cpp
|
|
||||||
unix:DEFINES += _TTY_POSIX_
|
|
||||||
|
|
||||||
|
|
||||||
win32:HEADERS += win_qextserialport.h
|
|
||||||
win32:SOURCES += win_qextserialport.cpp
|
|
||||||
win32:DEFINES += _TTY_WIN_
|
|
||||||
|
|
||||||
win32:LIBS += -lsetupapi
|
|
||||||
|
|
||||||
|
|
||||||
DESTDIR = build
|
|
||||||
#DESTDIR = examples/enumerator/debug
|
|
||||||
#DESTDIR = examples/qespta/debug
|
|
||||||
#DESTDIR = examples/event/debug
|
|
||||||
|
|
||||||
CONFIG(debug, debug|release) {
|
|
||||||
TARGET = qextserialportd
|
|
||||||
} else {
|
|
||||||
TARGET = qextserialport
|
|
||||||
}
|
|
||||||
|
|
||||||
unix:VERSION = 1.2.0
|
|
File diff suppressed because it is too large
Load Diff
@ -1,137 +0,0 @@
|
|||||||
#ifndef _WIN_QEXTSERIALPORT_H_
|
|
||||||
#define _WIN_QEXTSERIALPORT_H_
|
|
||||||
|
|
||||||
#include "qextserialbase.h"
|
|
||||||
#include <windows.h>
|
|
||||||
#include <QThread>
|
|
||||||
|
|
||||||
|
|
||||||
/*if all warning messages are turned off, flag portability warnings to be turned off as well*/
|
|
||||||
#ifdef _TTY_NOWARN_
|
|
||||||
#define _TTY_NOWARN_PORT_
|
|
||||||
#endif
|
|
||||||
|
|
||||||
class QReadWriteLock;
|
|
||||||
class Win_QextSerialThread;
|
|
||||||
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\author Stefan Sander
|
|
||||||
\author Michal Policht
|
|
||||||
|
|
||||||
A cross-platform serial port class.
|
|
||||||
This class encapsulates the Windows portion of QextSerialPort. The user will be notified of
|
|
||||||
errors and possible portability conflicts at run-time by default - this behavior can be turned
|
|
||||||
off by defining _TTY_NOWARN_ (to turn off all warnings) or _TTY_NOWARN_PORT_ (to turn off
|
|
||||||
portability warnings) in the project. Note that defining _TTY_NOWARN_ also defines
|
|
||||||
_TTY_NOWARN_PORT_.
|
|
||||||
|
|
||||||
\note
|
|
||||||
On Windows NT/2000/XP this class uses Win32 serial port functions by default. The user may
|
|
||||||
select POSIX behavior under NT, 2000, or XP ONLY by defining _TTY_POSIX_ in the project. I can
|
|
||||||
make no guarantees as to the quality of POSIX support under NT/2000 however.
|
|
||||||
|
|
||||||
\todo remove copy constructor and assign operator.
|
|
||||||
*/
|
|
||||||
class Win_QextSerialPort: public QextSerialBase
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
friend class Win_QextSerialThread;
|
|
||||||
|
|
||||||
private:
|
|
||||||
/*!
|
|
||||||
* This method is a part of constructor.
|
|
||||||
*/
|
|
||||||
void init();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
HANDLE Win_Handle;
|
|
||||||
HANDLE threadStartEvent;
|
|
||||||
HANDLE threadTerminateEvent;
|
|
||||||
OVERLAPPED overlap;
|
|
||||||
OVERLAPPED overlapWrite;
|
|
||||||
COMMCONFIG Win_CommConfig;
|
|
||||||
COMMTIMEOUTS Win_CommTimeouts;
|
|
||||||
QReadWriteLock * bytesToWriteLock; ///< @todo maybe move to QextSerialBase.
|
|
||||||
qint64 _bytesToWrite; ///< @todo maybe move to QextSerialBase (and implement in POSIX).
|
|
||||||
Win_QextSerialThread * overlapThread; ///< @todo maybe move to QextSerialBase (and implement in POSIX).
|
|
||||||
|
|
||||||
void monitorCommEvent();
|
|
||||||
void terminateCommWait();
|
|
||||||
virtual qint64 readData(char *data, qint64 maxSize);
|
|
||||||
virtual qint64 writeData(const char *data, qint64 maxSize);
|
|
||||||
|
|
||||||
public:
|
|
||||||
Win_QextSerialPort();
|
|
||||||
Win_QextSerialPort(Win_QextSerialPort const& s);
|
|
||||||
Win_QextSerialPort(const QString & name, QextSerialBase::QueryMode mode = QextSerialBase::Polling);
|
|
||||||
Win_QextSerialPort(const PortSettings& settings, QextSerialBase::QueryMode mode = QextSerialBase::Polling);
|
|
||||||
Win_QextSerialPort(const QString & name, const PortSettings& settings, QextSerialBase::QueryMode mode = QextSerialBase::Polling);
|
|
||||||
Win_QextSerialPort& operator=(const Win_QextSerialPort& s);
|
|
||||||
virtual ~Win_QextSerialPort();
|
|
||||||
virtual bool open(OpenMode mode);
|
|
||||||
virtual void close();
|
|
||||||
virtual void flush();
|
|
||||||
virtual qint64 size() const;
|
|
||||||
virtual void ungetChar(char c);
|
|
||||||
virtual void setFlowControl(FlowType);
|
|
||||||
virtual void setParity(ParityType);
|
|
||||||
virtual void setDataBits(DataBitsType);
|
|
||||||
virtual void setStopBits(StopBitsType);
|
|
||||||
virtual void setBaudRate(BaudRateType);
|
|
||||||
virtual void setDtr(bool set=true);
|
|
||||||
virtual void setRts(bool set=true);
|
|
||||||
virtual ulong lineStatus(void);
|
|
||||||
virtual qint64 bytesAvailable();
|
|
||||||
virtual void translateError(ulong);
|
|
||||||
virtual void setTimeout(long);
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* Return number of bytes waiting in the buffer. Currently this shows number
|
|
||||||
* of bytes queued within write() and before the TX_EMPTY event occured. TX_EMPTY
|
|
||||||
* event is created whenever last character in the system buffer was sent.
|
|
||||||
*
|
|
||||||
* \return number of bytes queued within write(), before the first TX_EMPTY
|
|
||||||
* event occur.
|
|
||||||
*
|
|
||||||
* \warning this function may not give you expected results since TX_EMPTY may occur
|
|
||||||
* while writing data to the buffer. Eventually some TX_EMPTY events may not be
|
|
||||||
* catched.
|
|
||||||
*
|
|
||||||
* \note this function always returns 0 in polling mode.
|
|
||||||
*
|
|
||||||
* \see flush().
|
|
||||||
*/
|
|
||||||
virtual qint64 bytesToWrite() const;
|
|
||||||
|
|
||||||
virtual bool waitForReadyRead(int msecs); ///< @todo implement.
|
|
||||||
};
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* This thread monitors communication events.
|
|
||||||
*/
|
|
||||||
class Win_QextSerialThread: public QThread
|
|
||||||
{
|
|
||||||
Win_QextSerialPort * qesp;
|
|
||||||
bool terminate;
|
|
||||||
|
|
||||||
public:
|
|
||||||
/*!
|
|
||||||
* Constructor.
|
|
||||||
*
|
|
||||||
* \param qesp valid serial port object.
|
|
||||||
*/
|
|
||||||
Win_QextSerialThread(Win_QextSerialPort * qesp);
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* Stop the thread.
|
|
||||||
*/
|
|
||||||
void stop();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
//overriden
|
|
||||||
virtual void run();
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
@ -11,16 +11,8 @@
|
|||||||
#include <QTranslator>
|
#include <QTranslator>
|
||||||
#include <QFontDatabase>
|
#include <QFontDatabase>
|
||||||
|
|
||||||
QQtApplication::QQtApplication(int &argc, char **argv
|
QQtApplication::QQtApplication(int &argc, char **argv) :
|
||||||
#ifndef Q_QDOC
|
QApplication(argc, argv),
|
||||||
, int flags
|
|
||||||
#endif
|
|
||||||
) :
|
|
||||||
QApplication(argc, argv
|
|
||||||
#ifndef Q_QDOC
|
|
||||||
, flags
|
|
||||||
#endif
|
|
||||||
),
|
|
||||||
bUPanAutoRun(false)
|
bUPanAutoRun(false)
|
||||||
{
|
{
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(5,0,0)
|
#if QT_VERSION < QT_VERSION_CHECK(5,0,0)
|
||||||
|
@ -9,11 +9,7 @@ class QQTSHARED_EXPORT QQtApplication : public QApplication
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
public:
|
public:
|
||||||
explicit QQtApplication(int &argc, char **argv
|
explicit QQtApplication(int &argc, char **argv);
|
||||||
#ifndef Q_QDOC
|
|
||||||
, int = ApplicationFlags
|
|
||||||
#endif
|
|
||||||
);
|
|
||||||
|
|
||||||
void setLanguage(QString qmfile = "./lang/zh_CN.qm");
|
void setLanguage(QString qmfile = "./lang/zh_CN.qm");
|
||||||
//palette
|
//palette
|
||||||
|
Loading…
x
Reference in New Issue
Block a user