Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. 3rd Party Software
  4. Wrong data from qextserialport

Wrong data from qextserialport

Scheduled Pinned Locked Moved 3rd Party Software
4 Posts 3 Posters 2.8k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    cdeady
    wrote on 14 Dec 2011, 20:37 last edited by
    #1

    using Qt4.7 on Windows, I have created and opened the serial port in event mode. when the device sends its data, I don't get the same values as sent.

    Device sends:
    0x5A 0xF2 0x01 0x04 0xb3

    I receive:
    0x5A 0xF2 0x40 0x41 0xF6

    If I receive the data into Hyperterminal and save it to a file, I get the correct data. I don't see what I am doing wrong.

    Any ideas?

    Many thanks,
    Craig

    1 Reply Last reply
    0
    • V Offline
      V Offline
      vezprog
      wrote on 14 Dec 2011, 20:50 last edited by
      #2

      Try flushing the port and clearing any buffers when necessary so none of the data is being mixed up.

      Could you give a sample code of what your trying to do?

      Also, how are you reading the data?

      1 Reply Last reply
      0
      • C Offline
        C Offline
        cdeady
        wrote on 15 Dec 2011, 03:01 last edited by
        #3

        creating the port:
        @

            serialPort = new QextSerialPort(port, QextSerialPort::EventDriven);
        

        @

        where port is "COM26"

        after the port is created, I set the baud, parity, stop_bits, flow control, etc.

        opening the port:
        @
        serialPort->open(QIODevice::ReadWrite | QIODevice::Unbuffered);
        @

        I have tried it with Unbuffered and without

        in the OnDataAvailable SLOT:
        @

        int avail = serialPort->bytesAvailable();
        
        if(avail < 1) return;
        
        
        
        QByteArray usbdata;
        
        usbdata.resize(avail);
        
        int read = serialPort->read(usbdata.data(), usbdata.size());
        
        if(read<1) return;
        
        
        
        
        
        for(i=0; i<usbdata.size(); i++)
        
        {
        
            rx_char = usbdata[i];
        

        @

        process rx_char...

        I have looked at usbdata (which is a QByteArray) and it has the data as I posted previously as the receive data. Also, rx_char of course gets the same data, just on char at a time.

        1 Reply Last reply
        0
        • K Offline
          K Offline
          kuzulis
          Qt Champions 2020
          wrote on 15 Dec 2011, 07:12 last edited by
          #4

          Try using QSerialDevice 2.0.
          Read this "thread":http://developer.qt.nokia.com/forums/viewthread/11634/#67246

          1 Reply Last reply
          0

          1/4

          14 Dec 2011, 20:37

          • Login

          • Login or register to search.
          1 out of 4
          • First post
            1/4
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved