Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

context description with serial backend #926

Closed
buha opened this issue Jan 20, 2023 · 10 comments · Fixed by #1017
Closed

context description with serial backend #926

buha opened this issue Jan 20, 2023 · 10 comments · Fixed by #1017
Assignees

Comments

@buha
Copy link

buha commented Jan 20, 2023

  1. Given the following string in xml:
<context name="xml" version-major="0" version-minor="24" version-git="c4498c2" description="no-OS master-9271c4ee2-modified" >

When using the serial backend, I get the following context name and description from libiio:

>>> serctx.name
'serial'
>>> serctx.description
'/dev/ttyACM0: DAPLink CMSIS-DAP - 0425170267cb0dfe00000000000000000000000097969906'
  1. Given the following string in xml:
<context name="xml" version-major="0" version-minor="24" version-git="c4498c2" description="Linux (none) 5.4.0-gfd4058d9a174 #121 SMP PREEMPT Wed Apr 14 08:46:13 CEST 2021 armv7l" >

When using the usb backend, I get the folloing context name and description from libiio:

>>> usbctx.name
'usb'
>>> usbctx.description
'Linux (none) 5.4.0-gfd4058d9a174 #121 SMP PREEMPT Wed Apr 14 08:46:13 CEST 2021 armv7l'

At point 2, the description is as expected.
At point 1 however, the description contains serial port info instead of the xml description attribute.

I've traced this to this function:

libiio/serial.c

Line 113 in e9c8011

name = sp_get_port_name(port);

I think it would be better to have consistent behavior across backends and populate context description in libiio with the content from xml and not from libserialport. (Perhaps populate with info from libserialport if the description attribute is missing from xml, but this is optional).

@pcercuei
Copy link
Contributor

This should already be fixed for the next Libiio version in the dev branch.

@buha
Copy link
Author

buha commented Jan 20, 2023

oh really ? I will give it a try

@buha
Copy link
Author

buha commented Jan 20, 2023

$ cmake ../ -DWITH_SERIAL_BACKEND=ON
-- cmake version: 3.25.1
-- The C compiler identification is GNU 12.2.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Performing Test HAS_WPEDANTIC
-- Performing Test HAS_WPEDANTIC - Success
-- Performing Test HAS_WSHADOW
-- Performing Test HAS_WSHADOW - Success
-- Looking for strdup
-- Looking for strdup - found
-- Looking for strndup
-- Looking for strndup - found
-- Looking for strerror_r
-- Looking for strerror_r - found
-- Looking for strtok_r
-- Looking for strtok_r - found
-- Looking for newlocale
-- Looking for newlocale - found
-- Looking for in6addr_any
-- Looking for in6addr_any - found
-- Found PkgConfig: /usr/bin/pkg-config (found version "1.8.0") 
-- Checking for module 'libusb-1.0'
--   Found libusb-1.0, version 1.0.26
-- Looking for libusb_get_version
-- Looking for libusb_get_version - found
-- Found Git: /usr/bin/git (found version "2.39.0") 
-- Performing Test WITH_NETWORK_EVENTFD
-- Performing Test WITH_NETWORK_EVENTFD - Success
-- Performing Test Iconv_IS_BUILT_IN
-- Performing Test Iconv_IS_BUILT_IN - Success
-- Found BISON: /usr/bin/bison (found version "3.8.2") 
-- Found FLEX: /usr/bin/flex (found version "2.6.4") 
-- Looking for pthread_setname_np
-- Looking for pthread_setname_np - found
-- Looking for sys/types.h
-- Looking for sys/types.h - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for stddef.h
-- Looking for stddef.h - found
-- Check size of struct usb_functionfs_descs_head_v2
-- Check size of struct usb_functionfs_descs_head_v2 - done
CMake Warning (dev) at cmake/Install.cmake:38 (install):
  Target iio has PUBLIC_HEADER files but no PUBLIC_HEADER DESTINATION.
Call Stack (most recent call first):
  CMakeLists.txt:593 (include)
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Features enabled : xml zstd network dns-sd avahi ipv6 serial local local-dmabuf local-mmap usb utils iiod iiod-serial iiod-aio iiod-usb man-utils
-- Features disabled: hwmon examples modules usb-dynamic network-dynamic serial-dynamic iiod-systemd iiod-sysvinit iiod-upstart doc man python-bindings c#-bindings
-- Configuring done
-- Generating done
-- Build files have been written to: /home/dari/Work/libiio/build

Ok, I tried to build the dev branch and got this error.

@pcercuei
Copy link
Contributor

It's not an error, it's a warning :)

@buha
Copy link
Author

buha commented Jan 23, 2023

Oh yeah, my bad...

So it's ok now, I can build/install the dev branch. However I get Invalid argument (22) when trying to use the new libiio:

$ iio_genxml -u serial:/dev/ttyACM0,57600
ERROR: Unable to create IIO context serial:/dev/ttyACM0,57600: Invalid argument (22)

Is there anything that changed in xml parsing ? Does the dev branch expect something in the xml which was not there previously ?

Here's my xml for reference:

