Results 1 to 8 of 8

Thread: QextSerialEnumeraton problem

  1. #1
    kaszewczyk Guest

    Wink QextSerialEnumeraton problem

    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:
    Qt Code:
    1. C:/HyperTerminal/qextserialenumerator.cpp:40: error: invalid conversion from `BYTE*' to `const char*'
    2. C:/HyperTerminal/qextserialenumerator.cpp:40: error: initializing argument 1 of `static QString QString::fromLocal8Bit(const char*, int)'
    3. C:/HyperTerminal/qextserialenumerator.cpp:57: error: invalid conversion from `BYTE*' to `const char*'
    4. C:/HyperTerminal/qextserialenumerator.cpp:57: error: initializing argument 1 of `static QString QString::fromLocal8Bit(const char*, int)'
    To copy to clipboard, switch view to plain text mode 

    i was trying 2 something like this:
    Qt Code:
    1. QList<QextPortInfo> serialPortsOnSystem = QextSerialEnumeration::getPorts();
    2. //now i want to put them in combobox
    3. QComboBox port;
    4. port.addItem(serialPortsOnSystem.takeFirst().portName.toLocal8Bit().constData());)
    To copy to clipboard, switch view to plain text mode 

    i dont know if its helpful but this is my pro file:
    Qt Code:
    1. # -------------------------------------------------
    2. # Project created by QtCreator 2009-10-22T23:10:11
    3. # -------------------------------------------------
    4. TARGET = HyperTerminal
    5. TEMPLATE = app
    6. SOURCES += main.cpp \
    7. hyperterminal.cpp \
    8. qextserialenumerator.cpp \
    9. settingsdialog.cpp \
    10. win_qextserialport.cpp \
    11. qextserialbase.cpp
    12. HEADERS += hyperterminal.h \
    13. qextserialenumerator.h \
    14. settingsdialog.h \
    15. win_qextserialport.h \
    16. qextserialbase.cpp
    17. win32:DEFINES = _TTY_WIN_
    To copy to clipboard, switch view to plain text mode 

    Best Regards
    kaszewczyk

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

  2. #2
    Join Date
    Oct 2009
    Posts
    364
    Thanks
    10
    Thanked 37 Times in 36 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QextSerialEnumeraton problem

    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
    win32EFINES += _TTY_WIN_

    3) in my code:
    Qt Code:
    1. port = new QextSerialPort(CommPort, portSettings, QextSerialPort::EventDriven);
    2. port->open(QIODevice::ReadWrite);
    To copy to clipboard, switch view to plain text mode 

    4) enumeration:
    Qt Code:
    1. QList<QextPortInfo> ports = QextSerialEnumerator::getPorts();
    2. cmbPort->clear();
    3.  
    4. for(int i=0; i< ports.size(); i++)
    5. {
    6. cmbPort->addItem(QString("%1").arg(ports.at(i).portName.toLocal8Bit().constData()));
    7. }
    To copy to clipboard, switch view to plain text mode 

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

    hope this helps

  3. #3
    kaszewczyk Guest

    Default Re: QextSerialEnumeraton problem

    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:
    Qt Code:
    1. C:/QextSerialPort/Makefile.Debug:169: warning: overriding commands for target `build/obj/qextserialport.o'
    2. C:/QextSerialPort/Makefile.Debug:156: warning: ignoring old commands for target `build/obj/qextserialport.o'
    3. C:/QextSerialPort/Makefile.Debug:172: warning: overriding commands for target `build/obj/qextserialenumerator.o'
    4. C:/QextSerialPort/Makefile.Debug:159: warning: ignoring old commands for target `build/obj/qextserialenumerator.o'
    To copy to clipboard, switch view to plain text mode 
    etc

    Best Regards
    kaszewczyk

  4. #4
    Join Date
    Oct 2009
    Posts
    364
    Thanks
    10
    Thanked 37 Times in 36 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QextSerialEnumeraton problem

    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?

  5. #5
    kaszewczyk Guest

    Default Re: QextSerialEnumeraton problem

    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
    Qt Code:
    1. # #####################################################################
    2. # Enumerator
    3. # #####################################################################
    4. PROJECT = try_enumerator
    5. TEMPLATE = app
    6. DEPENDPATH += .
    7. INCLUDEPATH += ../..
    8. QMAKE_LIBDIR += ../../build
    9. OBJECTS_DIR = obj
    10. MOC_DIR = moc
    11. UI_DIR = uic
    12. CONFIG += qt \
    13. warn_on \
    14. console
    15. SOURCES += main.cpp
    16. CONFIG(debug, debug|release):LIBS += -lqextserialportd
    17. else:LIBS += -lqextserialport
    18. unix:DEFINES = _TTY_POSIX_
    19. win32:DEFINES = _TTY_WIN_
    20. HEADERS += qextserialenumerator.h
    21. OTHER_FILES += qextserialportd.dll
    To copy to clipboard, switch view to plain text mode 

    main.cpp:
    Qt Code:
    1. /**
    2.  * @file main.cpp
    3.  * @brief Main file.
    4.  * @author MichaĹ‚ Policht
    5.  */
    6.  
    7. #include <qextserialenumerator.h>
    8. #include <QtCore/QList>
    9.  
    10. int main(int argc, char *argv[])
    11. {
    12. QList<QextPortInfo> ports = QextSerialEnumerator::getPorts();
    13. printf("List of ports:\n");
    14. for (int i = 0; i < ports.size(); i++) {
    15. printf("port name: %s\n", ports.at(i).portName.toLocal8Bit().constData());
    16. printf("friendly name: %s\n", ports.at(i).friendName.toLocal8Bit().constData());
    17. printf("physical name: %s\n", ports.at(i).physName.toLocal8Bit().constData());
    18. printf("enumerator name: %s\n", ports.at(i).enumName.toLocal8Bit().constData());
    19. printf("===================================\n\n");
    20. }
    21. return EXIT_SUCCESS;
    22. }
    To copy to clipboard, switch view to plain text mode 

    the output
    Qt Code:
    1. C:/try_enumerator/main.cpp:7: qextserialenumerator.h: No such file or directory
    2. C:/try_enumerator/main.cpp:12: error: `QextPortInfo' was not declared in this scope
    3. C:/try_enumerator/main.cpp:12: error: invalid type in declaration before '=' token
    4. C:/try_enumerator/main.cpp:12: error: `QextSerialEnumerator' has not been declared
    5. C:/try_enumerator/main.cpp:14: error: request for member `size' in `ports', which is of non-class type `int'
    6. C:/try_enumerator/main.cpp:15: error: request for member `at' in `ports', which is of non-class type `int'
    7. C:/try_enumerator/main.cpp:17: error: request for member `at' in `ports', which is of non-class type `int'
    8. C:/try_enumerator/main.cpp:17: error: request for member `at' in `ports', which is of non-class type `int'
    9. C:/try_enumerator/main.cpp:12: warning: unused variable 'QextPortInfo'
    10. C:/try_enumerator/main.cpp:12: warning: unused variable 'getPorts'
    To copy to clipboard, switch view to plain text mode 

    Best Regards
    kaszewczyk

  6. #6
    Join Date
    Oct 2009
    Posts
    364
    Thanks
    10
    Thanked 37 Times in 36 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QextSerialEnumeraton problem

    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).

  7. #7
    kaszewczyk Guest

    Default Re: QextSerialEnumeraton problem

    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 , im still really thankful for Your help, thanks again.


    Yours
    kaszewczyk

  8. #8
    Join Date
    Oct 2010
    Posts
    1
    Qt products
    Qt4
    Platforms
    Windows

    Question Re: QextSerialEnumeraton problem

    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:nDeviceChangeWin(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

Similar Threads

  1. Problem with QAbstractListModel
    By eekhoorn12 in forum Qt Programming
    Replies: 3
    Last Post: 26th August 2009, 14:26
  2. Replies: 1
    Last Post: 23rd April 2009, 09:05
  3. Replies: 19
    Last Post: 3rd April 2009, 23:17
  4. Grid Layout Problem
    By Seema Rao in forum Qt Programming
    Replies: 2
    Last Post: 4th May 2006, 12:45
  5. fftw problem
    By lordy in forum General Programming
    Replies: 1
    Last Post: 16th March 2006, 21:36

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.