How to use execute linux commands using QProcess

Thread Starter


Joined Nov 29, 2015
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 : 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:

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?