Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    Unsolved how to transmit one after another in serialport connection .

    General and Desktop
    4
    8
    1516
    Loading More Posts
    • 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.
    • AnilReddy
      AnilReddy last edited by

      this program is for transmitting data in bit form, But i need transmit one after another. For example if press key one data has to be transmitted rather than all at at a time. please kindly help me. thanks in advance.

      void SerialConnect::write(const QString datan) {

      unsigned char engine3 = 64;
      unsigned char engine4 = 65;

      QByteArray byteToSend3(1, engine3);

      QByteArray byteToSend4(1, engine4);

      qint64 bytesWritten3 = serial->write(byteToSend3);
      qint64 bytesWritten4 = serial->write(byteToSend4);

      if (bytesWritten3==(-1) && bytesWritten4 ==(-1) ){
      qDebug() << "Error writing data to serial port: " << serial->errorString();
      }
      qDebug() << "SerialConnect::write(QString) Text sent as QByteArray: " << byteToSend3;
      qDebug() << "Number of bytes written: " << bytesWritten3;

              qDebug() << "SerialConnect::write(QString) Text sent as QByteArray: " << byteToSend4;
              qDebug() << "Number of bytes written: " << bytesWritten4;
      

      }

      1 Reply Last reply Reply Quote 0
      • K
        kuzulis Qt Champions 2020 last edited by

        Do you think that whole writing as '64 65' it is not a 'one after another' ? o_O
        I dare to assure that it follows as "one after another"! :)

        AnilReddy 1 Reply Last reply Reply Quote 0
        • AnilReddy
          AnilReddy @kuzulis last edited by

          @kuzulis
          yes it is not one after another , but need to modify the code as sending one after another. I need a logic to implement it.

          1 Reply Last reply Reply Quote 0
          • K
            kuzulis Qt Champions 2020 last edited by

            yes it is not one after another

            Really? Do you think it is sends in parallell? Or by other magic way?

            It seems to me, you do not know what do you need...

            AnilReddy 1 Reply Last reply Reply Quote 0
            • AnilReddy
              AnilReddy @kuzulis last edited by AnilReddy

              @kuzulis

              soryy i could not described it properly . Actually i am implementing this program to control the robotic arm . So there are 6 stepper motors in robo .each motor has its own separate actions for being controlled . I need to write a program to control the robotic arm by pressing keyboard buttons or graphical displayed buttons. So whenever i press the button only one required action should be triggered, it means only one action has to be sent . I need a logic place in my code. Please kindly help me.

              jsulm 1 Reply Last reply Reply Quote 0
              • jsulm
                jsulm Lifetime Qt Champion @AnilReddy last edited by

                @AnilReddy I think what @kuzulis is trying to tell you is that you can send several bytes at once in one QByteArray, so there is no need to send first, then send second.

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

                AnilReddy 1 Reply Last reply Reply Quote 0
                • AnilReddy
                  AnilReddy @jsulm last edited by

                  @jsulm
                  ok , But i need to control the flow by pressing keys.

                  M 1 Reply Last reply Reply Quote 0
                  • M
                    Mr.Floppy @AnilReddy last edited by

                    @AnilReddy
                    Maybe it would help reading some Documentation about QPushButton and to play around with the attached examples to get a feeling how everything works.
                    https://wiki.qt.io/How_to_Use_QPushButton

                    Buttons and all kinds of stuff can also be created in the WYSIWYG editor named QT Designer, if you don't want to type in all the code yourself.
                    http://doc.qt.io/qt-5/qtdesigner-manual.html

                    1 Reply Last reply Reply Quote 0
                    • First post
                      Last post