Code Monkey home page Code Monkey logo

analogdevicesinc / libiio Goto Github PK

View Code? Open in Web Editor NEW
484.0 56.0 312.0 19.92 MB

A cross platform library for interfacing with local and remote Linux IIO devices

Home Page: http://analogdevicesinc.github.io/libiio/

License: GNU Lesser General Public License v2.1

CMake 5.85% C# 6.94% Python 8.36% C 71.41% Lex 0.26% Yacc 1.11% Shell 2.99% PowerShell 0.40% C++ 2.67%
iio linux analog digital dac adc analog-devices iio-devices industrial-linux libiio

libiio's Introduction

⚠️ Important note (2023-08-22)

Since August 22th 2023, the "main" branch of libiio contains what will eventually become libiio v1.0. It features a brand new API, which is incompatible with libiio v0.25 and older. Have a look at the wiki for a description of the API changes.

The old v0.x API can still be found in the libiio-v0 branch. Libiio v0.x is now considered legacy, and as such, only important bug fixes will be accepted into this branch.

Old programs compiled against libiio v0.x will still be able to run with libiio v1.0 and newer, as it provides a compatibility layer.

libiio

Library for interfacing with Linux IIO devices

libiio is used to interface to the Linux Industrial Input/Output (IIO) Subsystem. The Linux IIO subsystem is intended to provide support for devices that in some sense are analog to digital or digital to analog converters (ADCs, DACs). This includes, but is not limited to ADCs, Accelerometers, Gyros, IMUs, Capacitance to Digital Converters (CDCs), Pressure Sensors, Color, Light and Proximity Sensors, Temperature Sensors, Magnetometers, DACs, DDS (Direct Digital Synthesis), PLLs (Phase Locked Loops), Variable/Programmable Gain Amplifiers (VGA, PGA), and RF transceivers. You can use libiio natively on an embedded Linux target (local mode), or use libiio to communicate remotely to that same target from a host Linux, Windows or MAC over USB or Ethernet or Serial.

Although libiio was primarily developed by Analog Devices Inc., it is an active open source library, which many people have contributed to. The library is released under the GNU Lesser General Public License (LGPL), version 2.1 or (at your option) any later version, this open-source license allows anyone to use the library, on any vendors processor/FPGA/SoC, which may be controlling any vendors peripheral device (ADC, DAC, etc) either locally or remotely. This includes closed or open-source, commercial or non-commercial applications (subject to the LGPL license freedoms, obligations and restrictions). The examples and test applications (sometimes referred to as the iio-utils) are released separately under the GNU General Public License (GPL) version 2.0 (at your option) any later version.

Library License : Library License Tests/Examples License : Application License Latest Release : GitHub release Downloads : Github All Releases

Scans : Coverity Scan Build Status Release docs: Documentation Issues : open bugs closed bugs

Support:
If you have a question about libiio and an Analog Devices IIO kernel driver please ask on : EngineerZone. If you have a question about a non-ADI devices, please ask it on github.

As with many open source packages, we use GitHub to do develop and maintain the source, and Azure Pipelines for continuous integration.

  • If you want to just use libiio, we suggest using the latest release.
  • If you think you have found a bug in the release, or need a feature which isn't in the release, try the latest untested binaries from the main branch and check out the documentation based on the main branch. We provide builds for a few operating systems. If you need something else, we can most likely add that -- just ask.
Operating System GitHub main status Version Primary Installer Package Alternative Package, tarball or zip
Windows Build Status Windows-64 Server 2019 Latest Windows installer
Build Status
Latest Windows zip
Build Status Windows-64 Server 2022 (libiio-setup.exe works for both Windows Server 2019 and Windows Server 2022) Latest Windows zip
OS X Build Status macOS Ventura
(v 13 x64)
OS-X package 13-x64 OS-X tarball 13-x64
Build Status macOS Ventura
(v 13 arm64)
OS-X package 13-arm64 OS-X tarball 13-arm64
Build Status macOS Monterey
(v 12)
OS-X package 12 OS-X tarball 12
Unsupported. Last artifacts from May 31, 2024 macOS Big Sur
(v 11)
OS-X package 11 OS-X tarball 11
Unsupported. Last artifacts from Sept 6, 2022 macOS Catalina
(v 10.15)
OS-X package 10.15 OS-X tarball 10.15
Linux Build Status Ubuntu Jammy Jellyfish
(v 22.04)1
Debian Linux tarball
Build Status Ubuntu Focal Fossa
(v 20.04)1
Debian Linux tarball
Unsupported. Last artifact from May 31, 2024 Ubuntu Bionic Beaver
(v 18.04)1
Debian Linux tarball
Build Status Fedora 34 RPM File Linux tarball
Build Status Fedora 28 RPM File Linux tarball
Build Status CentOS 7 RPM File Linux tarball
Build Status Debian Bullseye Debian Linux tarball
Build Status Debian Bookworm Debian Linux tarball
Build Status openSUSE 15.4 Debian Linux tarball
ARM Build Status Ubuntu-ppc64le Debian Linux tarball
Build Status Ubuntu-x390x Debian Linux tarball
Build Status Ubuntu-arm64v8 Debian Linux tarball
Build Status Ubuntu-arm32v7 Debian Linux tarball
Build Status Debian Bookworm-arm Debian Linux tarball
MinGW Build Status Windows-MinGW-W64 Latest Windows zip

If you use it, and like it - please let us know. If you use it, and hate it - please let us know that too. The goal of the project is to try to make Linux IIO devices easier to use on a variety of platforms. If we aren't doing that - we will try to make it better.

Feedback is appreciated (in order of preference):

Weblinks:

  1. The Ubuntu packages are known to work on their Debian counterpart releases.

libiio's People

Contributors

aandrisa avatar abrauchli avatar adisuciu avatar alexandratrifan avatar bia1708 avatar catkira avatar ccraluca avatar commodo avatar cristi-iacob avatar cristina-suteu avatar dnechita avatar ekigwana avatar fpagliughi avatar geertu avatar gizero avatar julienmalik avatar larsclausen avatar lucasrangit avatar maitbot avatar matejk avatar mhei avatar mhennerich avatar nunojsa avatar pcercuei avatar rgetz avatar sraus avatar srikanthpagadarai avatar sternmull avatar tfcollins avatar tsed avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

libiio's Issues

libiio needs to install some udev rules

analog@imhotep:~/github/libiio/build$ iio_info -s
Library version: 0.8 (git tag: 6a2c22a)
No contexts found.

analog@imhotep:~/github/libiio/build$ sudo iio_info -s
Library version: 0.8 (git tag: 6a2c22a)
Available contexts:
0: 0456:b673 (Analog Devices Inc. PlutoSDR (ADALM-PLUTO)) [usb:3.8.5]

USB IIO devices should be open read/write to normal users.

iio_create_buffer() failure in network mode

(Reposting from #31)

Hello, I’m trying to use an mma8453 accelerometer in buffer mode, here is a minimal testcase to reproduce this issue: https://people.collabora.com/~emmanuel/libiio/testcase.c

Both iiod and the testcase are running on Linux, on two different devices. iio_create_buffer() fails with EPERM when the testcase is ran as-is, or with EINVAL if I comment out the channels retrieval/enabling (which is normal). This setup works fine when I’m using the iio_channel_attr_read*() family of functions, but then I can’t integrate it properly in an event loop. With the testcase ran as-is, iiod displays two different incoming connections; if I don’t create the buffer it only displays one.

Thanks for your help. :)

runtime error on ubuntu 15

Same device works on Windows and other Linux installs

picozed@picozed:~$ iio_info -n 192.168.2.1
Library version: 0.8 (git tag: 9838779)
Compiled with backends: local xml network usb
IIO context created with network backend.
Backend version: 0.8 (git tag: v0.8 )
Backend description string: 192.168.2.1 Linux pluto 4.6.0-g1470706-dirty #66 SMP PREEMPT Fri Dec 23 12:40:07 CET 2016 armv7l
IIO context has 1 attributes:
local,kernel: 4.6.0-g1470706-dirty
IIO context has 5 devices:
iio:device0: adm1177
... works ....

