Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

How can i send multiple data to one serial port ?



  • 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");
    

  • Lifetime Qt Champion

    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.



  • Thank you, i will check the receiver.


Log in to reply