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. how to transmit one after another in serialport connection .
QtWS25 Last Chance

how to transmit one after another in serialport connection .

Scheduled Pinned Locked Moved Unsolved General and Desktop
8 Posts 4 Posters 1.9k 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.
  • AnilReddyA Offline
    AnilReddyA Offline
    AnilReddy
    wrote on last edited by
    #1

    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
    0
    • K Offline
      K Offline
      kuzulis
      Qt Champions 2020
      wrote on last edited by
      #2

      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"! :)

      AnilReddyA 1 Reply Last reply
      0
      • K kuzulis

        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"! :)

        AnilReddyA Offline
        AnilReddyA Offline
        AnilReddy
        wrote on last edited by
        #3

        @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
        0
        • K Offline
          K Offline
          kuzulis
          Qt Champions 2020
          wrote on last edited by
          #4

          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...

          AnilReddyA 1 Reply Last reply
          0
          • K kuzulis

            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...

            AnilReddyA Offline
            AnilReddyA Offline
            AnilReddy
            wrote on last edited by AnilReddy
            #5

            @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.

            jsulmJ 1 Reply Last reply
            0
            • AnilReddyA 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.

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

              @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

              AnilReddyA 1 Reply Last reply
              0
              • jsulmJ jsulm

                @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.

                AnilReddyA Offline
                AnilReddyA Offline
                AnilReddy
                wrote on last edited by
                #7

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

                M 1 Reply Last reply
                0
                • AnilReddyA AnilReddy

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

                  M Offline
                  M Offline
                  Mr.Floppy
                  wrote on last edited by
                  #8

                  @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
                  0

                  • Login

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