How to use execute linux commands using QProcess

Thread Starter

zazas321

Joined Nov 29, 2015
936
Hey. I am trying to execute linux commands using QProcess. I am trying to flash and read back data from STM32 micro using raspberry pi using the stm32flash utility as such : http://manpages.ubuntu.com/manpages/bionic/man1/stm32flash.1.html I am able to flash the STM32 chip using this command on the linux terminal:
stm32flash -w datafile.hex /dev/ttyUSB0

and then read the data using

stm32flash -r home/pi/Desktop/readback.hex /dev/ttyUSB0

All I am trying to do is call one or another command using the Qprocess so I do not need to use terminal. Reading the QT QProcess examples, it seems straight forward and should work using the code below:

C:
QObject *parent;
QString program = "/home/pi/stm32flash-code/stm32flash";
QStringList arguments;
arguments <<-r /home/pi/Desktop/readback.hex<< "/dev//ttyUSB0";
QProcess *myProcess = new QProcess(parent);
myProcess->start(program, arguments);

The code above does not seem to be working. Any ideas?
 
Top