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

Problem trying to read from serial port

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 233 Views 1 Watching
  • 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 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.

    jsulmJ 1 Reply Last reply
    0
    • S sundrakk

      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.

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on 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

      • Login

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