PDA

View Full Version : QextSerialEnumeraton problem



kaszewczyk
23rd October 2009, 01:41
Hello, everyone im new on this forum so i would like to sey hello 2 every1.
Im here because i have a problem, and i hope u'll help me guys :) Ok now lets go 2 the point, im using QtCreator as IDE im trying 2 write program which can communicate with serial ports on Windows OS, i found the website http://qextserialport.sourceforge.net/ so i started to code but when i try 2 compile i get error but not in my code, the error is in qextserialenumeraton class, and i dont know what to do :/

this is what compiler sey's:

C:/HyperTerminal/qextserialenumerator.cpp:40: error: invalid conversion from `BYTE*' to `const char*'
C:/HyperTerminal/qextserialenumerator.cpp:40: error: initializing argument 1 of `static QString QString::fromLocal8Bit(const char*, int)'
C:/HyperTerminal/qextserialenumerator.cpp:57: error: invalid conversion from `BYTE*' to `const char*'
C:/HyperTerminal/qextserialenumerator.cpp:57: error: initializing argument 1 of `static QString QString::fromLocal8Bit(const char*, int)'

i was trying 2 something like this:

QList<QextPortInfo> serialPortsOnSystem = QextSerialEnumeration::getPorts();
//now i want to put them in combobox
QComboBox port;
port.addItem(serialPortsOnSystem.takeFirst().portN ame.toLocal8Bit().constData());)


i dont know if its helpful but this is my pro file:


# -------------------------------------------------
# Project created by QtCreator 2009-10-22T23:10:11
# -------------------------------------------------
TARGET = HyperTerminal
TEMPLATE = app
SOURCES += main.cpp \
hyperterminal.cpp \
qextserialenumerator.cpp \
settingsdialog.cpp \
win_qextserialport.cpp \
qextserialbase.cpp
HEADERS += hyperterminal.h \
qextserialenumerator.h \
settingsdialog.h \
win_qextserialport.h \
qextserialbase.cpp
win32:DEFINES = _TTY_WIN_


Best Regards
kaszewczyk

PS.
Sorry for my broken english but its not my national language

schnitzel
23rd October 2009, 05:39
The way I got it to work is as follows:

1) build qextserialport project separately as a lib/dll and make sure examples work
2) in my .pro file:
# --- added for qtext serial port
CONFIG(debug, debug|release):LIBS += -lqextserialportd
else:LIBS += -lqextserialport
win32:DEFINES += _TTY_WIN_

3) in my code:

port = new QextSerialPort(CommPort, portSettings, QextSerialPort::EventDriven);
port->open(QIODevice::ReadWrite);

4) enumeration:

QList<QextPortInfo> ports = QextSerialEnumerator::getPorts();
cmbPort->clear();

for(int i=0; i< ports.size(); i++)
{
cmbPort->addItem(QString("%1").arg(ports.at(i).portName.toLocal8Bit().constData ()));
}

Make sure you get the qextserialport-1.2win-alpha version.

hope this helps

kaszewczyk
23rd October 2009, 08:17
Hello thanks for Your replay, i have tried to build project from existing code but i dont know how to do it correctly because im getting warnings like this:

C:/QextSerialPort/Makefile.Debug:169: warning: overriding commands for target `build/obj/qextserialport.o'
C:/QextSerialPort/Makefile.Debug:156: warning: ignoring old commands for target `build/obj/qextserialport.o'
C:/QextSerialPort/Makefile.Debug:172: warning: overriding commands for target `build/obj/qextserialenumerator.o'
C:/QextSerialPort/Makefile.Debug:159: warning: ignoring old commands for target `build/obj/qextserialenumerator.o'
etc

Best Regards
kaszewczyk

schnitzel
23rd October 2009, 08:32
well, if they are just warnings...
make sure your qt creator is working correctly, i.e. have you tried running any of the examples?
Is \qt\<qtversion>\bin in your path?
what is your qt version?

kaszewczyk
23rd October 2009, 11:40
Hi, i mange to make dll thenks to You, i added the Qt directory to path. Now im trying to run examples but im getting errors, im doing as follow:

example project files:
- main.cpp
- qextserialenumerator.h
- qextserialport.dll (made from files qextserialport-1.2win-alpha)
- try_enumerator.pro

try_enumerator.pro

# ################################################## ###################
# Enumerator
# ################################################## ###################
PROJECT = try_enumerator
TEMPLATE = app
DEPENDPATH += .
INCLUDEPATH += ../..
QMAKE_LIBDIR += ../../build
OBJECTS_DIR = obj
MOC_DIR = moc
UI_DIR = uic
CONFIG += qt \
warn_on \
console
SOURCES += main.cpp
CONFIG(debug, debug|release):LIBS += -lqextserialportd
else:LIBS += -lqextserialport
unix:DEFINES = _TTY_POSIX_
win32:DEFINES = _TTY_WIN_
HEADERS += qextserialenumerator.h
OTHER_FILES += qextserialportd.dll


main.cpp:


/**
* @file main.cpp
* @brief Main file.
* @author Michał Policht
*/

#include <qextserialenumerator.h>
#include <QtCore/QList>

int main(int argc, char *argv[])
{
QList<QextPortInfo> ports = QextSerialEnumerator::getPorts();
printf("List of ports:\n");
for (int i = 0; i < ports.size(); i++) {
printf("port name: %s\n", ports.at(i).portName.toLocal8Bit().constData());
printf("friendly name: %s\n", ports.at(i).friendName.toLocal8Bit().constData());
printf("physical name: %s\n", ports.at(i).physName.toLocal8Bit().constData());
printf("enumerator name: %s\n", ports.at(i).enumName.toLocal8Bit().constData());
printf("===================================\n\n");
}
return EXIT_SUCCESS;
}


the output

C:/try_enumerator/main.cpp:7: qextserialenumerator.h: No such file or directory
C:/try_enumerator/main.cpp:12: error: `QextPortInfo' was not declared in this scope
C:/try_enumerator/main.cpp:12: error: invalid type in declaration before '=' token
C:/try_enumerator/main.cpp:12: error: `QextSerialEnumerator' has not been declared
C:/try_enumerator/main.cpp:14: error: request for member `size' in `ports', which is of non-class type `int'
C:/try_enumerator/main.cpp:15: error: request for member `at' in `ports', which is of non-class type `int'
C:/try_enumerator/main.cpp:17: error: request for member `at' in `ports', which is of non-class type `int'
C:/try_enumerator/main.cpp:17: error: request for member `at' in `ports', which is of non-class type `int'
C:/try_enumerator/main.cpp:12: warning: unused variable 'QextPortInfo'
C:/try_enumerator/main.cpp:12: warning: unused variable 'getPorts'


Best Regards
kaszewczyk

schnitzel
23rd October 2009, 17:10
you have to add this to your pro file (change according to where your qextserialport folder is):

# --- added for qtext serial port
INCLUDEPATH += ../qextserialport
QMAKE_LIBDIR += ../qextserialport/build

and get rid of:
HEADERS += qextserialenumerator.h
OTHER_FILES += qextserialportd.dll

for testing, just put the qexterialport.dll into the release folder of your executable (similarly put the qextserialportd.dll into your debug folder).

kaszewczyk
23rd October 2009, 21:03
Thanks, mate i got it work, i was trying different things and i came out with this way of doing it, this took me a while :D, im still really thankful for Your help, thanks again.


Yours
kaszewczyk

sunilrajkiran
7th October 2010, 06:57
HI ,

i compiled all the dependencies needed by the qgis development installation
qgis1.5.0
qt4.5.3
msys1.0.11
mingw5.1.4

qgis has gps sources in its core sources
i got following error while compiling qgis1.5.0


src/core/CMakeFiles/qgis_core.dir/gps/qextserialport/qextserialenumerator.cpp.obj
C:\dev\cpp\qgis\src\core\gps\qextserialport\qextse rialenumerator.cpp: In
member function 'LRESULT QextSerialEnumerator::onDeviceChangeWin(WPARAM,
LPARAM)':
C:\dev\cpp\qgis\src\core\gps\qextserialport\qextse rialenumerator.cpp:145:
error: 'DBT_DEVTYP_DEVICEINTERFACE' was not declared in this scope
C:\dev\cpp\qgis\src\core\gps\qextserialport\qextse rialenumerator.cpp:147:
error: 'PDEV_BROADCAST_DEVICEINTERFACE' was not declared in this scope
C:\dev\cpp\qgis\src\core\gps\qextserialport\qextse rialenumerator.cpp:147:
error: expected ';' before 'pDevInf'
C:\dev\cpp\qgis\src\core\gps\qextserialport\qextse rialenumerator.cpp:149:
error: 'pDevInf' was not declared in this scope
mingw32-make[2]: ***
[src/core/CMakeFiles/qgis_core.dir/gps/qextserialport/qextserialenumerator.cpp.obj]
Error 1
mingw32-make[1]: *** [src/core/CMakeFiles/qgis_core.dir/all] Error 2
mingw32-make: *** [all] Error 2

is this a error in the code , or any dependency needed ,
im sorry i have send it privately , i stuck with that error for 1 week
so plz solve this error plz
regards
sunil