Results 1 to 7 of 7

Thread: Reading data from usb port

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Apr 2011
    Posts
    7
    Qt products
    Qt4
    Platforms
    Windows

    Question Reading data from usb port

    I'd like to read data from a usb-port,
    I've found someone using the following code with a micocontroller that will send data when you push a button, here is the code:

    The Qt code:

    Qt Code:
    1. comPort = new QextSerialPort("COM7");
    2. //set com port settings
    3.  
    4. comPort->setBaudRate(BAUD9600);
    5. comPort->setFlowControl(FLOW_HARDWARE);
    6. comPort->setParity(PAR_NONE);
    7. comPort->setDataBits(DATA_8);
    8. comPort->setStopBits(STOP_1);
    9.  
    10. //read data from com port
    11.  
    12. comPort->open(QIODevice::ReadWrite);
    13. char buff[1024];
    14. int numBytes;
    15. QString msg;
    16. numBytes = comPort->bytesAvailable();
    17. if(numBytes > 0)
    18. {
    19. if(numBytes > 1024){
    20. numBytes = 1024;}
    21. int i = comPort->read(buff, numBytes);
    22. buff[i] = '\0';
    23. msg = buff;
    24. }
    To copy to clipboard, switch view to plain text mode 

    The .pro filethe directions are from someone else ofcourse)

    Qt Code:
    1. //my qextserialport dir is C:/qt/qextserialport
    2. ...
    3. INCLUDEPATH += C:/Qt/qextserialport
    4. LIBS += C:\Qt\qextserialport\build\qextserialport.dll
    5. ..
    To copy to clipboard, switch view to plain text mode 

    My question now is, how do I instal qextserialport? I've downloaded qextserialport-1.2.rar from http://sourceforge.net/projects/qext...a.zip/download , but how do I install it?
    my qt map is located at: C:\Qt\2010.05\

    My qt is based on 4.7 and im running windows 7 x64 home premium.
    Last edited by jantje78; 17th May 2011 at 11:48. Reason: message at the .pro file:(...)

Similar Threads

  1. Replies: 3
    Last Post: 27th April 2011, 09:27
  2. Serial Port Reading problem
    By sfabel in forum Qt Programming
    Replies: 12
    Last Post: 18th February 2010, 14:59
  3. Problem in reading port using QextSerialPort
    By cutie.monkey in forum Qt Programming
    Replies: 6
    Last Post: 2nd July 2009, 02:07
  4. Replies: 1
    Last Post: 1st July 2009, 00:37
  5. Replies: 1
    Last Post: 1st July 2009, 00: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.