Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Problem trying to read from serial port
Forum Update on Monday, May 27th 2025

Problem trying to read from serial port

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 180 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.
  • S Offline
    S Offline
    sundrakk
    wrote on 22 Aug 2022, 20:48 last edited by
    #1

    Hi everyone,
    I'm having a hard time trying to read some data from the serial port. I'm able to write from it to a bluepill, but it seems that the program stucks on usbDevice -> readAll(), because after that I put a lot of qDebug() that will print something on the console debugger, and it doesn't happen.

    The code for read the serial port is:

    dataread = usbDevice -> readAll();
    if(dataread[0] != 0){
        qDebug() << "ok";
    }
    digin.append(dataread);
    
    if(dataread.size() >= 2){
        qDebug() << "Ok";
    
    }
    
    qDebug() << dataread;
    qDebug() << digin;
    qDebug() << dataread.size();
    qDebug() << dataread.count();
    qDebug() << dataread.length();
    qDebug() << digin.size();
    qDebug() << digin.count();
    qDebug() << digin.length();
    

    This is the last I tried, but nothing happens, I'm desperate.

    J 1 Reply Last reply 23 Aug 2022, 05:15
    0
    • S sundrakk
      22 Aug 2022, 20:48

      Hi everyone,
      I'm having a hard time trying to read some data from the serial port. I'm able to write from it to a bluepill, but it seems that the program stucks on usbDevice -> readAll(), because after that I put a lot of qDebug() that will print something on the console debugger, and it doesn't happen.

      The code for read the serial port is:

      dataread = usbDevice -> readAll();
      if(dataread[0] != 0){
          qDebug() << "ok";
      }
      digin.append(dataread);
      
      if(dataread.size() >= 2){
          qDebug() << "Ok";
      
      }
      
      qDebug() << dataread;
      qDebug() << digin;
      qDebug() << dataread.size();
      qDebug() << dataread.count();
      qDebug() << dataread.length();
      qDebug() << digin.size();
      qDebug() << digin.count();
      qDebug() << digin.length();
      

      This is the last I tried, but nothing happens, I'm desperate.

      J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 23 Aug 2022, 05:15 last edited by
      #2

      @sundrakk Please provide more information!
      Where is the code you posted located?
      Is it in a slot connected to readyRead signal from QSerialPort?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      3

      1/2

      22 Aug 2022, 20:48

      • Login

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