[solved]how I can send multiply commands through serial interface using QByteArray



  • Hi,
    I am using Qt to creat a GUI to communicate with X device through RS232

    I use QByteArray to send a single request to x device

    @void SerialCom::onSendButtonClicked()
    {

    if (port->isOpen());
    
    QString r= ui->comboBox->currentText();
    
    if(R=="XXXX"){
        
        QByteArray msg("00RS\r\n"); 
        port->write(msg);
    
    }@
    

    I have a list of commands to initialize the sensor setting and I have to send all these commands in one function.
    My Question is how I can send multiply commands through serial interface ( example of the command to be send ->"00RS\r\n") ?! is it right to create QByteArray for each command ?


  • Lifetime Qt Champion

    Hi,

    Why not build a complete list of command first and then send everything at once ?



  • how to do that can you please give me an example or any keyword so I can search about that and implement it in my code .
    [quote author="SGaist" date="1404977927"]Hi,

    Why not build a complete list of command first and then send everything at once ?[/quote]



  • Thanks , I put the list of commands as you suggest in QList<QByteArray> list;

    and it is work ..

    [quote author="SGaist" date="1404977927"]Hi,

    Why not build a complete list of command first and then send everything at once ?[/quote]


  • Lifetime Qt Champion

    You're welcome !

    Since you have your transmission working now, please update the thread title prepending [solved] so other forum users may know a solution has been found :)


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.