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. QTSerialPort doesn't read data after another serial software
Forum Updated to NodeBB v4.3 + New Features

QTSerialPort doesn't read data after another serial software

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 4 Posters 864 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.
  • A Offline
    A Offline
    Alex Lyapin
    wrote on last edited by
    #1

    Hi all,
    Let me explain the issue:
    I do serial port communication with device, I have several programs that work with this device and one program is written not by me (I do not have access to sources) and is based on some "handmade" asm serial port routine. My current program is just simple serial port monitor based on QSerialPort, readready signal.
    When I connect to device and read data everything works perfect, but when I read serial port data using another software (those I have no access to) and then try to read it again with my qt program, I get the situation:
    -program opens port
    -function, corresponding to readready signal, never calls

    The important thing, that I need to reboot my PC to have opportunity to read serial port data with my qt program.

    I've done the simple serial port monitor with Python, everything works. So the issue is only with qt realization.

    Can you advice me something? What can I check?

    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Maybe the other program sets some other serial port parameters - make sure to specify all parameters the way you need them.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      4
      • A Offline
        A Offline
        Alex Lyapin
        wrote on last edited by Alex Lyapin
        #3

        #Christian, I am setting all the parameters required (port name, baud rate, flow control, stop bits, parity etc.). As I said, when I start my program everything works perfectly. But, after and only after another program is connected to serial port, works with it, disconnects from it, I can't work with this port anymore (I can open it but not receive data from).
        I can do this with my python script, and receive data, but not with qt program.

        Is there some way I can debug low level serial port flags and settings from qt?
        I don't understand this situation, since the port is opening easily, and my function is connected to serial port signal. So the difference between two runs of the completely same program is just run of another program, not connected with qt program in any way.

        Looks like some bug...

        aha_1980A 1 Reply Last reply
        0
        • A Alex Lyapin

          #Christian, I am setting all the parameters required (port name, baud rate, flow control, stop bits, parity etc.). As I said, when I start my program everything works perfectly. But, after and only after another program is connected to serial port, works with it, disconnects from it, I can't work with this port anymore (I can open it but not receive data from).
          I can do this with my python script, and receive data, but not with qt program.

          Is there some way I can debug low level serial port flags and settings from qt?
          I don't understand this situation, since the port is opening easily, and my function is connected to serial port signal. So the difference between two runs of the completely same program is just run of another program, not connected with qt program in any way.

          Looks like some bug...

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

          Hi @Alex-Lyapin

          • which platform?
          • which Qt version?
          • can you show your Qt code?

          Regards

          Qt has to stay free or it will die.

          1 Reply Last reply
          0
          • Kent-DorfmanK Offline
            Kent-DorfmanK Offline
            Kent-Dorfman
            wrote on last edited by
            #5

            Either the mystery program is fiddling with a parameter you don't explicitly reset (modem control comes to mind), or it is sending a speed change request to the other device and syncing at a different speed, such that you would need to power cycle/reboot, to reset the other device. I'm assuming you're using usb/rs232 and not a real pc comm port.

            It is best practice to reset a serial device to the "tty sane" state and then explicitly set all necessary fields when a program accesses the device. There is no such thing as "simple serial". That's why folks get into trouble; underestimating...and butchering the physical protocols because they feel that they know better than the EIA guys who developed it 50 years ago.

            1 Reply Last reply
            2
            • A Offline
              A Offline
              Alex Lyapin
              wrote on last edited by
              #6

              @Kent-Dorfman , thank you for the answer. Yes, it is usb/rs232 using ch340.

              I don't call serial communication simple. I call my program for this issue simple, cause it is based only on three operations:

              1. open serial port with required settings
              2. connect readyread signal to function
              3. receive data and print it
                And as I said before, this works ok when I connect to device all the times before "mystery" program is connected. I assume it changes some parameter I don't catch and thus I cant receive data anymore.
                Also, the serial device starts working only when I establish connection. The rest of time is powered off, so I think the state at the port initialization is the same.

              @aha_1980 , thank you for the answer
              I will send this info as soon as I get to my PC

              Most interesting, I was doing the "same" logics with Java and Python, and didn't get this situation.
              Is there some state when the readyread signal does not emit?

              I will also try to read data without signal, using just timer and check bytes available. Will send results later.
              Thanks guys

              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