picozed@picozed:~$ lsusb
Bus 001 Device 002: ID 1bcf:288a Sunplus Innovation Technology Inc.
Bus 001 Device 006: ID 0456:b673 Analog Devices, Inc.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

device is there

[ 2083.447606] usb 1-1: new high-speed USB device number 6 using ehci-pci
[ 2083.582909] usb 1-1: New USB device found, idVendor=0456, idProduct=b673
[ 2083.582935] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 2083.582952] usb 1-1: Product: PlutoSDR (ADALM-PLUTO)
[ 2083.582967] usb 1-1: Manufacturer: Analog Devices Inc.
[ 2083.582982] usb 1-1: SerialNumber: 100000235523730700230029090216ea7c
[ 2083.590405] rndis_host 1-1:1.0 eth0: register 'rndis_host' at usb-0000:00:1d.7-1, RNDIS device, 00:e0:22:b6:0f:8b
[ 2083.591828] usb-storage 1-1:1.2: USB Mass Storage device detected
[ 2083.592234] scsi host7: usb-storage 1-1:1.2
[ 2083.593623] cdc_acm 1-1:1.3: ttyACM0: USB ACM device
[ 2083.668834] rndis_host 1-1:1.0 enx00e022b60f8b: renamed from eth0
[ 2083.729681] IPv6: ADDRCONF(NETDEV_UP): enx00e022b60f8b: link is not ready
[ 2084.593228] scsi 7:0:0:0: Direct-Access Linux File-Stor Gadget 0406 PQ: 0 ANSI: 2
[ 2084.594848] sd 7:0:0:0: Attached scsi generic sg1 type 0
[ 2084.596870] sd 7:0:0:0: [sdb] 32769 512-byte logical blocks: (16.7 MB/16.0 MiB)
[ 2084.597986] sd 7:0:0:0: [sdb] Write Protect is off
[ 2084.598009] sd 7:0:0:0: [sdb] Mode Sense: 0f 00 00 00
[ 2084.598847] sd 7:0:0:0: [sdb] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
[ 2084.612208] sdb: sdb1
[ 2084.615682] sd 7:0:0:0: [sdb] Attached SCSI removable disk

Looks like everything is working ok.

picozed@picozed:~$ iio_info -s
Library version: 0.8 (git tag: 9838779)
Compiled with backends: local xml network usb
No contexts found.

but no devices found.

picozed@picozed:~$ dpkg -l libusb*
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-========================-=================-=================-======================================================
ii libusb-0.1-4:i386 2:0.1.12-27 i386 userspace USB programming library
ii libusb-1.0-0:i386 2:1.0.19-1 i386 userspace USB programming library
ii libusb-1.0-0-dev:i386 2:1.0.19-1 i386 userspace USB programming library development files

Python bindings: memory leak due to circular references

The garbage collector is unable to determine what order to free a Context and its child objects in due to the circular reference between Context and Device, and Context's del method. I've found that wrapping all parent-references in weakref.ref() solves this problem for me. The attached patch is against version 0.5 and shows my changes to make this work better.
0000-weakref.patch.txt

iio_device_create_buffer always fails

I'm trying to read from ADIS16209 using libiio, but when I create a buffer with iio_device_create_buffer I'm always getting a nullptr. I've reviewed my code and the documentation, but can't find any explanation why this is happening.

I've been reading libiio documentation and http://wiki.analog.com/resources/tools-software/linux-software/libiio_internals, but didn't find any guideline on the recommended buffer size. Perhaps anyone can explain me what criteria should be used to set the buffer size.

Thank you for this project.

  • Source code:
int main()
{
    //...
    struct iio_context* ctx;
    ctx = iio_create_local_context();

    if (!ctx) return 1;

    read_device(ctx, "adis16209");

    iio_context_destroy(ctx);
    return exit_code;
}
void read_device(iio_context* ctx, string dev_name)
{
    iio_device* dev = get_device(ctx, dev_name);
    if(nullptr == dev)
    {
        exit_code = EXIT_FAILURE;
        return;
    }
    cout << "device : " << dev_name << endl;

    // Enable all channels
    unsigned int num_channels = iio_device_get_channels_count(dev);
    for (unsigned int i = 0; i < num_channels; i++)
    {
        iio_channel* chn = iio_device_get_channel(dev, i);
        iio_channel_enable(chn);

        string chn_name;
        {
            const char *name = iio_channel_get_name(chn);
            if (name!=NULL)
                chn_name = name;
            else
                chn_name = iio_channel_get_id(chn);
        }
        bool is_output = iio_channel_is_output(chn);
        cout << " enabled ch" << i << " : " << chn_name << (is_output ? "(output)":"(input)") << endl;
    }

    size_t samples_count=1024*num_channels;

    iio_buffer *buffer;
    buffer = iio_device_create_buffer(dev, samples_count, false);

   if (!buffer)
    {
        cout << "Unable to allocate buffer"<<endl;
        exit_code = EXIT_FAILURE;
        return;
    }

    while (app_running)
    {
        int ret = iio_buffer_refill(buffer);
        if (ret < 0) {
            cout << "Unable to refill buffer" << endl;
            exit_code = EXIT_FAILURE;
            break;
        }

        iio_buffer_foreach_sample(buffer, print_sample, NULL);
        fflush(stdout);
    }

    iio_buffer_destroy(buffer);
    return;
}
  • application output:

device : adis16209
enabled ch0 : supply(input)
enabled ch1 : accel_x(input)
enabled ch2 : accel_y(input)
enabled ch3 : voltage1(input)
enabled ch4 : temp0(input)
enabled ch5 : incli_x(input)
enabled ch6 : incli_y(input)
enabled ch7 : rot_x(input)
enabled ch8 : timestamp(input)
Unable to allocate buffer

  • iio_info output:

$ iio_info
Library version: 0.5 (git tag: 6399de7)
IIO context created with local backend.
Backend version: 0.5 (git tag: 6399de7)
Backend description string: Linux beaglebone 3.14.35-ti-r55 #1 SMP PREEMPT Fri Mar 27 01:37:50 WET 2015 armv7l
IIO context has 2 devices:
iio_sysfs_trigger:
0 channels found:
2 device-specific attributes found:
ERROR: Unable to read attribute: add_trigger
ERROR: Unable to read attribute: remove_trigger
iio:device0: adis16209
9 channels found:
voltage0: supply (input)
5 channel-specific attributes found:
attr 0: scale value: 0.305180
attr 1: raw value: 0
attr 2: en value: 0
attr 3: index value: 0
attr 4: type value: be:u14/16>>0
accel_x: (input)
5 channel-specific attributes found:
attr 0: calibbias value: 0
attr 1: raw value: 0
attr 2: index value: 1
attr 3: type value: be:s14/16>>0
attr 4: en value: 0
accel_y: (input)
5 channel-specific attributes found:
attr 0: raw value: 0
attr 1: calibbias value: 0
attr 2: type value: be:s14/16>>0
attr 3: index value: 2
attr 4: en value: 0
voltage1: (input)
5 channel-specific attributes found:
attr 0: raw value: 0
attr 1: scale value: 0.610500
attr 2: en value: 0
attr 3: index value: 3
attr 4: type value: be:u12/16>>0
temp0: (input)
6 channel-specific attributes found:
attr 0: offset value: -1331
attr 1: scale value: -470.000000
attr 2: raw value: 0
attr 3: index value: 4
attr 4: en value: 0
attr 5: type value: be:u12/16>>0
incli_x: (input)
4 channel-specific attributes found:
attr 0: raw value: 0
attr 1: index value: 5
attr 2: type value: be:s14/16>>0
attr 3: en value: 0
incli_y: (input)
4 channel-specific attributes found:
attr 0: raw value: 0
attr 1: type value: be:s14/16>>0
attr 2: en value: 0
attr 3: index value: 6
rot_x: (input)
4 channel-specific attributes found:
attr 0: raw value: 0
attr 1: type value: be:s14/16>>0
attr 2: index value: 7
attr 3: en value: 0
timestamp: (input)
3 channel-specific attributes found:
attr 0: type value: le:s64/64>>0
attr 1: index value: 8
attr 2: en value: 0
3 device-specific attributes found:
attr 0: in_accel_scale value: 0.002394195
attr 1: in_incli_scale value: 0.025000
attr 2: in_rot_scale value: 0.025000

Function read_all (local.c) return -5 when data is available

In a acquisition system with 36 bytes by sample, a buffer is created [iio_device_create_buffer(dev, 1000, false)], and trying to fetch 2 samples, the function iio_buffer_refill return -5.

After debugging, the function read_all (at local.c) return -5 in the last condition because the function read the samples partially (not all bytes defined in "len").

static ssize_t read_all(void *dst, size_t len, int fd)
{
uintptr_t ptr = (uintptr_t) dst;
ssize_t readsize;
int ret;
while (len > 0) {
    do {
        ret = read(fd, (void *) ptr, len);
    } while (ret == -1 && errno == EINTR);

    if (ret == -1) {
        ret = -errno;
        break;
    } else if (ret == 0) {
        ret = -EIO;
        break;
    }

    ptr += ret;
    len -= ret;
}
readsize = (ssize_t)(ptr - (uintptr_t) dst);
if ((ret > 0 || ret == -EAGAIN) && (readsize > 0)) 
    return readsize;
else 
    return ret;
}

If the samples count (in my case 2) are not in the driver buffer, the library discard any sample acquired and return -5.

I suggest to two changes:

  • Not change "ret" to "-EIO" when read return 0
  • Compare "ret" with ">=" in last condition

Below the suggestion in the code:

static ssize_t read_all(void *dst, size_t len, int fd)
{
uintptr_t ptr = (uintptr_t) dst;
ssize_t readsize;
int ret;
while (len > 0) {
    do {
        ret = read(fd, (void *) ptr, len);
    } while (ret == -1 && errno == EINTR);
    if (ret == -1) {
        ret = -errno;
        break;
    } else if (ret == 0) {
        // >>>> ret = -EIO;  <<<<
        break;
    }
    ptr += ret;
    len -= ret;
}
readsize = (ssize_t)(ptr - (uintptr_t) dst);
// >>>> if ((ret > 0 || ret == -EAGAIN) && (readsize > 0)) <<<<
if ((ret >= 0 || ret == -EAGAIN) && (readsize > 0)) 
    return readsize;
else
    return ret;
}

unable to create IIO buffer

Hi,
I try to connect the matlab windows with linux using the library libiio, I use in my project a zedboard execute Linux connected to AD9361.

At the beginning he show that he "cannot connect to iiod" but when I execute the iiod manually (by writing iiod in the terminal), the connection with iiod establishes. Consequently when he started to upload data, it appears in the terminal:

  • new Client connected from 10.1.25.142
  • new Client connected from 10.1.25.142
  • WARNING: Hight-speed mode not enabled
  • ERROR: Unalbe to create buffer
  • Client exited

and the matlab crashes in function :
obj.iio_buffer = calllib(obj.libname, 'iio_device_create_buffer', obj.iio_dev,...
obj.data_ch_size, 1);
What Could Be the Reason That ERROR?

Thanks for your help in advance!
Sorry for my englsih

Current CMake doesn't build tarball on os-x

On an OS-X machine:

cd build; rm -rf *; cmake ..; make ; make package; ls -lG ; tar tf libiio-0.8.gc59cba6-Darwin.tar.gz

gives me something like:
-rw-r--r-- 1 analogdevices staff 29 Jan 12 14:03 libiio-0.8.gc59cba6-Darwin.tar.gz

which is an empty tar file. :(

making this change:
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -29,7 +29,7 @@ set(BUILD_SHARED_LIBS ON CACHE BOOL "Build shared libraries")

if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(CMAKE_MACOSX_RPATH ON)

  •   set(SKIP_INSTALL_ALL ON)
    

+# set(SKIP_INSTALL_ALL ON)
endif()

and doing it again, makes a tar file with everything in it. (but I'm sure this breaks "make install", but that might not matter since we now have a pkg).

-rw-r--r-- 1 analogdevices staff 58314 Jan 12 14:06 libiio-0.8.gc59cba6-Darwin.tar.gz
bin/
bin/iio_adi_xflow_check
bin/iio_genxml
bin/iio_info
bin/iio_readdev
bin/iio_reg
lib/
lib/iio.framework/
lib/iio.framework/Headers
lib/iio.framework/iio
lib/iio.framework/Resources
lib/iio.framework/Versions/
lib/iio.framework/Versions/0.8/
lib/iio.framework/Versions/0.8/Headers/
lib/iio.framework/Versions/0.8/Headers/iio.h
lib/iio.framework/Versions/0.8/iio
lib/iio.framework/Versions/0.8/Resources/
lib/iio.framework/Versions/0.8/Resources/Info.plist
lib/iio.framework/Versions/Current
lib/pkgconfig/
lib/pkgconfig/libiio.pc

osx shared library doesn't include the correct (osx) extension

My understanding is that osx shared libraries should have a ".dylib" sufix

Looks like we are building the right file:

adi-mm:build analogdevices$ otool -hv ./iio.framework/iio
Mach header
magic cputype cpusubtype caps filetype ncmds sizeofcmds flags
MH_MAGIC_64 X86_64 ALL 0x00 DYLIB 15 1496 NOUNDEFS DYLDLINK TWOLEVEL NO_REEXPORTED_DYLIBS

(at least it has the same filetype as the other libs):
adi-mm:build analogdevices$ otool -hv /usr/lib/libm.dylib
Mach header
magic cputype cpusubtype caps filetype ncmds sizeofcmds flags
MH_MAGIC_64 X86_64 ALL 0x00 DYLIB 48 3656 NOUNDEFS DYLDLINK TWOLEVEL APP_EXTENSION_SAFE

but it should be "libiio.dylib" or something similar - shouldn't it?

Thanks

examples don't build

analog@imhotep:~/github/libiio$ git show .
commit bb70e40

analog@imhotep:~/github/libiio$ cd tests/
CMakeOutput.log.txt

analog@imhotep:/github/libiio/tests$ mkdir build
analog@imhotep:
/github/libiio/tests$ cd build/
analog@imhotep:~/github/libiio/tests/build$ cmake ..
-- The C compiler identification is GNU 6.2.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
CMake Error at CMakeLists.txt:39 (install):
install TARGETS given no RUNTIME DESTINATION for executable target
"iio_genxml".

-- Configuring incomplete, errors occurred!
See also "/home/analog/github/libiio/tests/build/CMakeFiles/CMakeOutput.log".
(attached)

When building on Ubuntu precise, build errors

Ubuntu 12.04 (precise), includes 2:1.0.9 of libusb-1.0-0
http://packages.ubuntu.com/precise/libusb-1.0-0-dev

Debian 7 (wheezy) includes 2:1.0.11-1 of libusb-1.0-0 (and will have the same issue)
https://packages.debian.org/wheezy/libusb-1.0-0

This does not include the ''libusb_set_auto_detach_kernel_driver'', which was added in
https://github.com/libusb/libusb/blob/4eca418ef50dcaf3f2fca11158410acd72e8e2e2/ChangeLog
2013-07-11: v1.0.16

To get things to compile without errors requires:
74d80a4

To get things to actually work, (I think) will require a little more - most likely something the reverse of this:
https://sourceforge.net/p/libusbx/mailman/message/31055437/

If we want to support 3 year old verions of libusb - is something to be discussed.
Ubuntu precise EOLs April 2017 (which would seem to be fine)
https://wiki.ubuntu.com/Releases
Debian 7 EOLs May 2018 (LTS) (is little further out to abandon).
https://wiki.debian.org/DebianReleases

-Robin

iiod: dropping buffer refills

I have a iio ADC driver using DMA to transfers.
When the userspace iio software is running on our embedded system using the local interface everything looks good. However using the network interface via iiod results in missing buffers, we are losing about a third of all data. Data is being read using iio_buffer_refill.

I'm digging into it to see if I can find the problem, but I've added some debug stated to iiod and can see iiod refilling at roughly the correct rate. But it is not issuing an writefd_io op for every refill. Sample rate is 24000sps with 4bytes per sample with a single channel.

Below is a log with some the additional messages inserted and timestamps added.

If anyone has any pointers on where to look that'd help.

Thanks
Phil

1480414079.731135920 DEBUG: Mask[0] = 0x00000001
1480414079.731309450 DEBUG: writefd_io: 2
1480414079.733963770 DEBUG: Waiting for completion...
1480414081.280262490 DEBUG: iio_buffer_refill: 40000
1480414081.280377950 DEBUG: writefd_io: 6
1480414081.280414930 DEBUG: writefd_io: 9
1480414081.280777680 DEBUG: writefd_io: 27731
1480414081.292457200 DEBUG: writefd_io: 12269
1480414081.296015000 DEBUG: Exiting rw_buffer with code 0
1480414081.301273900 DEBUG: Waiting for completion...
1480414081.974149370 DEBUG: iio_buffer_refill: 40000
1480414081.974287560 DEBUG: writefd_io: 6
1480414081.974333820 DEBUG: writefd_io: 9
1480414081.974646960 DEBUG: writefd_io: 36491
1480414081.976232780 DEBUG: writefd_io: 3509
1480414081.976325270 DEBUG: Exiting rw_buffer with code 0
1480414081.976500800 DEBUG: iio_buffer_refill: 40000
1480414081.982892750 DEBUG: Waiting for completion...
1480414082.656784750 DEBUG: iio_buffer_refill: 40000
1480414082.656931800 DEBUG: writefd_io: 6
1480414082.656974310 DEBUG: writefd_io: 9
1480414082.657551100 DEBUG: writefd_io: 39411
1480414082.658288270 DEBUG: writefd_io: 589
1480414082.658591230 DEBUG: Exiting rw_buffer with code 0
1480414082.669794630 DEBUG: Waiting for completion...
1480414083.339325110 DEBUG: iio_buffer_refill: 40000
1480414083.339503590 DEBUG: writefd_io: 6
1480414083.339584880 DEBUG: writefd_io: 9
1480414083.340001230 DEBUG: writefd_io: 40000
1480414083.340255160 DEBUG: Exiting rw_buffer with code 0
1480414083.340311110 DEBUG: iio_buffer_refill: 40000
1480414083.346527180 DEBUG: Waiting for completion...
1480414084.021636260 DEBUG: iio_buffer_refill: 40000
1480414084.021750630 DEBUG: writefd_io: 6
1480414084.021787380 DEBUG: writefd_io: 9
1480414084.022201650 DEBUG: writefd_io: 40000
1480414084.022271250 DEBUG: Exiting rw_buffer with code 0
1480414084.022478610 DEBUG: iio_buffer_refill: 40000
1480414084.028074920 DEBUG: Waiting for completion...
1480414084.704703950 DEBUG: iio_buffer_refill: 40000
1480414084.704878260 DEBUG: writefd_io: 6
1480414084.704958600 DEBUG: writefd_io: 9
1480414084.705379680 DEBUG: writefd_io: 40000
1480414084.707134320 DEBUG: Exiting rw_buffer with code 0
1480414084.716438780 DEBUG: Waiting for completion...
1480414085.387262830 DEBUG: iio_buffer_refill: 40000
1480414085.387453850 DEBUG: writefd_io: 6
1480414085.387531730 DEBUG: writefd_io: 9
1480414085.388030340 DEBUG: writefd_io: 40000
1480414085.388278010 DEBUG: Exiting rw_buffer with code 0
1480414085.388335590 DEBUG: iio_buffer_refill: 40000
1480414085.395464210 DEBUG: Waiting for completion...
1480414086.069969010 DEBUG: iio_buffer_refill: 40000
1480414086.070155530 DEBUG: writefd_io: 6
1480414086.070244510 DEBUG: writefd_io: 9
1480414086.070677660 DEBUG: writefd_io: 40000
1480414086.070921860 DEBUG: Exiting rw_buffer with code 0
1480414086.071049370 DEBUG: iio_buffer_refill: 40000
1480414086.076090770 DEBUG: Waiting for completion...
1480414086.752683200 DEBUG: iio_buffer_refill: 40000
1480414086.752862950 DEBUG: writefd_io: 6
1480414086.752945150 DEBUG: writefd_io: 9
1480414086.753366680 DEBUG: writefd_io: 40000
1480414086.756252300 DEBUG: Exiting rw_buffer with code 0
1480414086.762326660 DEBUG: Waiting for completion...
1480414087.435226630 DEBUG: iio_buffer_refill: 40000
1480414087.435639540 DEBUG: writefd_io: 6
1480414087.435868710 DEBUG: writefd_io: 9
1480414087.436669110 DEBUG: writefd_io: 40000
1480414087.436972790 DEBUG: Exiting rw_buffer with code 0
1480414087.437151730 DEBUG: iio_buffer_refill: 40000
1480414087.442761350 DEBUG: Waiting for completion...
1480414088.117940800 DEBUG: iio_buffer_refill: 40000
1480414088.118122780 DEBUG: writefd_io: 6
1480414088.118203270 DEBUG: writefd_io: 9
1480414088.118643220 DEBUG: writefd_io: 40000
1480414088.118882800 DEBUG: Exiting rw_buffer with code 0
1480414088.118941380 DEBUG: iio_buffer_refill: 40000
1480414088.124553950 DEBUG: Waiting for completion...
1480414088.800740630 DEBUG: iio_buffer_refill: 40000
1480414088.800970840 DEBUG: writefd_io: 6
1480414088.801094010 DEBUG: writefd_io: 9
1480414088.801529020 DEBUG: writefd_io: 40000
1480414088.805805330 DEBUG: Exiting rw_buffer with code 0
1480414088.810474850 DEBUG: Waiting for completion...
1480414089.483238100 DEBUG: iio_buffer_refill: 40000
1480414089.483438790 DEBUG: writefd_io: 6
1480414089.483543730 DEBUG: writefd_io: 9
1480414089.483993380 DEBUG: writefd_io: 40000
1480414089.484236310 DEBUG: Exiting rw_buffer with code 0
1480414089.484323410 DEBUG: iio_buffer_refill: 40000
1480414089.490034700 DEBUG: Waiting for completion...
1480414090.166036690 DEBUG: iio_buffer_refill: 40000
1480414090.166215320 DEBUG: writefd_io: 6
1480414090.166322240 DEBUG: writefd_io: 9
1480414090.166762880 DEBUG: writefd_io: 40000
1480414090.166995030 DEBUG: Exiting rw_buffer with code 0
1480414090.178874890 DEBUG: Waiting for completion...
1480414090.848494810 DEBUG: iio_buffer_refill: 40000
1480414090.848668660 DEBUG: writefd_io: 6
1480414090.848747230 DEBUG: writefd_io: 9
1480414090.849154420 DEBUG: writefd_io: 40000
1480414090.849444490 DEBUG: iio_buffer_refill: 40000
1480414090.849552740 DEBUG: Exiting rw_buffer with code 0
1480414090.855519360 DEBUG: Waiting for completion...
1480414091.531277040 DEBUG: iio_buffer_refill: 40000
1480414091.531687490 DEBUG: writefd_io: 6
1480414091.531917580 DEBUG: writefd_io: 9
1480414091.532505700 DEBUG: writefd_io: 40000
1480414091.533834390 DEBUG: Exiting rw_buffer with code 0
1480414091.534367020 DEBUG: iio_buffer_refill: 40000
1480414091.538021220 DEBUG: Waiting for completion...
1480414092.213967260 DEBUG: iio_buffer_refill: 40000
1480414092.214376090 DEBUG: writefd_io: 6
1480414092.214600880 DEBUG: writefd_io: 9
1480414092.215716230 DEBUG: writefd_io: 40000
1480414092.216306750 DEBUG: Exiting rw_buffer with code 0
1480414092.223836580 DEBUG: Waiting for completion...
1480414092.896503800 DEBUG: iio_buffer_refill: 40000
1480414092.896913340 DEBUG: writefd_io: 6
1480414092.897137770 DEBUG: writefd_io: 9
1480414092.898306790 DEBUG: writefd_io: 40000
1480414092.898912660 DEBUG: Exiting rw_buffer with code 0
1480414092.899380190 DEBUG: iio_buffer_refill: 40000
1480414092.903443780 DEBUG: Waiting for completion...
1480414093.579241330 DEBUG: iio_buffer_refill: 40000
1480414093.579654950 DEBUG: writefd_io: 6
1480414093.579885350 DEBUG: writefd_io: 9
1480414093.580454240 DEBUG: writefd_io: 40000
1480414093.581535320 DEBUG: Exiting rw_buffer with code 0
1480414093.582294950 DEBUG: iio_buffer_refill: 40000
1480414093.586470720 DEBUG: Waiting for completion...
1480414094.262133880 DEBUG: iio_buffer_refill: 40000
1480414094.262553760 DEBUG: writefd_io: 6
1480414094.262775720 DEBUG: writefd_io: 9
1480414094.263782250 DEBUG: writefd_io: 40000
1480414094.264449090 DEBUG: Exiting rw_buffer with code 0
1480414094.269743120 DEBUG: Waiting for completion...
1480414094.944644180 DEBUG: iio_buffer_refill: 40000
1480414094.945053030 DEBUG: writefd_io: 6
1480414094.945282750 DEBUG: writefd_io: 9
1480414094.945859290 DEBUG: writefd_io: 40000
1480414094.946968660 DEBUG: Exiting rw_buffer with code 0
1480414094.947497740 DEBUG: iio_buffer_refill: 40000
1480414094.953180450 DEBUG: Waiting for completion...
1480414095.627421220 DEBUG: iio_buffer_refill: 40000
1480414095.627839040 DEBUG: writefd_io: 6
1480414095.628050960 DEBUG: writefd_io: 9
1480414095.628643220 DEBUG: writefd_io: 40000
1480414095.629559930 DEBUG: Exiting rw_buffer with code 0
1480414095.630182080 DEBUG: iio_buffer_refill: 40000
1480414095.633983770 DEBUG: Waiting for completion...
1480414096.310001650 DEBUG: iio_buffer_refill: 40000
1480414096.310443920 DEBUG: writefd_io: 6
1480414096.310645770 DEBUG: writefd_io: 9
1480414096.311203910 DEBUG: writefd_io: 40000
1480414096.311583760 DEBUG: Exiting rw_buffer with code 0
1480414096.319925020 DEBUG: Waiting for completion...
1480414096.993091290 DEBUG: iio_buffer_refill: 40000
1480414096.993481510 DEBUG: writefd_io: 6
1480414096.993703040 DEBUG: writefd_io: 9
1480414096.994273310 DEBUG: writefd_io: 40000
1480414096.995330170 DEBUG: Exiting rw_buffer with code 0
1480414096.995786580 DEBUG: iio_buffer_refill: 40000
1480414096.999675640 DEBUG: Waiting for completion...
1480414097.675426700 DEBUG: iio_buffer_refill: 40000
1480414097.675839310 DEBUG: writefd_io: 6
1480414097.676102900 DEBUG: writefd_io: 9
1480414097.676681090 DEBUG: writefd_io: 40000
1480414097.677667520 DEBUG: Exiting rw_buffer with code 0
1480414097.682118090 DEBUG: Waiting for completion...
1480414098.357995610 DEBUG: iio_buffer_refill: 40000
1480414098.358403350 DEBUG: writefd_io: 6
1480414098.358624570 DEBUG: writefd_io: 9
1480414098.359193280 DEBUG: writefd_io: 40000
1480414098.359486810 DEBUG: Exiting rw_buffer with code 0
1480414098.359882240 DEBUG: iio_buffer_refill: 40000
1480414098.369123740 DEBUG: Waiting for completion...
1480414099.040566370 DEBUG: iio_buffer_refill: 40000
1480414099.040679300 DEBUG: writefd_io: 6
1480414099.040714690 DEBUG: writefd_io: 9
1480414099.041119540 DEBUG: writefd_io: 40000
1480414099.041348200 DEBUG: iio_buffer_refill: 40000
1480414099.041412520 DEBUG: Exiting rw_buffer with code 0
1480414099.050088220 DEBUG: Waiting for completion...
1480414099.722953550 DEBUG: iio_buffer_refill: 40000
1480414099.723064550 DEBUG: writefd_io: 6
1480414099.723100030 DEBUG: writefd_io: 9
1480414099.723459790 DEBUG: writefd_io: 40000
1480414099.727739160 DEBUG: Exiting rw_buffer with code 0
1480414099.734795790 DEBUG: Waiting for completion...
1480414100.405539560 DEBUG: iio_buffer_refill: 40000
1480414100.405654870 DEBUG: writefd_io: 6
1480414100.405693610 DEBUG: writefd_io: 9
1480414100.406093070 DEBUG: writefd_io: 40000
1480414100.406323900 DEBUG: iio_buffer_refill: 40000
1480414100.406649530 DEBUG: Exiting rw_buffer with code 0
1480414100.412089390 DEBUG: Waiting for completion...
1480414101.088227290 DEBUG: iio_buffer_refill: 40000
1480414101.088336770 DEBUG: writefd_io: 6
1480414101.088374430 DEBUG: writefd_io: 9
1480414101.088741900 DEBUG: writefd_io: 40000
1480414101.088966870 DEBUG: iio_buffer_refill: 40000
1480414101.089650050 DEBUG: Exiting rw_buffer with code 0
1480414101.097322430 DEBUG: Waiting for completion...
1480414101.770986160 DEBUG: iio_buffer_refill: 40000
1480414101.771098320 DEBUG: writefd_io: 6
1480414101.771135770 DEBUG: writefd_io: 9
1480414101.771926810 DEBUG: writefd_io: 40000
1480414101.776741350 DEBUG: Exiting rw_buffer with code 0
1480414101.793312100 DEBUG: Waiting for completion...
1480414102.453826260 DEBUG: iio_buffer_refill: 40000
1480414102.454018010 DEBUG: writefd_io: 6
1480414102.454121590 DEBUG: writefd_io: 9
1480414102.454570730 DEBUG: writefd_io: 40000
1480414102.454709220 DEBUG: Exiting rw_buffer with code 0
1480414102.454983960 DEBUG: iio_buffer_refill: 40000

Make install errors on OS X

adi-mm:build analogdevices$ sudo make install
Password:
[ 50%] Built target iio
[ 58%] Built target libiio-pkg
[ 66%] Built target iio_reg
[ 75%] Built target iio_readdev
[ 83%] Built target iio_info
[ 91%] Built target iio_adi_xflow_check
[100%] Built target iio_genxml
Install the project...
-- Install configuration: "RelWithDebInfo"
-- Installing: /usr/lib/pkgconfig/libiio.pc
CMake Error at cmake_install.cmake:31 (file):
file INSTALL cannot copy file
"/Users/analogdevices/github/libiio/build/libiio.pc" to
"/usr/lib/pkgconfig/libiio.pc".

make: *** [install] Error 1

my understanding is that this is part of System Integrity Protection (SIP, sometimes referred to as rootless) is a security feature of OS X.

I think they now go into /usr/local (which isn't protected.)
https://support.apple.com/en-us/HT204899

in the examples, libcdk5-dev needs to be installed

I think this is just a doc issue, but we should put a README in the ./examples directory.

analog@imhotep:~/github/libiio/examples$ make
cc -Wall -c -o ad9361-iiostream.o ad9361-iiostream.c
cc -o ad9361-iiostream ad9361-iiostream.o -liio
cc -Wall -c -o dummy-iiostream.o dummy-iiostream.c
cc -o dummy-iiostream dummy-iiostream.o -liio
cc -Wall -c -o iio-monitor.o iio-monitor.c
iio-monitor.c:22:21: fatal error: cdk/cdk.h: No such file or directory
#include <cdk/cdk.h>
^
compilation terminated.

analog@imhotep:~/github/libiio/examples$ sudo apt-get install libcdk5-dev

fixes it

Missing values in pkg-config file

In libiio.pc, libdir, sharedlibdir and includedir are empty when built with the default options, leading to pkg-config giving broken options to gcc.

`chan->extend_name` does not seem to be parsed correctly anymore

Hi,

It seems to me that kernel chan->extend_name is not parsed anymore correctly in sysfs for some time.

  1. get_short_attr_name() does not handle it, therefore handle_protected_scan_element_attr() is not able to detect protected attributes, leading to an error.
  2. as protected attributes do not work when an extend_name is there, set_channel_name() is not able anymore to find the name and fix attributes. Also, protected attributes are not part anymore of the attributes list, so this would not work anyway.

I'm not sure about the best way to fix this. Maybe set_channel_name() should be removed (it looks like a hack more than a proper solution) and a get_channel_name() function should be called at the same time than get_channel_id(), but do we have enough information at this moment?

Did I miss something?

Thank you

./examples/iio-monitor.c includes deprecated '#define _BSD_SOURCE'

cc -Wall -c -o iio-monitor.o iio-monitor.c
In file included from /usr/include/stdint.h:25:0,
from /usr/lib/gcc/x86_64-linux-gnu/6/include/stdint.h:9,
from /usr/include/curses.h:63,
from /usr/include/cdk/cdk.h:67,
from iio-monitor.c:22:
/usr/include/features.h:148:3: warning: #warning "_BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE" [-Wcpp]

warning "_BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE"

^~~~~~~
cc -o iio-monitor iio-monitor.o -lpthread -lncurses -lcdk -liio

libiio crash with osc

When using ./osc with Pluto, sometimes I get this:

Thread 1 "osc" received signal SIGSEGV, Segmentation fault.
0x00007ffff4cbb3a6 in iio_channel_attr_write_raw ()
from /usr/lib/x86_64-linux-gnu/libiio.so.0
(gdb) bt
#0 0x00007ffff4cbb3a6 in iio_channel_attr_write_raw ()

from /usr/lib/x86_64-linux-gnu/libiio.so.0
#1 0x00007ffff4cbbd66 in iio_channel_attr_write_double ()

from /usr/lib/x86_64-linux-gnu/libiio.so.0
#2 0x00007ffff7bbed47 in iio_widget_save (widget=0x7fffd008e378)

at iio_widget.c:357

#3 0x00007ffff7bbedd8 in spin_button_progress_step (iio_w=0x7fffd008e378)

at iio_widget.c:518

#4 0x00007ffff5625fc3 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#5 0x00007ffff562554a in g_main_context_dispatch ()

from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#6 0x00007ffff5625900 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#7 0x00007ffff5625c22 in g_main_loop_run ()

from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#8 0x00007ffff725e567 in gtk_main ()

from /usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0
#9 0x0000000000402e4f in main (argc=, argv=)

at oscmain.c:237

Where should the pointer checking be done? in libiio or osc?
I think this is done with the version of libiio in the deb repository. (libiio-dev), not trunk.

-Robin

CMake Cross Compiling

I had to make a few changes to the CMake files in order to get libiio to compile with a GCC Linaro ARM toolchain.

  1. Make the iio target's link libraries public.
-target_link_libraries(iio LINK_PRIVATE ${LIBS_TO_LINK})
+target_link_libraries(iio PUBLIC ${LIBS_TO_LINK})

Without this change, iiod links to libiio, but doesn't link libiio's dependencies, so you get errors like the following:

$ make
Scanning dependencies of target iio
[  4%] Building C object CMakeFiles/iio.dir/channel.c.o
[  8%] Building C object CMakeFiles/iio.dir/device.c.o
[ 12%] Building C object CMakeFiles/iio.dir/context.c.o
[ 16%] Building C object CMakeFiles/iio.dir/buffer.c.o
[ 20%] Building C object CMakeFiles/iio.dir/utilities.c.o
[ 24%] Building C object CMakeFiles/iio.dir/local.c.o
[ 28%] Building C object CMakeFiles/iio.dir/network.c.o
[ 32%] Building C object CMakeFiles/iio.dir/xml.c.o
[ 36%] Building C object CMakeFiles/iio.dir/iiod-client.c.o
[ 40%] Linking C shared library libiio.so
[ 40%] Built target iio
[ 44%] [FLEX][lexer] Building scanner with flex 2.5.39
[ 48%] [BISON][parser] Building parser with bison 3.0.2
Scanning dependencies of target iiod
[ 52%] Building C object iiod/CMakeFiles/iiod.dir/iiod.c.o
[ 56%] Building C object iiod/CMakeFiles/iiod.dir/ops.c.o
[ 60%] Building C object iiod/CMakeFiles/iiod.dir/parser.c.o
[ 64%] Building C object iiod/CMakeFiles/iiod.dir/lexer.c.o
[ 68%] Linking C executable iiod
arm-linux-gnueabihf/bin/ld: warning: libxml2.so.2, needed by ../libiio.so.0.6, not found (try using -rpath or -rpath-link)
../libiio.so.0.6: undefined reference to `xmlFreeDoc@LIBXML2_2.4.30'
../libiio.so.0.6: undefined reference to `iio_mutex_create'
../libiio.so.0.6: undefined reference to `xmlReadMemory@LIBXML2_2.6.0'
  1. Use find_package(Threads) instead of find_library(PTHREAD_LIBRARIES pthread):
if (NEED_THREADS)
   if (NOT_WIN32)
-       find_library(PTHREAD_LIBRARIES pthread)
-       if (PTHREAD_LIBRARIES)
-           set(LIBS_TO_LINK ${LIBS_TO_LINK} ${PTHREAD_LIBRARIES})
-           set(LIBIIO_CFILES ${LIBIIO_CFILES} lock.c)

+       find_package(Threads)
+       if (CMAKE_USE_PTHREADS_INIT)
+           set(LIBS_TO_LINK ${LIBS_TO_LINK} ${CMAKE_THREAD_LIBS_INIT})
+           set(LIBIIO_CFILES ${LIBIIO_CFILES} lock.c)
        else()
            message(SEND_ERROR "The pthread library is a requirement for the selected backends")
        endif()

(And then also update iiod/CMakeLists.txt to link ${CMAKE_THREAD_LIBS_INIT} instead of ${PTHREAD_LIBRARIES}).

build error on Ubuntu 15 with libserialport installed

picozed@picozed:~/github/libiio/build$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 15.10
Release: 15.10
Codename: wily

picozed@picozed:~/github/libiio/build$ dpkg -l libserialport-dev
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-========================-=================-=================-======================================================
ii libserialport-dev:i386 0.1.0-1 i386 Crossplatform serial port handling library - developme

[ 3%] Building C object CMakeFiles/iio.dir/serial.c.o
/home/picozed/github/libiio/serial.c: In function ‘serial_read_data’:
/home/picozed/github/libiio/serial.c:204:49: warning: implicit declaration of function ‘sp_blocking_read_next’ [-Wimplicit-function-declaration]
ssize_t ret = (ssize_t) libserialport_to_errno(sp_blocking_read_next(
^
/home/picozed/github/libiio/serial.c: In function ‘serial_create_context’:
/home/picozed/github/libiio/serial.c:334:45: error: ‘SP_MODE_READ_WRITE’ undeclared (first use in this function)
ret = libserialport_to_errno(sp_open(port, SP_MODE_READ_WRITE));
^
/home/picozed/github/libiio/serial.c:334:45: note: each undeclared identifier is reported only once for each function it appears in
/home/picozed/github/libiio/serial.c:350:9: warning: implicit declaration of function ‘sp_get_port_description’ [-Wimplicit-function-declaration]
desc = sp_get_port_description(port);
^
/home/picozed/github/libiio/serial.c:350:7: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
desc = sp_get_port_description(port);
^
CMakeFiles/iio.dir/build.make:238: recipe for target 'CMakeFiles/iio.dir/serial.c.o' failed
make[2]: *** [CMakeFiles/iio.dir/serial.c.o] Error 1
CMakeFiles/Makefile2:60: recipe for target 'CMakeFiles/iio.dir/all' failed
make[1]: *** [CMakeFiles/iio.dir/all] Error 2
Makefile:136: recipe for target 'all' failed
make: *** [all] Error 2

building without libserialport installed works fine.

Most likely just needs a little more Cmake-foo to check the version of libserialport

-Robin

how to send IQ data using tx1 and rx1 and tx2 and rx2

HI,

I use AD-FMComms2-EBZ platforme with ad9361 and Zedboard, controled by MATLAB windows. I send IQ data using TXRX and it work well.
i tried to send IQ data using tx1rx1 and tx2rx2 (MIMO 2*2) with different frequency on each txrx. How can i reconfigure ad9361.cfg to succeded this communication.

Thank you
Regards

Libiio release for Windows

Is the Windows installer release for 32 or 64 bits?

If it is for 64 bits, it would be helpful if the file name indicated that.
Also if it is for 64 bits, would it be possible for you to provide a 32 bit version as well?
( Use will be will be with 32 bit Python ).

Thanks

sudo make install leaves files in ./build directory as root

mkdir build
cd build
cmake .. && make && sudo make install

then:

analog@imhotep:/github/libiio/build$ rm * -rf
rm: cannot remove 'build/lib.linux-x86_64-2.7/iio.py': Permission denied
analog@imhotep:
/github/libiio/build$ ls -l ./build/lib.linux-x86_64-2.7/
total 24
-rw-r--r-- 1 root root 24168 Oct 27 12:20 iio.py

?

Enhance buffer API

I have some requests about buffer API. Actually I have some needs, but I would like to have a feedback before starting my development, mainly to know if the ideas themself are correct for libiio, and to have some clues about the expected implementation. The goal is to provide a pull request that has a sense...

My goal is to fetch samples from three differents sensors that are running at different rates, in an unique thread. I would like to :

  • Make a blocking read on my faster sensor (no problem here, it's already available in libiio API)
  • Read the other sensors. If no data are available, get EAGAIN. There is already a iio_context_set_timeout() but it is global to the context, not locally defined for a buffer

Furthermore, I would like to have a way to control the size of the buffer on kernel side. From what I understand, libiio configures the buffer at the exact size of the read done by iio_buffer_refill(), and this size is configured in iio_device_create_buffer(). Actually I would like to use kernel buffer to store some extra data for me, in case I'm a little bit late in my processing, so a little tuning of the kernel buffer size would help me a lot.

To conclude, I would like to add these functionalities in the buffer API :

  • Support of non-blocking reads
  • Kernel buffer size configuration

An extra feature is to export the filedescriptor of the buffer to read (or return -1 if no pollable filedescriptor is available), to do the poll() myself in my acquisition loop.

Question : identification of USB devices?

Is there a way to expose device USB serial number via libiio?
http://libusb.org/static/api-1.0/structlibusb__device__descriptor.html

I know I can manage things with uri (which port things are plugged into), but if I write an application that always expects device A to be set to frequency Z, and device B to be set to frequency Y, on USB, I can't really tell which is which.

I have to ensure that end users always plug USB devices into the same ports.

Or is there a way to get the USB serial number?

Thanks

Handling channels that have no modifier or are not indexed

iio_channel_is_scan_element() returns false for channels without a modifier and that are not indexed, even though the kernel creates an entry in the scan_elements directory for them. Is that correct?

For example, a temperature sensor would have a single channel (so there's no need to index it), and it wouldn't need a modifier either. It would show up as "in_temp_raw" in the device directory and have "in_temp_{en|index|type}" files in the scan_elements directory.

IPv6 on Windows

Libiio does not support IPv6 on Windows, while it does on Linux.

LIbiio with intel edison

Hello,

I want to run the ADC on intel edison at 8khz.Is it possible to achieve this with libiio on edison?

Installing libiio breaks pysmu

Having libiio installed causes pysmu to break.

Python Error when libiio is installed:

Python 2.7.12 (v2.7.12:d33e0cf91556, Jun 27 2016, 15:19:22) [MSC v.1500 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
============= RESTART: D:\ALM\ALM Software\alice-desktop-1.1.pyw =============

Traceback (most recent call last):
File "D:\ALM\ALM Software\alice-desktop-1.1.pyw", line 8, in
from pysmu import *
File "C:\Python27\lib\site-packages\pysmu_init_.py", line 13, in
import _pysmu
ImportError: DLL load failed: The specified module could not be found.

This happened on all three of my Windows computers. Uninstalling libiio fixes the problem and pysmu will import properly again.

Just thought you would like to know....

Doug

local_get_buffer() Valgrind error

I'm trying to debug what I think it stack corruption in my program, and I came across this. I'm not sure if it's related to my problem.

==865== Thread 2:
==865== Syscall param ioctl(generic) points to uninitialised byte(s)
==865== at 0x4B8B76C: ioctl (syscall-template.S:81)
==865== by 0x487C2C7: local_get_buffer (in /usr/lib/libiio.so.0.5)
==865== Address 0x57f6d38 is on thread 2's stack
==865==

Contradictory behaviour in iio_info

I have a x86 ubuntu 16.04 machine with into which I've loaded industrialio.ko and industrialio-triggered-event.ko

running iio_info --scan gives
Library version: 0.8 (git tag: v0.8)
Compiled with backends: local xml network
No contexts found.

however running iio_info gives
Library version: 0.8 (git tag: v0.8)
Compiled with backends: local xml network
IIO context created with local backend.
Backend version: 0.8 (git tag: v0.8)
Backend description string: Linux <....>
IIO context has 1 attributes:
local,kernel: 4.4.0-53-generic
IIO context has 0 devices:

Why does the iio_scan_context_get_info_list not find the local backend?

Network versus local context

Hi Paul,

I'm running a system with an ADC conversion at 1000Hz and noted that sometimes using a network context, there is a package lost (127.0.0.1). I describe below how the drop packages are measured.

The application is checking the timestamp (setup with monotonic clock) to validate there is not data lost in the SPI interruption (currently around 30% CPU usage). The same application calculate the time between samples to diagnostic data lost. Could be another way to perform this checking at user space level using libiio?

At the moment, the samples_count is set to be 0.1 sec (100 samples) when the buffer is created iio_device_create_buffer (pDev, 100, false).

Sometimes (around minutes) the time between samples is 100ms (almost exact). Ir seems there is a package lost anywhere. Assuming this setup, may you give a hint where the data is lost and how to avoid it? Any other test setup to evaluated this issue?

BTW, I used this comm channel for previous experience. Let me know if there is another more convenient (I don't want to register an issue here without to be sure about it).

Thanks

build error when libusb-dev not installed is sort of wrong...

analog@imhotep:/github/libiio$ cd build/
analog@imhotep:
/github/libiio/build$ cmake .. && make
-- The C compiler identification is GNU 6.2.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Performing Test HAS_WPEDANTIC
-- Performing Test HAS_WPEDANTIC - Success
-- Looking for strdup
-- Looking for strdup - found
-- Looking for strerror_r
-- Looking for strerror_r - found
-- Looking for in6addr_any
-- Looking for in6addr_any - found
-- Found Git: /usr/bin/git (found version "2.10.2")
-- Performing Test HAS_O_TMPFILE
-- Performing Test HAS_O_TMPFILE - Success
-- Performing Test WITH_NETWORK_EVENTFD
-- Performing Test WITH_NETWORK_EVENTFD - Success
-- Performing Test HAS_PIPE2
-- Performing Test HAS_PIPE2 - Success
-- Found LibXml2: /usr/lib/x86_64-linux-gnu/libxml2.so (found version "2.9.4")
-- Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE)
-- Doxygen not found, API documentation won't be generated
-- Found BISON: /usr/bin/bison (found version "3.0.4")
-- Found FLEX: /usr/bin/flex (found version "2.6.1")
-- 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 Error at iiod/CMakeLists.txt:34 (message):
USB support in IIOD requires async. I/O support

analog@imhotep:~/github/libiio/build$ sudo apt-get install libusb-1.0-0-dev

didn't help

analog@imhotep:~/github/libiio/build$ sudo apt-get install libaio-dev

does fix the error.

having a more specific error message would be great. ("please make sure libusb-dev and libaio-dev are installed") or something like that.

ssize_t on Windows

Since commit 463edc7, ssize_t on Windows changed from being a typedef of 'long' to a typedef of 'ptrdiff_t'. This did enlighten one issue: 'long' is 32-bit even on 64-bit Windows, so this commit broke the ABI. On the other hand, ssize_t should really be 64-bit (just like size_t).

This should be fixed before v0.8, any thoughts about the issue?

iioxml.py crashes wtih null pointer exception

Thanks for this great project! I'm especially excited for the python bindings, and have been trying to get them to work today.

Is iioxml.py expected to work at this point? If not, please disregard. If so... I still could have messed something up, but I think I have everything installed correctly. When I try to run iioxml.py, I get this:

Traceback (most recent call last):
  File "./examples/iioxml.py", line 83, in <module>
    main()
  File "./examples/iioxml.py", line 66, in main
    context = LocalContext()
  File "/home/pi/devdir/tmp/libiio/bindings/python/iio.py", line 673, in __init__
    ctx = _new_local()
  File "/home/pi/devdir/tmp/libiio/bindings/python/iio.py", line 25, in _checkNull
    raise Exception("Null pointer")
Exception: Null pointer
Exception AttributeError: "'LocalContext' object has no attribute '_context'" in <bound method LocalContext.__del__ of <iio.LocalContext object at 0xb6d002b0>> ignored

I get the same whenever I try to initialize a LocalContext object. Is it working for you? If so, and you can't reproduce the issue, let me know and I'll do some more thorough reporting.

cmake on OS-X spews warnings

adi-mm:build analogdevices$ uname -a
Darwin adi-mm.local 15.6.0 Darwin Kernel Version 15.6.0: Thu Sep 1 15:01:16 PDT 2016; root:xnu-3248.60.11~2/RELEASE_X86_64 x86_64

adi-mm:github analogdevices$ cd libiio/
adi-mm:libiio analogdevices$ mkdir build
adi-mm:libiio analogdevices$ cd build/
adi-mm:build analogdevices$ cmake ../

CMake Warning (dev):
Policy CMP0042 is not set: MACOSX_RPATH is enabled by default. Run "cmake
--help-policy CMP0042" for policy details. Use the cmake_policy command to
set the policy and suppress this warning.

MACOSX_RPATH is not specified for the following targets:

iio

This warning is for project developers. Use -Wno-dev to suppress it.

-- Generating done
-- Build files have been written to: /Users/analogdevices/github/libiio/build

adi-mm:build analogdevices$ cmake --help-policy CMP0042
CMP0042

MACOSX_RPATH is enabled by default.

CMake 2.8.12 and newer has support for using @rpath in a target's install
name. This was enabled by setting the target property
MACOSX_RPATH. The @rpath in an install name is a more
flexible and powerful mechanism than @executable_path or @loader_path
for locating shared libraries.

CMake 3.0 and later prefer this property to be ON by default. Projects
wanting @rpath in a target's install name may remove any setting of
the INSTALL_NAME_DIR and CMAKE_INSTALL_NAME_DIR
variables.

This policy was introduced in CMake version 3.0. CMake version
3.5.0 warns when the policy is not set and uses OLD behavior. Use
the cmake_policy command to set it to OLD or NEW explicitly.

.. note::
The OLD behavior of a policy is
deprecated by definition
and may be removed in a future version of CMake.

warnings on various compilers/operating systems

From https://travis-ci.org/analogdevicesinc/libiio/builds/187372758

Linux clang, and OS-X (10.10 & 10.11 & 10.12)
/home/travis/build/analogdevicesinc/libiio/usb.c:712:4: warning: format
specifies type 'unsigned char' but the argument has type 'int' [-Wformat]
(dev_desc.bcdUSB >> 8) & 0xf,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/travis/build/analogdevicesinc/libiio/usb.c:713:4: warning: format
specifies type 'unsigned char' but the argument has type 'int' [-Wformat]
(dev_desc.bcdUSB >> 4) & 0xf);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 warnings generated.

Linux/gcc/trusty:

[ 62%] Building C object iiod/CMakeFiles/iiod.dir/iiod.c.o
/home/travis/build/analogdevicesinc/libiio/iiod/iiod.c: In function ‘main’:
/home/travis/build/analogdevicesinc/libiio/iiod/iiod.c:368:8: warning: unused variable ‘end’ [-Wunused-variable]
char *end, *ffs_mountpoint = NULL;
^
/home/travis/build/analogdevicesinc/libiio/iiod/iiod.c:365:7: warning: unused variable ‘nb_pipes’ [-Wunused-variable]
long nb_pipes = 3;
^

all the language bindings don't get installed in all packages

After I build, the header files are include in the packges:

analog@imhotep:~/github/libiio$ find ./ -name "iio.h"
./iio.h
./build/_CPack_Packages/Linux/DEB/libiio-0.8.gc4040b6-Linux/usr/include/iio.h
./build/_CPack_Packages/Linux/RPM/libiio-0.8.gc4040b6-Linux/usr/include/iio.h
./build/_CPack_Packages/Linux/TGZ/libiio-0.8.gc4040b6-Linux/include/iio.h

in the deb, rpm, and tar file.

However:
analog@imhotep:~/github/libiio$ find ./ -name iio.py
./bindings/python/iio.py
./build/_CPack_Packages/Linux/DEB/libiio-0.8.gc4040b6-Linux/usr/lib/python2.7/site-packages/iio.py
./build/_CPack_Packages/Linux/RPM/libiio-0.8.gc4040b6-Linux/usr/lib/python2.7/site-packages/iio.py
./build/bindings/python/build/lib.linux-x86_64-2.7/iio.py

in the deb, rpm, but not the tar file.

analog@imhotep:~/github/libiio$ find ./ -name "iio-wrapper.h"
./bindings/matlab/iio-wrapper.h

not in the deb, rpm, or tar file.

Macro definition of snprintf conflicts on MSVC 14 (VS2015)

There is the following code in "iio-private.h".

#ifdef _MSC_BUILD
#define snprintf sprintf_s  
#define inline __inline  
#endif

This cases a build error in Microsoft Visual C++ version 14 which comes from Visual Studio 2015 because "snprintf" is already defined as below.

Error C1189 #error: Macro definition of snprintf conflicts with Standard Library function declaration

https://msdn.microsoft.com/en-us/library/2ts7cx93.aspx

I would like to suggest to change the code like below.

#if _MSC_VER<=1800
#define snprintf sprintf_s
#endif

#ifdef _MSC_BUILD
#define inline __inline
#endif

Using Libiio with Python

The Windows installer places the libiio.dll file in the system32 directory but Python (iio.py) does not seem
to find it there. Installer probably needs to add/change something in a Path?

Thanks

stack usage

In most of the int iio_xxxxxx_attr_write_xxxxxx functions, we allocate a 1k buffer on the stack:

    char buf[1024];
    snprintf(buf, sizeof(buf), "%lld", val);

(In this case, of the longlong), we know at compile time, that the max length of long long is:

floor( log10( ULLONG_MAX ) ) + 1;

which should all be done by the pre-processor at complile time on modern toolsuites (it's all constants) - at least it works on gcc 6.2.0... which is:

floor ( log10(18446744073709551615) ) + 1 = 20;

which is alot more memory efficient than a 1k buffer on the stack. -- even DBL_MAX is only 309 characters...

?

Accessing already enabled device

When I open device that is already running (buffer/enable is 1) I cannot set its attributes with iio_channel_attr_write(). This can happen eg. after when application closes unexpectedly.
For such case I'm lacking a possibility to disable buffer before calling iio_device_create_buffer().

My issue can be workarounded by sequence iio_device_create_buffer(), iio_buffer_destroy(), iio_device_create_buffer() but it does not look very nice...

Updating context when new device appears

For some purposes iio_sysfs_trigger module is quiet usable. New triggers sysfstrigX are added after writing X into iio_sysfs_trigger/add_trigger. Unfortunately it seems that there is no way to update existing context with new trigger devices after it was created.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.