<?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 description CDATA #IMPLIED>
<!ATTLIST context-attribute name CDATA #REQUIRED value CDATA #REQUIRED>
<!ATTLIST device id CDATA #REQUIRED name CDATA #IMPLIED>
<!ATTLIST channel id CDATA #REQUIRED type (input|output) #REQUIRED name CDATA #IMPLIED>
<!ATTLIST scan-element index CDATA #REQUIRED format CDATA #REQUIRED scale CDATA #IMPLIED>
<!ATTLIST attribute name CDATA #REQUIRED filename CDATA #IMPLIED>
<!ATTLIST debug-attribute name CDATA #REQUIRED>
<!ATTLIST buffer-attribute name CDATA #REQUIRED>]>
<context name="xml" description="no-OS microwave-b0fd22e4a-modified" >
	<device id="iio:device0" name="hmc6300">
		<channel id="temp" type="input" >
			<attribute name="raw" filename="in_temp_raw" />
		</channel>
		<attribute name="enabled" />
		<attribute name="vco" />
		<attribute name="vco_available" />
		<attribute name="if_attn" />
		<attribute name="rf_attn" />
		<debug-attribute name="direct_reg_access" />
	</device>
	<device id="iio:device1" name="hmc6301">
		<channel id="temp" type="input" >
			<attribute name="raw" filename="in_temp_raw" />
		</channel>
		<attribute name="enabled" />
		<attribute name="vco" />
		<attribute name="vco_available" />
		<attribute name="if_attn" />
		<attribute name="bb_attn1" />
		<attribute name="bb_attn2" />
		<attribute name="bb_attni_fine" />
		<attribute name="bb_attnq_fine" />
		<debug-attribute name="direct_reg_access" />
	</device>
	<device id="iio:device2" name="mwc">
		<channel id="voltage" name="tx_det" type="input" >
			<attribute name="raw" filename="in_voltage_raw" />
		</channel>
		<channel id="voltage" name="rx_det" type="input" >
			<attribute name="raw" filename="in_voltage_raw" />
		</channel>
		<attribute name="tx_autotuning" />
		<attribute name="rx_autotuning" />
	</device>
</context>

@pcercuei
Copy link
Contributor

The XML looks fine - if you save it to a file test.xml, then run iio_genxml -u xml:test.xml it will accept it without problems.

Serial backend works mostly fine here, I do not get this "invalid argument" error.
What do you run on the other side? Is it regular IIOD with the serial code enabled, or tinyIIOD?

@buha
Copy link
Author

buha commented Jan 25, 2023

I am using TinyIIOD in no-OS. The one implemented here which is a modified version of the original TinyIIOD:
https://github.com/analogdevicesinc/no-OS/blob/master/iio/iiod.c

I tried what you suggested on dev branch, iio_genxml works when provided with test.xml input file but fails when getting the same thing from serial so I'm not quite sure what's going on.

@buha
Copy link
Author

buha commented Jan 30, 2023

So we've found out the issue was that no-OS replies with -EINVAL (-22) to the TIMEOUT IIO command.

@buha
Copy link
Author

buha commented Jan 30, 2023

Closing this as it's already implemented by @pcercuei on dev branch.

@buha buha closed this as completed Jan 30, 2023
@buha
Copy link
Author

buha commented Jul 26, 2023

@pcercuei I've just tested 0.25-rc1 for this feature and I still don't see it in there, I haven't checked the git log of libiio, do you plan on including this in 0.25?

I have this in the xml:

<context name="xml" version-major="0" version-minor="25" version-git="v0.25" description="no-OS tags/wethlink-0.1.7-d3207fb6d" >

And iio_info shows this at Backend description string:

iio_info -u serial:/dev/ttyACM0,115200,8n2n
iio_info version: 0.25 (git tag:v0.25)
Libiio version: 0.25 (git tag: v0.25) backends: local xml ip usb serial
IIO context created with serial backend.
Backend version: 1.1 (git tag: 0000000)
Backend description string: /dev/ttyACM0: DAPLink CMSIS-DAP - 0409170256d9088800000000000000000000000097969906

I was expecting no-OS tags/wethlink-0.1.7-d3207fb6d to be printed.

@buha buha reopened this Jul 26, 2023
pcercuei added a commit that referenced this issue Jul 26, 2023
Instead of overriding the context description that comes from the XML,
pass the serial port name and description as context attributes, and
keep the context description as-is.

Fixes #926.

Signed-off-by: Paul Cercueil <[email protected]>
pcercuei added a commit that referenced this issue Jul 27, 2023
Instead of overriding the context description that comes from the XML,
pass the serial port name and description as context attributes, and
keep the context description as-is.

Fixes #926.

Signed-off-by: Paul Cercueil <[email protected]>
pcercuei added a commit that referenced this issue Jul 27, 2023
Instead of overriding the context description that comes from the XML,
pass the serial port name and description as context attributes, and
keep the context description as-is.

Fixes #926.

Signed-off-by: Paul Cercueil <[email protected]>
SRaus pushed a commit that referenced this issue Sep 26, 2023
Instead of overriding the context description that comes from the XML,
pass the serial port name and description as context attributes, and
keep the context description as-is.

Fixes #926.

Signed-off-by: Paul Cercueil <[email protected]>
(cherry picked from commit b31f4c9)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants