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. Qt Serial Port (works ok on Mac, can't read on Windows only write)

Qt Serial Port (works ok on Mac, can't read on Windows only write)

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 738 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.
  • H Offline
    H Offline
    hugofreitas
    wrote on last edited by
    #1

    Hello,

    I'm having a strange problem with qtserialport. I'll be thankful if someone help me solve this problem:

    • I'm not an expert in QT and STM.
    • I already search for this issue in several forums but I didn't have any luck.

    Problem:

    • I'm trying to communicate with STM32F767
    • The port device is a virtual one.
    • STM is sending a package of data each 250 ms (~100bytes).
    • Using Mac OS I don't have problems with the code and readyRead() signal is trigger normally.
    • If I use Windows and run the app readyRead() is never triggered and if I try to readAll() no data is showed.
    • Write method is working.

    Important note: Using Windows and after open and close the port with putty the app works normally. In these case readyRead() is triggered.

    You can find bellow the setup code used:

    firmware = new QSerialPort(this);
    ...
    firmware -> setPortName(port);
    firmware -> open(QIODevice::ReadWrite);
    firmware -> setBaudRate(QSerialPort::Baud115200);
    firmware -> setDataBits(QSerialPort::Data8);
    firmware -> setFlowControl(QSerialPort::NoFlowControl);
    firmware -> setParity(QSerialPort::NoParity);
    firmware -> setStopBits(QSerialPort::OneStop);
    
    connect(firmware, SIGNAL(readyRead()), this, SLOT(receivedata()));
    
    

    Thank you for your help,
    Hugo

    aha_1980A 1 Reply Last reply
    0
    • H hugofreitas

      Hello,

      I'm having a strange problem with qtserialport. I'll be thankful if someone help me solve this problem:

      • I'm not an expert in QT and STM.
      • I already search for this issue in several forums but I didn't have any luck.

      Problem:

      • I'm trying to communicate with STM32F767
      • The port device is a virtual one.
      • STM is sending a package of data each 250 ms (~100bytes).
      • Using Mac OS I don't have problems with the code and readyRead() signal is trigger normally.
      • If I use Windows and run the app readyRead() is never triggered and if I try to readAll() no data is showed.
      • Write method is working.

      Important note: Using Windows and after open and close the port with putty the app works normally. In these case readyRead() is triggered.

      You can find bellow the setup code used:

      firmware = new QSerialPort(this);
      ...
      firmware -> setPortName(port);
      firmware -> open(QIODevice::ReadWrite);
      firmware -> setBaudRate(QSerialPort::Baud115200);
      firmware -> setDataBits(QSerialPort::Data8);
      firmware -> setFlowControl(QSerialPort::NoFlowControl);
      firmware -> setParity(QSerialPort::NoParity);
      firmware -> setStopBits(QSerialPort::OneStop);
      
      connect(firmware, SIGNAL(readyRead()), this, SLOT(receivedata()));
      
      

      Thank you for your help,
      Hugo

      aha_1980A Offline
      aha_1980A Offline
      aha_1980
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi @hugofreitas,

      firmware = new QSerialPort(this);

      I guess firmware is a member variable ... right?

      firmware -> open(QIODevice::ReadWrite);

      Open returns a bool, check it!

      Also, I'd move all the setBaudRate & co. calls before calling open.
      Also, most of these calls have a return value to check.

      Regarding the controller: does it have an internal USB-serial port or do you use an external chip (e.g. FTDI)?

      Regards

      Qt has to stay free or it will die.

      1 Reply Last reply
      1
      • H Offline
        H Offline
        hugofreitas
        wrote on last edited by
        #3

        Thank you for your answer @aha_1980

        @aha_1980 said in Qt Serial Port (works ok on Mac, can't read on Windows only write):

        I guess firmware is a member variable ... right?

        Yes!

        @aha_1980 said in Qt Serial Port (works ok on Mac, can't read on Windows only write):

        I guess firmware is a member variable ... right?

        firmware -> open(QIODevice::ReadWrite);

        Open returns a bool, check it!

        Also, most of these calls have a return value to check.

        Everything that can return bools returns a true state and without errors. (firmware -> error())

        @aha_1980 said in Qt Serial Port (works ok on Mac, can't read on Windows only write):

        Regarding the controller: does it have an internal USB-serial port or do you use an external chip (e.g. FTDI)?

        Internal.

        @aha_1980 said in Qt Serial Port (works ok on Mac, can't read on Windows only write):

        Also, I'd move all the setBaudRate & co. calls before calling open.

        I'll try this and come back later.

        Regards,
        Hugo

        1 Reply Last reply
        0

        • Login

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