analogdevicesinc / iio-emu

Server application for libiio clients.
Other
8 stars 6 forks source link

gnuradio / gr-iio #22

Open jamesoncollins opened 1 month ago

jamesoncollins commented 1 month ago

I seem to have no problem using iio-emu with IIO Oscope but I'm having problems with gnuradio. Typically I use gnuradio with real hardware, as well as iio_demo from the no-os library. Both of those work fine. But trying to use iio-emu I keep getting: ERROR: READ LINE: -32 ERROR: Unable to find host: Servname not supported for ai_socktype

Dpending on the exact iio-emu setup (adalm2000 or custom XML) I might instead see: ERROR: READ LINE: -32 ERROR: Unable to find host: Name or service not known

This is for a uri of 'ip:127.0.0.1'

jamesoncollins commented 1 month ago

Here is gnuradio and iio oscope right next to eachother. One connected, the other didn't. Now, IIO oscope isn't actually streaming any data here, but I assume the context was created at this point.

image

And here it is succesfully connecting to iio_demo: image

jamesoncollins commented 1 month ago

When I try in C++ I see a bit more info, maybe this matters: WARNING: Unknown parameter '0' in WARNING: Unknown parameter '23' in WARNING: Unknown parameter 'v0.23' in

After that it works fine though. Initially I was having trouble in C++ when using a custom XML, but the adalm2000 works fine it seems. Both fail to work in gnuradio though.

tfcollins commented 1 month ago

Can you provide more detail on what versions of each component you are using? Can you provide your custom context file?

jamesoncollins commented 1 month ago

iio-emu is v0.2

gnuradio is version 3.10 and is running in conda with libiio=0.25

The c++ software is running native on libiio=0.19

Chaning the conda/gnuradio libiio to 0.21 seems to have made it work.

tfcollins commented 1 month ago

I think this is related to the conda packages of libiio. It's not repeatable on source builds or pre-built packages.

Can you try running this from the command prompt "iio_attr -u ip:ip -d" inside and outside of your conda environment? To do this outside of conda you will be to install libiio from github.

If it works outside of conda, please report the issue to Ryan Volz the maintainer of the conda package.

jamesoncollins commented 1 month ago

Am I supposed to just leave it as -u ip: or do I also include the IP?

So far I have only been able to repeat the original problem with libiio 0.25 in conda. Works fine with 0.21.

tfcollins commented 1 month ago

Sorry markdown formatting removed the bracketed example. Include your ip after ip: as usual

jamesoncollins commented 1 month ago

Using iio-emu main, and libiio from conda:

libiio 0.23 and 0.25 both say: ERROR: READ LINE: -32 Unable to create IIO context ip:127.0.0.1: Broken pipe (32)

libiio 0.21 says: WARNING: Unknown parameter '0' in WARNING: Unknown parameter '23' in WARNING: Unknown parameter 'v0.23' in IIO context has 2 devices: iio:device2, cf_axi_adc: found 0 device attributes iio:device3, cf_axi_dds: found 0 device attributes

tfcollins commented 1 month ago

How about outside conda?

jamesoncollins commented 1 month ago

Outside conda is ubuntu 20.04 with libiio 0.19. Look like this, and seems to work well:

WARNING: Unknown parameter '0' in WARNING: Unknown parameter '23' in WARNING: Unknown parameter 'v0.23' in IIO context has 2 devices: iio:device2: cf_axi_adc, found 0 device attributes iio:device3: cf_axi_dds, found 0 device attributes

tfcollins commented 1 month ago

Can you please go back to Windows and check v0.25? Swapping OSs and versions doesn't really help narrow down the problem

jamesoncollins commented 1 month ago

Sorry, there were a bunch of red herrings that through this off. Plus I don't actually use that windows host, I just wanted to see IIO OScope.

I figured out the source of the issue. Its the XML file.

Specifically, for version 0.21 and earlier this is a valid line:

For version 0.23 and later, it needs to look like this:

&gt is html for > so I assume its saying that the format is signed 16-bit with no bit shifting.

