Re: GPIO lines on RPi4
To complete this demonstration of running a TCP server from within the GNU Radio Companion flowchart without modifying the generated Python code, and correcting a mistake in the post below so that I can also update the Signal Source frequency, I have uploaded http://jmfriedt.org/2020-07-17-140636_2704x1050_scrot_ann.png (and removed the erroneous screenshots cited in the previous messages). Gwenhael Goavec explained to me the mistake I was doing: when calling tt=t.t() (since t is the Id of the flowchart) from the thread, I was creating a new instance of the whole flowchart, whose frequency variable did not match the one defining the frequency source signal that was being displayed. Instead of creating a new instance of the flowchart in the thread, the argument "self" must be provided when creating the thread. Then, the variables and methods from the calling class can be accessed and indeed, changing the signal source frequency does lead to a change in the displayed spectrum. JM -- JM Friedt, FEMTO-ST Time & Frequency/SENSeOR, 26 rue de l'Epitaphe, 25000 Besancon, France June 30, 2020 10:10 AM, jean-michel.fri...@femto-st.fr wrote: > Thanks to this comment, I ended up finding a solution to call a thread > running a TCP/IP server able to control the variables from the main > processing flowchart, without modifying manually the generated Python for a Qt > application. > A screenshot, which I hope is self-explanatory, illustrating this process is > at > http://jmfriedt.org/2020-06-30-083722_2704x1050_scrot.png > > However I am facing a surprising result. > I initially (see above) created a signal source, set its frequency to a > variable flo, > checked with a slider that changing flo did change the output frequency, > removed the > slider and set the signal source flo from my server. No change in the > frequency output. > > So I went back to my initial setup in which I change not only the source > signal > frequency but also the receiver hardware LO frequency of the B210, keeping > the TX LO > fixed. And surely enough both a spectrum analyzer and the coupled output from > the > B210 TX to the RX show the signal shifting. > > Screenshots at > http://jmfriedt.org/2020-06-30-095336_2704x1050_scrot.png show that the > callback function > for the source frequency or LO frequency are exactly the same and so are the > server handling > functions, while > http://jmfriedt.org/2020-06-30-095712_2704x1050_scrot.png shows that the B210 > TX frequency > only changes when tuning the hardware LO, not the signal source LO. > > Is there some signal that needs to be sent to the signal source beyond > self.analog_sig_source_x_0.set_frequency(self.flo) > to tell it to change frequency ? > > Thanks, JM > > -- > JM Friedt, FEMTO-ST Time & Frequency/SENSeOR, 26 rue de l'Epitaphe, > 25000 Besancon, France > > June 22, 2020 1:25 PM, "Marcus Müller" wrote: > >> It gets even better: >> >> We've launched a feature in 3.8.1.0 (and on master before that, as we do >> with any feature that ends up in a maintenance release) that we hope >> doesn't come back to bite us due to enabling unclean design. But, we >> must build best practices so that it doesn't go unused, either, so: >> >> Assuming you're using GNU Radio 3.8.1.0 (or later, once we release >> something), you can make use of the "Python Snippets" in GRC. >> >> Cheers, >> Marcus >> >> On 18/06/2020 23.17, Marcus D. Leech wrote: >> >>> On 06/18/2020 03:54 PM, jean-michel.fri...@femto-st.fr wrote: >> >> My approach: >> * build your grc chart from GNU Radio Companion and generate the .py file >> * edit the py file and import pygpio >> * play with the RPi4 GPIO in your python script. >> >> See attached script, with a python server included in the Python script >> to control an RF switch from a GNU Octave TCP/IP client talking to the >> Python >> TCP/IP server. >> >> I am presenting this approach to hardware control at >> http://jmfriedt.free.fr/sdra_radar.pdf >> >> JM >>> If you use "Python Module" block, you can write a lot of >>> non-GnuRadio-esque python, import anything you want, etc, etc. No editing >>> of the output python required, necessarily. >> >> -- >> JM Friedt, FEMTO-ST Time & Frequency/SENSeOR, 26 rue de l'Epitaphe, >> 25000 Besancon, France >> >> June 18, 2020 9:40 PM, "Da Fy" wrote: >>> Hi All, does anyone have an example of how to control GOIO lines on >>> the RPi4 from within a GRC >>> flowgraph. I’m guessing it’s an OOT module. >>> >>> I need to generate a signal of a few 100Hz & control GPIO lines at >>> various points though the cycle. >>> >>> Alternatively, I could generate the signal & lines with external >>> hardware & read them with >>> GnuRadio. >>> >>> Tnx, Dave
Re: GPIO lines on RPi4
Thanks to this comment, I ended up finding a solution to call a thread running a TCP/IP server able to control the variables from the main processing flowchart, without modifying manually the generated Python for a Qt application. A screenshot, which I hope is self-explanatory, illustrating this process is at http://jmfriedt.org/2020-06-30-083722_2704x1050_scrot.png However I am facing a surprising result. I initially (see above) created a signal source, set its frequency to a variable flo, checked with a slider that changing flo did change the output frequency, removed the slider and set the signal source flo from my server. No change in the frequency output. So I went back to my initial setup in which I change not only the source signal frequency but also the receiver hardware LO frequency of the B210, keeping the TX LO fixed. And surely enough both a spectrum analyzer and the coupled output from the B210 TX to the RX show the signal shifting. Screenshots at http://jmfriedt.org/2020-06-30-095336_2704x1050_scrot.png show that the callback function for the source frequency or LO frequency are exactly the same and so are the server handling functions, while http://jmfriedt.org/2020-06-30-095712_2704x1050_scrot.png shows that the B210 TX frequency only changes when tuning the hardware LO, not the signal source LO. Is there some signal that needs to be sent to the signal source beyond self.analog_sig_source_x_0.set_frequency(self.flo) to tell it to change frequency ? Thanks, JM -- JM Friedt, FEMTO-ST Time & Frequency/SENSeOR, 26 rue de l'Epitaphe, 25000 Besancon, France June 22, 2020 1:25 PM, "Marcus Müller" wrote: > It gets even better: > > We've launched a feature in 3.8.1.0 (and on master before that, as we do > with any feature that ends up in a maintenance release) that we hope > doesn't come back to bite us due to enabling unclean design. But, we > must build best practices so that it doesn't go unused, either, so: > > Assuming you're using GNU Radio 3.8.1.0 (or later, once we release > something), you can make use of the "Python Snippets" in GRC. > > Cheers, > Marcus > > On 18/06/2020 23.17, Marcus D. Leech wrote: > >> On 06/18/2020 03:54 PM, jean-michel.fri...@femto-st.fr wrote: >>> My approach: >>> * build your grc chart from GNU Radio Companion and generate the .py file >>> * edit the py file and import pygpio >>> * play with the RPi4 GPIO in your python script. >>> >>> See attached script, with a python server included in the Python script >>> to control an RF switch from a GNU Octave TCP/IP client talking to the >>> Python >>> TCP/IP server. >>> >>> I am presenting this approach to hardware control at >>> http://jmfriedt.free.fr/sdra_radar.pdf >>> >>> JM >> >> If you use "Python Module" block, you can write a lot of >> non-GnuRadio-esque python, import anything you want, etc, etc. No editing >> of the output python required, necessarily. >> >>> -- >>> JM Friedt, FEMTO-ST Time & Frequency/SENSeOR, 26 rue de l'Epitaphe, >>> 25000 Besancon, France >>> >>> June 18, 2020 9:40 PM, "Da Fy" wrote: >> >> Hi All, does anyone have an example of how to control GOIO lines on >> the RPi4 from within a GRC >> flowgraph. I’m guessing it’s an OOT module. >> >> I need to generate a signal of a few 100Hz & control GPIO lines at >> various points though the cycle. >> >> Alternatively, I could generate the signal & lines with external >> hardware & read them with >> GnuRadio. >> >> Tnx, Dave
Re: GPIO lines on RPi4
I am definitely not knowledgeable about Python so I might be missing the basics: as I want to include a TCP server for tuning the acquisition parameters, it seems to me (but I might be wrong) that the Python Module is more appropriate than the Python Snippet which seems to add a piece of code to the main() Python flowgraph function. The TCP server in the Python Module I have written must change the USRP LO frequency so in my Python Module I import t since t is my GRC flowchart name and I create tt=t.t() which allows me to change e.g. the LO frequency variable f with tt.f=tt.f+1 or change the LO frequency itself by calling tt.set_f(tt.f). This is all good in a CLI application as the one running on the RPi4, and working nicely. However for educational purposes I wanted to demonstrate the same principle with a Qt Application and in this case I get the error message QWidget: Must construct a QApplication before a QWidget which I assume is due to the definition of the class class t(gr.top_block, Qt.QWidget): requiring a Qt.QWidget when I define tt=t.t() which is not yet defined as Qt.QApplication.setGraphicsSystem(style) qapp = Qt.QApplication(sys.argv) Is there a proper way of accessing the variables and the functions of the main GRC flowchart from my Python Module, also applicable in the case of a Qt Application ? Thanks, JM -- JM Friedt, FEMTO-ST Time & Frequency/SENSeOR, 26 rue de l'Epitaphe, 25000 Besancon, France June 22, 2020 1:25 PM, "Marcus Müller" wrote: > It gets even better: > > We've launched a feature in 3.8.1.0 (and on master before that, as we do > with any feature that ends up in a maintenance release) that we hope > doesn't come back to bite us due to enabling unclean design. But, we > must build best practices so that it doesn't go unused, either, so: > > Assuming you're using GNU Radio 3.8.1.0 (or later, once we release > something), you can make use of the "Python Snippets" in GRC. > > Cheers, > Marcus > > On 18/06/2020 23.17, Marcus D. Leech wrote: > >> On 06/18/2020 03:54 PM, jean-michel.fri...@femto-st.fr wrote: >>> My approach: >>> * build your grc chart from GNU Radio Companion and generate the .py file >>> * edit the py file and import pygpio >>> * play with the RPi4 GPIO in your python script. >>> >>> See attached script, with a python server included in the Python script >>> to control an RF switch from a GNU Octave TCP/IP client talking to the >>> Python >>> TCP/IP server. >>> >>> I am presenting this approach to hardware control at >>> http://jmfriedt.free.fr/sdra_radar.pdf >>> >>> JM >> >> If you use "Python Module" block, you can write a lot of >> non-GnuRadio-esque python, import anything you want, etc, etc. No editing >> of the output python required, necessarily. >> >>> -- >>> JM Friedt, FEMTO-ST Time & Frequency/SENSeOR, 26 rue de l'Epitaphe, >>> 25000 Besancon, France >>> >>> June 18, 2020 9:40 PM, "Da Fy" wrote: >> >> Hi All, does anyone have an example of how to control GOIO lines on >> the RPi4 from within a GRC >> flowgraph. I’m guessing it’s an OOT module. >> >> I need to generate a signal of a few 100Hz & control GPIO lines at >> various points though the cycle. >> >> Alternatively, I could generate the signal & lines with external >> hardware & read them with >> GnuRadio. >> >> Tnx, Dave
Re: GPIO lines on RPi4
Seems like you already understand the limitations! Good luck with you project! --Albin On Mon, Jun 22, 2020, 14:30 jean-michel.fri...@femto-st.fr < jean-michel.fri...@femto-st.fr> wrote: > The envisioned application is event driven: send a control word from a > client, > wait for the even to complete (e.g. move antenna to target position), start > streaming data for a given amount of time, and when enough data is > collected move > to new position. Of course timing cannot be relied on with a non-real time > multitasking > operating system whose load is not predictable. > > I did use successfully Python Module to implement the server and tune the > UHD parameters > during the week end without editing the Python code (why the Python Module > must be entered > through the GRC Python editor and not externally for the updates not to be > lost is still > not yet understood). Will have a look at this new Python Snippet feature. > > Thanks, JM > > -- > JM Friedt, FEMTO-ST Time & Frequency/SENSeOR, 26 rue de l'Epitaphe, > 25000 Besancon, France > > June 22, 2020 2:05 PM, "Albin Stigö" wrote: > > > It might be difficult to control GPIO with precise timing on raspberry > pi depending on what you > > want to do... A few hundred khz might be ok though. libgpiod is the new > better Linux GPIO API. > > > > --Albin > > > > On Mon, Jun 22, 2020, 13:25 Marcus Müller wrote: > > > >> It gets even better: > >> > >> We've launched a feature in 3.8.1.0 (and on master before that, as we do > >> with any feature that ends up in a maintenance release) that we hope > >> doesn't come back to bite us due to enabling unclean design. But, we > >> must build best practices so that it doesn't go unused, either, so: > >> > >> Assuming you're using GNU Radio 3.8.1.0 (or later, once we release > >> something), you can make use of the "Python Snippets" in GRC. > >> > >> Cheers, > >> Marcus > >> > >> On 18/06/2020 23.17, Marcus D. Leech wrote: > >>> On 06/18/2020 03:54 PM, jean-michel.fri...@femto-st.fr wrote: > My approach: > * build your grc chart from GNU Radio Companion and generate the .py > file > * edit the py file and import pygpio > * play with the RPi4 GPIO in your python script. > > See attached script, with a python server included in the Python > script > to control an RF switch from a GNU Octave TCP/IP client talking to the > Python > TCP/IP server. > > I am presenting this approach to hardware control at > http://jmfriedt.free.fr/sdra_radar.pdf > > JM > >>> If you use "Python Module" block, you can write a lot of > >>> non-GnuRadio-esque python, import anything you want, etc, etc. No > editing > >>> of the output python required, necessarily. > >>> > >>> > > -- > JM Friedt, FEMTO-ST Time & Frequency/SENSeOR, 26 rue de l'Epitaphe, > 25000 Besancon, France > > June 18, 2020 9:40 PM, "Da Fy" wrote: > > > Hi All, does anyone have an example of how to control GOIO lines on > > the RPi4 from within a GRC > > flowgraph. I’m guessing it’s an OOT module. > > > > I need to generate a signal of a few 100Hz & control GPIO lines at > > various points though the cycle. > > > > Alternatively, I could generate the signal & lines with external > > hardware & read them with > > GnuRadio. > > > > Tnx, Dave > >>> > >>> >
Re: GPIO lines on RPi4
The envisioned application is event driven: send a control word from a client, wait for the even to complete (e.g. move antenna to target position), start streaming data for a given amount of time, and when enough data is collected move to new position. Of course timing cannot be relied on with a non-real time multitasking operating system whose load is not predictable. I did use successfully Python Module to implement the server and tune the UHD parameters during the week end without editing the Python code (why the Python Module must be entered through the GRC Python editor and not externally for the updates not to be lost is still not yet understood). Will have a look at this new Python Snippet feature. Thanks, JM -- JM Friedt, FEMTO-ST Time & Frequency/SENSeOR, 26 rue de l'Epitaphe, 25000 Besancon, France June 22, 2020 2:05 PM, "Albin Stigö" wrote: > It might be difficult to control GPIO with precise timing on raspberry pi > depending on what you > want to do... A few hundred khz might be ok though. libgpiod is the new > better Linux GPIO API. > > --Albin > > On Mon, Jun 22, 2020, 13:25 Marcus Müller wrote: > >> It gets even better: >> >> We've launched a feature in 3.8.1.0 (and on master before that, as we do >> with any feature that ends up in a maintenance release) that we hope >> doesn't come back to bite us due to enabling unclean design. But, we >> must build best practices so that it doesn't go unused, either, so: >> >> Assuming you're using GNU Radio 3.8.1.0 (or later, once we release >> something), you can make use of the "Python Snippets" in GRC. >> >> Cheers, >> Marcus >> >> On 18/06/2020 23.17, Marcus D. Leech wrote: >>> On 06/18/2020 03:54 PM, jean-michel.fri...@femto-st.fr wrote: My approach: * build your grc chart from GNU Radio Companion and generate the .py file * edit the py file and import pygpio * play with the RPi4 GPIO in your python script. See attached script, with a python server included in the Python script to control an RF switch from a GNU Octave TCP/IP client talking to the Python TCP/IP server. I am presenting this approach to hardware control at http://jmfriedt.free.fr/sdra_radar.pdf JM >>> If you use "Python Module" block, you can write a lot of >>> non-GnuRadio-esque python, import anything you want, etc, etc. No editing >>> of the output python required, necessarily. >>> >>> -- JM Friedt, FEMTO-ST Time & Frequency/SENSeOR, 26 rue de l'Epitaphe, 25000 Besancon, France June 18, 2020 9:40 PM, "Da Fy" wrote: > Hi All, does anyone have an example of how to control GOIO lines on > the RPi4 from within a GRC > flowgraph. I’m guessing it’s an OOT module. > > I need to generate a signal of a few 100Hz & control GPIO lines at > various points though the cycle. > > Alternatively, I could generate the signal & lines with external > hardware & read them with > GnuRadio. > > Tnx, Dave >>> >>>
Re: GPIO lines on RPi4
It might be difficult to control GPIO with precise timing on raspberry pi depending on what you want to do... A few hundred khz might be ok though. libgpiod is the new better Linux GPIO API. --Albin On Mon, Jun 22, 2020, 13:25 Marcus Müller wrote: > It gets even better: > > We've launched a feature in 3.8.1.0 (and on master before that, as we do > with any feature that ends up in a maintenance release) that we hope > doesn't come back to bite us due to enabling unclean design. But, we > must build best practices so that it doesn't go unused, either, so: > > Assuming you're using GNU Radio 3.8.1.0 (or later, once we release > something), you can make use of the "Python Snippets" in GRC. > > Cheers, > Marcus > > On 18/06/2020 23.17, Marcus D. Leech wrote: > > On 06/18/2020 03:54 PM, jean-michel.fri...@femto-st.fr wrote: > >> My approach: > >> * build your grc chart from GNU Radio Companion and generate the .py > file > >> * edit the py file and import pygpio > >> * play with the RPi4 GPIO in your python script. > >> > >> See attached script, with a python server included in the Python script > >> to control an RF switch from a GNU Octave TCP/IP client talking to the > >> Python > >> TCP/IP server. > >> > >> I am presenting this approach to hardware control at > >> http://jmfriedt.free.fr/sdra_radar.pdf > >> > >> JM > > If you use "Python Module" block, you can write a lot of > > non-GnuRadio-esque python, import anything you want, etc, etc. No > editing > >of the output python required, necessarily. > > > > > >> > >> -- > >> JM Friedt, FEMTO-ST Time & Frequency/SENSeOR, 26 rue de l'Epitaphe, > >> 25000 Besancon, France > >> > >> June 18, 2020 9:40 PM, "Da Fy" wrote: > >> > >>> Hi All, does anyone have an example of how to control GOIO lines on > >>> the RPi4 from within a GRC > >>> flowgraph. I’m guessing it’s an OOT module. > >>> > >>> I need to generate a signal of a few 100Hz & control GPIO lines at > >>> various points though the cycle. > >>> > >>> Alternatively, I could generate the signal & lines with external > >>> hardware & read them with > >>> GnuRadio. > >>> > >>> Tnx, Dave > > > > > >
Re: GPIO lines on RPi4
It gets even better: We've launched a feature in 3.8.1.0 (and on master before that, as we do with any feature that ends up in a maintenance release) that we hope doesn't come back to bite us due to enabling unclean design. But, we must build best practices so that it doesn't go unused, either, so: Assuming you're using GNU Radio 3.8.1.0 (or later, once we release something), you can make use of the "Python Snippets" in GRC. Cheers, Marcus On 18/06/2020 23.17, Marcus D. Leech wrote: On 06/18/2020 03:54 PM, jean-michel.fri...@femto-st.fr wrote: My approach: * build your grc chart from GNU Radio Companion and generate the .py file * edit the py file and import pygpio * play with the RPi4 GPIO in your python script. See attached script, with a python server included in the Python script to control an RF switch from a GNU Octave TCP/IP client talking to the Python TCP/IP server. I am presenting this approach to hardware control at http://jmfriedt.free.fr/sdra_radar.pdf JM If you use "Python Module" block, you can write a lot of non-GnuRadio-esque python, import anything you want, etc, etc. No editing of the output python required, necessarily. -- JM Friedt, FEMTO-ST Time & Frequency/SENSeOR, 26 rue de l'Epitaphe, 25000 Besancon, France June 18, 2020 9:40 PM, "Da Fy" wrote: Hi All, does anyone have an example of how to control GOIO lines on the RPi4 from within a GRC flowgraph. I’m guessing it’s an OOT module. I need to generate a signal of a few 100Hz & control GPIO lines at various points though the cycle. Alternatively, I could generate the signal & lines with external hardware & read them with GnuRadio. Tnx, Dave smime.p7s Description: S/MIME Cryptographic Signature
Re: GPIO lines on RPi4
On 06/18/2020 03:54 PM, jean-michel.fri...@femto-st.fr wrote: My approach: * build your grc chart from GNU Radio Companion and generate the .py file * edit the py file and import pygpio * play with the RPi4 GPIO in your python script. See attached script, with a python server included in the Python script to control an RF switch from a GNU Octave TCP/IP client talking to the Python TCP/IP server. I am presenting this approach to hardware control at http://jmfriedt.free.fr/sdra_radar.pdf JM If you use "Python Module" block, you can write a lot of non-GnuRadio-esque python, import anything you want, etc, etc. No editing of the output python required, necessarily. -- JM Friedt, FEMTO-ST Time & Frequency/SENSeOR, 26 rue de l'Epitaphe, 25000 Besancon, France June 18, 2020 9:40 PM, "Da Fy" wrote: Hi All, does anyone have an example of how to control GOIO lines on the RPi4 from within a GRC flowgraph. I’m guessing it’s an OOT module. I need to generate a signal of a few 100Hz & control GPIO lines at various points though the cycle. Alternatively, I could generate the signal & lines with external hardware & read them with GnuRadio. Tnx, Dave
Re: GPIO lines on RPi4
My approach: * build your grc chart from GNU Radio Companion and generate the .py file * edit the py file and import pygpio * play with the RPi4 GPIO in your python script. See attached script, with a python server included in the Python script to control an RF switch from a GNU Octave TCP/IP client talking to the Python TCP/IP server. I am presenting this approach to hardware control at http://jmfriedt.free.fr/sdra_radar.pdf JM -- JM Friedt, FEMTO-ST Time & Frequency/SENSeOR, 26 rue de l'Epitaphe, 25000 Besancon, France June 18, 2020 9:40 PM, "Da Fy" wrote: > Hi All, does anyone have an example of how to control GOIO lines on the RPi4 > from within a GRC > flowgraph. I’m guessing it’s an OOT module. > > I need to generate a signal of a few 100Hz & control GPIO lines at various > points though the cycle. > > Alternatively, I could generate the signal & lines with external hardware & > read them with > GnuRadio. > > Tnx, Dave s.py Description: Binary data
GPIO lines on RPi4
Hi All, does anyone have an example of how to control GOIO lines on the RPi4 from within a GRC flowgraph. I’m guessing it’s an OOT module. I need to generate a signal of a few 100Hz & control GPIO lines at various points though the cycle. Alternatively, I could generate the signal & lines with external hardware & read them with GnuRadio. Tnx, Dave