Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-109455

read() returns qint64 not int

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 6.4.0
    • Serial Port
    • None
    • All

    Description

      At  serial port example page there is example code. Look:

      int numRead = 0, numReadTotal = 0;
      char buffer[50];
      
      for (;;) {
          numRead  = serial.read(buffer, 50);
      
          // Do whatever with the array
      
          numReadTotal += numRead;
          if (numRead == 0 && !serial.waitForReadyRead())
              break;
      }
      

      But serial.read() function returns qint64.

      I suggest make
      qint64 numRead = 0, numReadTotal = 0;

       

      P.S. I agree that in real app serial.read() never returns more than int. If you think so you should use numRead=(int)serial.read(buffer, 50)

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            ablasche Alex Blasche
            dungeonlords Andrei Cherniaev
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes