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

ad7606. Channel 0 for Timestamp #602

Open
Miavu87 opened this issue Oct 1, 2024 · 10 comments
Open

ad7606. Channel 0 for Timestamp #602

Miavu87 opened this issue Oct 1, 2024 · 10 comments
Assignees

Comments

@Miavu87
Copy link

Miavu87 commented Oct 1, 2024

Hello,
I am new to a development with AD7606 and I am trying to run the example given in the repository: "pyadi-iio/examples
/ad7606.py".

The example shows an error on the line "sc = ad7606.scale_available" because it tries to read the data from channel 0.

In my device, it assigns channel 0 to the Timestamp:

        IIO context has 2 devices:
                iio:device0: ad7606-8
                        9 channels found: 
                                timestamp:  (input)
                                voltage0:  (input)
                                3 channel-specific attributes found: 
  ...

On the other hand, if I run iio_info the channel Timestamp is number 8.

      IIO context has 2 devices:
              iio:device0: ad7606-8 (buffer capable)
                      9 channels found:
                              voltage0:  (input, index: 0, format: le:S16/16>>0)
                              3 channel-specific attributes found:
                                      attr  0: raw value: 32767
      ....

I fixed everything by making a new file "ad7606.py" and changing the line:

          @property
          def scale_available(self):
              """Provides all available scale settings for the AD7606 channels"""
              return self._get_iio_attr(self.channel[0].name, "scale_available", False)

Along the line:

        @property
        def scale_available(self):
            """Provides all available scale settings for the AD7606 channels"""
            return self._get_iio_attr(self.channel[0].name, "scale_available", False)

Is this the only solution?

THANK YOU!!

@Miavu87
Copy link
Author

Miavu87 commented Oct 1, 2024

Sorry,
the solution is:
return self._get_iio_attr(self.channel[1].name, "scale_available", False)`

@tfcollins
Copy link
Collaborator

Can you generate a context file for the device and provide it here?
They can be created through use of the pytest-libiio module or with iio-emu.

@tfcollins tfcollins self-assigned this Oct 1, 2024
@Miavu87
Copy link
Author

Miavu87 commented Oct 3, 2024

Hi,
I have continued working with my device and having problems with Device Tree and Udev. At this moment, the device isn't created and therefore iio_info doesn't work for me.

As soon as I solve it I will send you what you requested.

Thank you.

@Miavu87
Copy link
Author

Miavu87 commented Oct 3, 2024

Hi,
I was able to generate the XML file (attached): context_file.xml ==> The order of the channels is as expected.

I attach a file with the context from a Python script (with import iio): context_from_python.txt ==> Timestamp is channel 0

Thanks,
Files_context.zip

@tfcollins
Copy link
Collaborator

tfcollins commented Oct 4, 2024

I don't think you used the correct tool to generate the XML file. Note that you cannot use iio-genxml from libiio itself. This is different than the tools provided by iio-emu or pytest-libiio

@Miavu87
Copy link
Author

Miavu87 commented Oct 5, 2024 via email

@tfcollins
Copy link
Collaborator

tfcollins commented Oct 15, 2024

In your file you can see the log messages:

XML generated:

<?xml ...

Context re-creation from generated XML succeeded!

Those surrounding log messages (not xml data) only come from iio-genxml. See here https://github.com/analogdevicesinc/libiio/blob/main/utils/iio_genxml.c#L99 . The issue with using iio-genxml (not gen_xml) is that it doesn't retrieve values from the context which are required for baseline emulation

@Miavu87
Copy link
Author

Miavu87 commented Oct 16, 2024

Hi,
I'm sorry but I don't know how to get the XML file from pytest-libiio or iio-emu.

Could you send me an example?

Thanks again.

@tfcollins
Copy link
Collaborator

Can you generate a context file for the device and provide it here? They can be created through use of the pytest-libiio module or with iio-emu.

I detailed this here with these tools

@Miavu87
Copy link
Author

Miavu87 commented Oct 22, 2024

Hello,
I'm sorry but I am absolutely unable to compile ios-emu. I have tried thousands of things and thousands of tests.

If you like, we'll drop the matter.

Thanks for everything.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants