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 can i send multiple data to one serial port ?
Forum Updated to NodeBB v4.3 + New Features

How can i send multiple data to one serial port ?

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 273 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.
  • M Offline
    M Offline
    Mucahit
    wrote on 15 Mar 2021, 07:04 last edited by
    #1

    Hi all,

    I have a project and I want to light two LEDs in this project at the same time. It crashes when I send data to the serial port like this :

    serial.write("first led high");
    serial.write("second led high");
    

    When I put a delay between two lines of code, my problem is solved but I think this is not correct because this is asynchronous communication.

    serial.write("first led high");
    delay(5); //milliseconds
    serial.write("second led high");
    

    What I want is that the serial port sends another data immediately after sending one data. How can I do that ? I aim to find something like :

    serial.write("first led high");
    while(serial.busy==true); // wait until the first one goes and send the second one
    serial.write("second led high");
    
    1 Reply Last reply
    0
    • C Online
      C Online
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on 15 Mar 2021, 07:06 last edited by
      #2

      It's a problem of your receiver. Serial communication is a stream so the receiver has to find out where one command ends and the next one starts. So fix your receiver.

      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
      3
      • M Offline
        M Offline
        Mucahit
        wrote on 15 Mar 2021, 09:19 last edited by
        #3

        Thank you, i will check the receiver.

        1 Reply Last reply
        0

        1/3

        15 Mar 2021, 07:04

        • Login

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