So, this works in 0.25 and I think in earlier versions as well:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE context [
<!ELEMENT context (device | context-attribute)*>
<!ELEMENT context-attribute EMPTY>
<!ELEMENT device (channel | attribute | debug-attribute | buffer-attribute)*>
<!ELEMENT channel (scan-element? , attribute*)>
<!ELEMENT attribute EMPTY>
<!ELEMENT scan-element EMPTY>
<!ELEMENT debug-attribute EMPTY>
<!ELEMENT buffer-attribute EMPTY>
<!ATTLIST context name CDATA #REQUIRED>
<!ATTLIST context description CDATA #IMPLIED>
<!ATTLIST context-attribute name CDATA #REQUIRED>
<!ATTLIST context-attribute value CDATA #REQUIRED>
<!ATTLIST device id CDATA #REQUIRED>
<!ATTLIST device name CDATA #IMPLIED>
<!ATTLIST channel id CDATA #REQUIRED>
<!ATTLIST channel type (input | output) #REQUIRED>
<!ATTLIST channel name CDATA #IMPLIED>
<!ATTLIST scan-element index CDATA #REQUIRED>
<!ATTLIST scan-element format CDATA #REQUIRED>
<!ATTLIST scan-element scale CDATA #IMPLIED>
<!ATTLIST attribute name CDATA #REQUIRED>
<!ATTLIST attribute filename CDATA #IMPLIED>
<!ATTLIST attribute value CDATA #IMPLIED>
<!ATTLIST debug-attribute name CDATA #REQUIRED>
<!ATTLIST debug-attribute value CDATA #IMPLIED>
<!ATTLIST buffer-attribute name CDATA #REQUIRED>
<!ATTLIST buffer-attribute value CDATA #IMPLIED>
]>
<context name="network" description="192.168.2.1 Linux (none) 4.19.0-gbd9f616 #102 SMP PREEMPT Thu Sep 17 09:44:38 CEST 2020 armv7l">
    <context-attribute name="uri" value="ip:127.0.0.1"/>
    <context-attribute name="ip,ip-addr" value="127.0.0.1"/>
    <context-attribute name="local,kernel" value="4.19.0-gbd9f616"/>
    <device id="iio:device2" name="cf_axi_adc" >
        <channel id="voltage0" type="input" >
            <scan-element index="0" format="le:S16/16&gt;&gt;0" />
        </channel>
    </device>
    <device id="iio:device3" name="cf_axi_dds" >
        <channel id="voltage0" type="output" >
            <scan-element index="0" format="le:S16/16&gt;&gt;0" />
        </channel>
    </device>
</context>

This doesn't work in 0.25 but does work in earlier versions:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE context [
<!ELEMENT context (device | context-attribute)*>
<!ELEMENT context-attribute EMPTY>
<!ELEMENT device (channel | attribute | debug-attribute | buffer-attribute)*>
<!ELEMENT channel (scan-element? , attribute*)>
<!ELEMENT attribute EMPTY>
<!ELEMENT scan-element EMPTY>
<!ELEMENT debug-attribute EMPTY>
<!ELEMENT buffer-attribute EMPTY>
<!ATTLIST context name CDATA #REQUIRED>
<!ATTLIST context description CDATA #IMPLIED>
<!ATTLIST context-attribute name CDATA #REQUIRED>
<!ATTLIST context-attribute value CDATA #REQUIRED>
<!ATTLIST device id CDATA #REQUIRED>
<!ATTLIST device name CDATA #IMPLIED>
<!ATTLIST channel id CDATA #REQUIRED>
<!ATTLIST channel type (input | output) #REQUIRED>
<!ATTLIST channel name CDATA #IMPLIED>
<!ATTLIST scan-element index CDATA #REQUIRED>
<!ATTLIST scan-element format CDATA #REQUIRED>
<!ATTLIST scan-element scale CDATA #IMPLIED>
<!ATTLIST attribute name CDATA #REQUIRED>
<!ATTLIST attribute filename CDATA #IMPLIED>
<!ATTLIST attribute value CDATA #IMPLIED>
<!ATTLIST debug-attribute name CDATA #REQUIRED>
<!ATTLIST debug-attribute value CDATA #IMPLIED>
<!ATTLIST buffer-attribute name CDATA #REQUIRED>
<!ATTLIST buffer-attribute value CDATA #IMPLIED>
]>
<context name="network" description="192.168.2.1 Linux (none) 4.19.0-gbd9f616 #102 SMP PREEMPT Thu Sep 17 09:44:38 CEST 2020 armv7l">
    <context-attribute name="uri" value="ip:127.0.0.1"/>
    <context-attribute name="ip,ip-addr" value="127.0.0.1"/>
    <context-attribute name="local,kernel" value="4.19.0-gbd9f616"/>
    <device id="iio:device2" name="cf_axi_adc" >
        <channel id="voltage0" type="input" >
            <scan-element index="0" format="le:S16/16" />
        </channel>
    </device>
    <device id="iio:device3" name="cf_axi_dds" >
        <channel id="voltage0" type="output" >
            <scan-element index="0" format="le:S16/16" />
        </channel>
    </device>
</context>
tfcollins commented 1 month ago

Kk thanks for letting us know. Closing