shell script in qt not changing the value
-
Hi everyone help required!
I pass two values in shell script when script runs then Two RX_LO run in device one at 2425000000 and other at 2475000000 within script when my Rx_LO at 2425000000 then it out value at Tx_LO at 2425000000 but when my value change for other one at 2475000000 then its still gave me value for Tx_LO at 2425000000 previous value of first one. How I can change it according new for second LO?void secbox::dds_control(){ QProcess proc; QStringList args; proc.setProcessChannelMode(QProcess::MergedChannels); args << "devmem2" << "0x80000000"; proc.start("sudo", args); if(proc.waitForFinished()) { QString result = QString(proc.readAll()); qDebug() << "devmem2 done and returning:"<<result; QString dds_en = result.mid(result.lastIndexOf("0x")); QString test=dds_en.simplified(); qDebug()<<"Detected:"<<dds_en; qDebug()<<"Detected 2:"<<test; //test.flush(); if(test=="0x0"){ QProcess p1 ; p1.startDetached("/bin/bash", QStringList() << "-c" << "/home/analog/Documents/master/hoppingMaster.sh"); QProcess Rx_CF; Rx_CF.start("cat /sys/bus/iio/devices/iio:device1/out_altvoltage0_RX_LO_frequency"); Rx_CF.waitForFinished(-1); // will wait forever until finished Rx_CF_read =Rx_CF.readAllStandardOutput(); qDebug()<<"Rx LO ="<<Rx_CF_read; } if(test=="0x1"){ QFile file("/sys/bus/iio/devices/iio:device1/out_altvoltage1_TX_LO_frequency"); qDebug()<<"Try to set out_altvoltage1_TX_LO_frequency to:"<<Rx_CF_read; if(file.open(QIODevice::WriteOnly)){ quint64 count = file.write(Rx_CF_read.toLatin1()); Q_ASSERT(count > 0); file.flush(); file.close(); qDebug()<<"QFile Run:"<<count; } } proc.close(); } else qDebug() << "faild to start devmem2 for dds_en";
-
I don't know how people can understand what you write, or answer your specific desires, about which we have no idea.
I see a
Rx_CF_read
variable. Since I do not see it declared I have to assume it is a (persistent) member variable. I see it set duringif(test=="0x0")
. I see it used (at a later date?) to write during theif(test=="0x1")
case. Only you know whether it has the desired value at that point.As a separate issue, I don't know why in order to read the content of file
/sys/bus/iio/devices/iio:device1/out_altvoltage0_RX_LO_frequency
you issue an OScat
command and read the stdout from that, when all you should do is open the file for read and read it, why the OScat
command?Also as a separate issue, you will (potentially at least) execute
/home/analog/Documents/master/hoppingMaster.sh
multiple times. Is that desired, or is it desired only once before all this reading/writing? Again only you know that.Finally, your title is "shell script in qt not changing the value". What shell script is not changing what value? the only shell script I see is
hoppingMaster.sh
? And again only you can know how that behaves/what it;s supposed to do. -
@JonB said in shell script in qt not changing the value:
I don't know how people can understand what you write, or answer your specific desires, about which we have no idea.
I see a Rx_CF_read variable. Since I do not see it declared I have to assume it is a (persistent) member variable. I see it set during if(test=="0x0"). I see it used (at a later date?) to write during the if(test=="0x1") case. Only you know whether it has the desired value at that point.
As a separate issue, I don't know why in order to read the content of file /sys/bus/iio/devices/iio:device1/out_altvoltage0_RX_LO_frequency you issue an OS cat command and read the stdout from that, when all you should do is open the file for read and read it, why the OS cat command?
Also as a separate issue, you will (potentially at least) execute /home/analog/Documents/master/hoppingMaster.sh multiple times. Is that desired, or is it desired only once before all this reading/writing? Again only you know that.
Finally, your title is "shell script in qt not changing the value". What shell script is not changing what value? the only shell script I see is hoppingMaster.sh? And again only you can know how that behaves/what it;s supposed to do.@JonB Thanks your valuable response!
Variable Rx_CF_read is defined in header file as QString. And its value is updated as it should be.I am reading and writing in OS file directly so thats why I am accessing the file using cat command because it directly access in terminal.
I need to run the hoppingMaster.sh file once when GUI start before any reading and writing step.
See below
#!/bin/sh find_zynq_base_gpio () { for i in /sys/class/gpio/gpiochip*; do if [ "zynq_gpio" = `cat $i/label` ]; then return `echo $i | sed 's/^[^0-9]\+//'` break fi done return -1 } if [ `id -u` != "0" ] then echo "This script must be run as root" 1>&2 exit 1 fi for i in $(find -L /sys/bus/iio/devices -maxdepth 2 -name name) do dev_name=$(cat $i); if [ "$dev_name" = "ad9361-phy" ]; then phy_path=$(echo $i | sed 's:/name$::') cd $phy_path break fi done if [ "$dev_name" != "ad9361-phy" ]; then exit fi #Setup 8 Profiles 1MHz spaced ##GPS-P1 echo 2425000000 > out_altvoltage0_RX_LO_frequency echo "Initializing PROFILE $i at 2425000000 MHz" echo 0 > out_altvoltage0_RX_LO_fastlock_store ##GPS-P2 echo 2475000000 > out_altvoltage0_RX_LO_frequency echo "Initializing PROFILE $i at 2475000000 MHz" echo 1 > out_altvoltage0_RX_LO_fastlock_store ##GPS-P3 echo 2425000000 > out_altvoltage0_RX_LO_frequency echo "Initializing PROFILE $i at 2425000000 MHz" echo 2 > out_altvoltage0_RX_LO_fastlock_store ##GPS-P4 echo 2475000000 > out_altvoltage0_RX_LO_frequency echo "Initializing PROFILE $i at 2475000000 MHz" echo 3 > out_altvoltage0_RX_LO_fastlock_store ##GPS-P5 echo 2425000000 > out_altvoltage0_RX_LO_frequency echo "Initializing PROFILE $i at 2425000000 MHz" echo 4 > out_altvoltage0_RX_LO_fastlock_store ##GPS-P1 echo 2475000000 > out_altvoltage0_RX_LO_frequency echo "Initializing PROFILE $i at 2475000000 MHz" echo 5 > out_altvoltage0_RX_LO_fastlock_store ##GPS-P2 echo 2425000000 > out_altvoltage0_RX_LO_frequency echo "Initializing PROFILE $i at 2425000000 MHz" echo 6 > out_altvoltage0_RX_LO_fastlock_store ##GPS-P4 echo 2475000000 > out_altvoltage0_RX_LO_frequency echo "Initializing PROFILE $i at 2475000000 MHz" echo 7 > out_altvoltage0_RX_LO_fastlock_store #Enable Fastlock Mode echo "Entering to find the hopping IP" for i in $(find -L /sys/bus/iio/devices -maxdepth 2 -name name) do dev_name=$(cat $i) if [ "$dev_name" = "axi-hopper" ]; then phy_path=$(echo $i | sed 's:/name$::') echo "Hopping IP found" cd $phy_path break fi done if [ "$dev_name" != "axi-hopper" ]; then echo "Hopping IP not found" exit fi echo 1 > hopping_enable echo 2000 > dwell_samples
-
@JonB said in shell script in qt not changing the value:
I don't know how people can understand what you write, or answer your specific desires, about which we have no idea.
I see a Rx_CF_read variable. Since I do not see it declared I have to assume it is a (persistent) member variable. I see it set during if(test=="0x0"). I see it used (at a later date?) to write during the if(test=="0x1") case. Only you know whether it has the desired value at that point.
As a separate issue, I don't know why in order to read the content of file /sys/bus/iio/devices/iio:device1/out_altvoltage0_RX_LO_frequency you issue an OS cat command and read the stdout from that, when all you should do is open the file for read and read it, why the OS cat command?
Also as a separate issue, you will (potentially at least) execute /home/analog/Documents/master/hoppingMaster.sh multiple times. Is that desired, or is it desired only once before all this reading/writing? Again only you know that.
Finally, your title is "shell script in qt not changing the value". What shell script is not changing what value? the only shell script I see is hoppingMaster.sh? And again only you can know how that behaves/what it;s supposed to do.@JonB Thanks your valuable response!
Variable Rx_CF_read is defined in header file as QString. And its value is updated as it should be.I am reading and writing in OS file directly so thats why I am accessing the file using cat command because it directly access in terminal.
I need to run the hoppingMaster.sh file once when GUI start before any reading and writing step.
See below
#!/bin/sh find_zynq_base_gpio () { for i in /sys/class/gpio/gpiochip*; do if [ "zynq_gpio" = `cat $i/label` ]; then return `echo $i | sed 's/^[^0-9]\+//'` break fi done return -1 } if [ `id -u` != "0" ] then echo "This script must be run as root" 1>&2 exit 1 fi for i in $(find -L /sys/bus/iio/devices -maxdepth 2 -name name) do dev_name=$(cat $i); if [ "$dev_name" = "ad9361-phy" ]; then phy_path=$(echo $i | sed 's:/name$::') cd $phy_path break fi done if [ "$dev_name" != "ad9361-phy" ]; then exit fi #Setup 8 Profiles 1MHz spaced ##GPS-P1 echo 2425000000 > out_altvoltage0_RX_LO_frequency echo "Initializing PROFILE $i at 2425000000 MHz" echo 0 > out_altvoltage0_RX_LO_fastlock_store ##GPS-P2 echo 2475000000 > out_altvoltage0_RX_LO_frequency echo "Initializing PROFILE $i at 2475000000 MHz" echo 1 > out_altvoltage0_RX_LO_fastlock_store ##GPS-P3 echo 2425000000 > out_altvoltage0_RX_LO_frequency echo "Initializing PROFILE $i at 2425000000 MHz" echo 2 > out_altvoltage0_RX_LO_fastlock_store ##GPS-P4 echo 2475000000 > out_altvoltage0_RX_LO_frequency echo "Initializing PROFILE $i at 2475000000 MHz" echo 3 > out_altvoltage0_RX_LO_fastlock_store ##GPS-P5 echo 2425000000 > out_altvoltage0_RX_LO_frequency echo "Initializing PROFILE $i at 2425000000 MHz" echo 4 > out_altvoltage0_RX_LO_fastlock_store ##GPS-P1 echo 2475000000 > out_altvoltage0_RX_LO_frequency echo "Initializing PROFILE $i at 2475000000 MHz" echo 5 > out_altvoltage0_RX_LO_fastlock_store ##GPS-P2 echo 2425000000 > out_altvoltage0_RX_LO_frequency echo "Initializing PROFILE $i at 2425000000 MHz" echo 6 > out_altvoltage0_RX_LO_fastlock_store ##GPS-P4 echo 2475000000 > out_altvoltage0_RX_LO_frequency echo "Initializing PROFILE $i at 2475000000 MHz" echo 7 > out_altvoltage0_RX_LO_fastlock_store #Enable Fastlock Mode echo "Entering to find the hopping IP" for i in $(find -L /sys/bus/iio/devices -maxdepth 2 -name name) do dev_name=$(cat $i) if [ "$dev_name" = "axi-hopper" ]; then phy_path=$(echo $i | sed 's:/name$::') echo "Hopping IP found" cd $phy_path break fi done if [ "$dev_name" != "axi-hopper" ]; then echo "Hopping IP not found" exit fi echo 1 > hopping_enable echo 2000 > dwell_samples
@Wasee said in shell script in qt not changing the value:
I am reading and writing in OS file directly so thats why I am accessing the file using cat command because it directly access in terminal.
I do not know what you think this means. Going
cat
on a file and reading from its stdout does the same as just opening the file for read, only much slower.I need to run the hoppingMaster.sh file once when GUI start before any reading and writing step.
Then I suggest you change your code to make that the case instead of what it does now, which is potentially to run it any number of times, whenever
test=="0x0"
, which we have no idea how many times may occur. I have no interest in reading through the code of the script to figure what it does.Whatever, I am no clearer on what your question is, and it appears from the lack of responses nor is anyone else. Other than you need to get your logic right, this does not sound like it is a Qt question.
-
@JonB said in shell script in qt not changing the value:
I don't know how people can understand what you write, or answer your specific desires, about which we have no idea.
I see a Rx_CF_read variable. Since I do not see it declared I have to assume it is a (persistent) member variable. I see it set during if(test=="0x0"). I see it used (at a later date?) to write during the if(test=="0x1") case. Only you know whether it has the desired value at that point.
As a separate issue, I don't know why in order to read the content of file /sys/bus/iio/devices/iio:device1/out_altvoltage0_RX_LO_frequency you issue an OS cat command and read the stdout from that, when all you should do is open the file for read and read it, why the OS cat command?
Also as a separate issue, you will (potentially at least) execute /home/analog/Documents/master/hoppingMaster.sh multiple times. Is that desired, or is it desired only once before all this reading/writing? Again only you know that.
Finally, your title is "shell script in qt not changing the value". What shell script is not changing what value? the only shell script I see is hoppingMaster.sh? And again only you can know how that behaves/what it;s supposed to do.@JonB Thanks your valuable response!
Variable Rx_CF_read is defined in header file as QString. And its value is updated as it should be.I am reading and writing in OS file directly so thats why I am accessing the file using cat command because it directly access in terminal.
I need to run the hoppingMaster.sh file once when GUI start before any reading and writing step.
See below
#!/bin/sh find_zynq_base_gpio () { for i in /sys/class/gpio/gpiochip*; do if [ "zynq_gpio" = `cat $i/label` ]; then return `echo $i | sed 's/^[^0-9]\+//'` break fi done return -1 } if [ `id -u` != "0" ] then echo "This script must be run as root" 1>&2 exit 1 fi for i in $(find -L /sys/bus/iio/devices -maxdepth 2 -name name) do dev_name=$(cat $i); if [ "$dev_name" = "ad9361-phy" ]; then phy_path=$(echo $i | sed 's:/name$::') cd $phy_path break fi done if [ "$dev_name" != "ad9361-phy" ]; then exit fi #Setup 8 Profiles 1MHz spaced ##GPS-P1 echo 2425000000 > out_altvoltage0_RX_LO_frequency echo "Initializing PROFILE $i at 2425000000 MHz" echo 0 > out_altvoltage0_RX_LO_fastlock_store ##GPS-P2 echo 2475000000 > out_altvoltage0_RX_LO_frequency echo "Initializing PROFILE $i at 2475000000 MHz" echo 1 > out_altvoltage0_RX_LO_fastlock_store ##GPS-P3 echo 2425000000 > out_altvoltage0_RX_LO_frequency echo "Initializing PROFILE $i at 2425000000 MHz" echo 2 > out_altvoltage0_RX_LO_fastlock_store ##GPS-P4 echo 2475000000 > out_altvoltage0_RX_LO_frequency echo "Initializing PROFILE $i at 2475000000 MHz" echo 3 > out_altvoltage0_RX_LO_fastlock_store ##GPS-P5 echo 2425000000 > out_altvoltage0_RX_LO_frequency echo "Initializing PROFILE $i at 2425000000 MHz" echo 4 > out_altvoltage0_RX_LO_fastlock_store ##GPS-P1 echo 2475000000 > out_altvoltage0_RX_LO_frequency echo "Initializing PROFILE $i at 2475000000 MHz" echo 5 > out_altvoltage0_RX_LO_fastlock_store ##GPS-P2 echo 2425000000 > out_altvoltage0_RX_LO_frequency echo "Initializing PROFILE $i at 2425000000 MHz" echo 6 > out_altvoltage0_RX_LO_fastlock_store ##GPS-P4 echo 2475000000 > out_altvoltage0_RX_LO_frequency echo "Initializing PROFILE $i at 2475000000 MHz" echo 7 > out_altvoltage0_RX_LO_fastlock_store #Enable Fastlock Mode echo "Entering to find the hopping IP" for i in $(find -L /sys/bus/iio/devices -maxdepth 2 -name name) do dev_name=$(cat $i) if [ "$dev_name" = "axi-hopper" ]; then phy_path=$(echo $i | sed 's:/name$::') echo "Hopping IP found" cd $phy_path break fi done if [ "$dev_name" != "axi-hopper" ]; then echo "Hopping IP not found" exit fi echo 1 > hopping_enable echo 2000 > dwell_samples
@Wasee said in shell script in qt not changing the value:
I am reading and writing in OS file directly so thats why I am accessing the file using cat command because it directly access in terminal.
There is absolutely no need to use shell and cat to read a any file! Just use QFile...
The great thing about UNIX/Linux is that a file is a file and behaves as a file, doesn't matter whether it is normal file or device file. -
@jsulm said in shell script in qt not changing the value:
There is absolutely no need to use shell and cat to read a any file! Just use QFile...
The great thing about UNIX/Linux is that a file is a file and behaves as a file, doesn't matter whether it is normal file or device file.Hi Dear;
I didn't understand Please brief more. In my case I run the bash script behind the external signal when its value equal zero and when external signal value change to 1 then only one value pass to out_altvoltage1_TX_LO_frequency and write on the devices register.Thanks
-
@jsulm said in shell script in qt not changing the value:
There is absolutely no need to use shell and cat to read a any file! Just use QFile...
The great thing about UNIX/Linux is that a file is a file and behaves as a file, doesn't matter whether it is normal file or device file.Hi Dear;
I didn't understand Please brief more. In my case I run the bash script behind the external signal when its value equal zero and when external signal value change to 1 then only one value pass to out_altvoltage1_TX_LO_frequency and write on the devices register.Thanks
@Wasee What did you not understand?
How to read/write a file in Qt using QFile?
Did you read its documentation already: https://doc.qt.io/qt-5/qfile.html
There are even examples...If your question is about writing shell scripts, then you're in the wrong forum and should at least try to be more clear as @JonB already pointed out.