Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. I also have the same issue...

I also have the same issue...

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
3 Posts 3 Posters 372 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.
  • D Offline
    D Offline
    Dwende
    wrote on last edited by
    #1

    Re: How to send data to Serial Port in Qt Test

    I also have the same issue.

    The code works outside the QTest project, but inside it fails !!

    QDEBUG : TestKat500::test_3_Ant3() Sending  "AN3;"
    QWARN  : TestKat500::test_3_Ant3() QSocketNotifier: Can only be used with threads started with QThread
    QDEBUG : TestKat500::test_3_Ant3() Short Delay Start
    QDEBUG : TestKat500::test_3_Ant3() Short Delay End
    QINFO  : TestKat500::test_3_Ant3() Read  ""
    QWARN  : TestKat500::test_3_Ant3() Wanted  4  only got  0
    QDEBUG : TestKat500::test_3_Ant3() Kat Releasing Serial port
    

    I have tried to see if by using QConcurrent I can force the test to run as a thread.

    I suppose that often people Mock the output of Serial devices, and so - this is slightly against the common use-case. But as the test equipment (radio) is sitting on my desk next to the development machine - writing a MOCK seems a little like making work for myself.

    Running Qt 6.2.3 on Mac M1 Silicon.

    jsulmJ J.HilkJ 2 Replies Last reply
    0
    • D Dwende

      Re: How to send data to Serial Port in Qt Test

      I also have the same issue.

      The code works outside the QTest project, but inside it fails !!

      QDEBUG : TestKat500::test_3_Ant3() Sending  "AN3;"
      QWARN  : TestKat500::test_3_Ant3() QSocketNotifier: Can only be used with threads started with QThread
      QDEBUG : TestKat500::test_3_Ant3() Short Delay Start
      QDEBUG : TestKat500::test_3_Ant3() Short Delay End
      QINFO  : TestKat500::test_3_Ant3() Read  ""
      QWARN  : TestKat500::test_3_Ant3() Wanted  4  only got  0
      QDEBUG : TestKat500::test_3_Ant3() Kat Releasing Serial port
      

      I have tried to see if by using QConcurrent I can force the test to run as a thread.

      I suppose that often people Mock the output of Serial devices, and so - this is slightly against the common use-case. But as the test equipment (radio) is sitting on my desk next to the development machine - writing a MOCK seems a little like making work for myself.

      Running Qt 6.2.3 on Mac M1 Silicon.

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Dwende said in I also have the same issue...:

      I have tried to see if by using QConcurrent I can force the test to run as a thread

      Why?

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

      1 Reply Last reply
      0
      • D Dwende

        Re: How to send data to Serial Port in Qt Test

        I also have the same issue.

        The code works outside the QTest project, but inside it fails !!

        QDEBUG : TestKat500::test_3_Ant3() Sending  "AN3;"
        QWARN  : TestKat500::test_3_Ant3() QSocketNotifier: Can only be used with threads started with QThread
        QDEBUG : TestKat500::test_3_Ant3() Short Delay Start
        QDEBUG : TestKat500::test_3_Ant3() Short Delay End
        QINFO  : TestKat500::test_3_Ant3() Read  ""
        QWARN  : TestKat500::test_3_Ant3() Wanted  4  only got  0
        QDEBUG : TestKat500::test_3_Ant3() Kat Releasing Serial port
        

        I have tried to see if by using QConcurrent I can force the test to run as a thread.

        I suppose that often people Mock the output of Serial devices, and so - this is slightly against the common use-case. But as the test equipment (radio) is sitting on my desk next to the development machine - writing a MOCK seems a little like making work for myself.

        Running Qt 6.2.3 on Mac M1 Silicon.

        J.HilkJ Offline
        J.HilkJ Offline
        J.Hilk
        Moderators
        wrote on last edited by J.Hilk
        #3

        @Dwende like the op, you probably have the SerialPort member variable one the stack.

        initialise it correctly in the initaliser list of your constructor so that it has the correct parent, than it should be moved correctly to any thread, the parent is moved to

        class MySerialPort : public QObject
        {
            Q_OBJECT
            
        public:
            MySerialPort (QObject *parent = nullptr) 
                : QObject(parent)
                , m_serialPort(this)
            {
                
            }
            
        private:
            QSerialPort m_serialPort;
        };
        
        

        Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


        Q: What's that?
        A: It's blue light.
        Q: What does it do?
        A: It turns blue.

        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