Unix & Linux Stack Exchange
Q&A for users of Linux, FreeBSD and other Unix-like operating systems
Latest Questions
0
votes
1
answers
150
views
Where to create symlinks to sysfs iio files
I wrote a driver that exposes I2C registers via an IIO device, this device operates in direct mode (read/write directly to files in sysfs), the files are correctly created in sysfs and work fine. I would like to expose these files in a user-friendly way, I was thinking of creating symlinks to the sy...
I wrote a driver that exposes I2C registers via an IIO device, this device operates in direct mode (read/write directly to files in sysfs), the files are correctly created in sysfs and work fine.
I would like to expose these files in a user-friendly way, I was thinking of creating symlinks to the sysfs files with a udev rule so that instead of having to read
/sys/bus/i2c/devices/5-0042/iio\:device1/in_pressure_raw
the user can read from a file like /run/the_tank/pressure
.
What's the best place for such files? /dev
? /run
?
Pedru
(101 rep)
Aug 6, 2024, 11:52 AM
• Last activity: Aug 6, 2024, 12:47 PM
1
votes
1
answers
295
views
How to fix MPU9250 configuration issue in device tree?
I have set up an i2c protocol which detects the mpu9250 at address 0x68. Now I want to configure the mpu and I have updated my dts file with the following lines of code: mpu9250@68 { compatible = "invensense,mpu9250"; reg = ; i2c-gate { #address-cells = ; #size-cells = ; ax8975@c { compatible = "ak,...
I have set up an i2c protocol which detects the mpu9250 at address 0x68. Now I want to configure the mpu and I have updated my dts file with the following lines of code:
mpu9250@68 {
compatible = "invensense,mpu9250";
reg = ;
i2c-gate {
#address-cells = ;
#size-cells = ;
ax8975@c {
compatible = "ak,ak8975";
reg = ;
};
};
};
However, I get the following error on running >> dmesg | grep mpu
>> inv-mpu6050-i2c 1-0068: invalid whoami 0x40 expected 0x71 (MPU9250)
For this I have also configured the i2cmux and Industrial I/O (IIO) through the developer shell with the "make menuconfig" command. But I see no expected results. Where could I have possibly gone wrong?
Amod Amatya
(111 rep)
Jun 14, 2019, 02:22 PM
• Last activity: Jan 30, 2024, 04:47 PM
0
votes
1
answers
537
views
IIO Unable to refill buffer: Connection timed out (110) error when running iio_readdev
I have made a custom Linux image with Yocto for use with [CN0540][1] and DE10-Nano. The manufacturer of the CN0540 (Analog Devices) provides an [evaluation image][3] for the board, which works without issue, however in my custom image which is using the same kernel fork ([ADI Linux fork][4]), the sa...
I have made a custom Linux image with Yocto for use with CN0540 and DE10-Nano. The manufacturer of the CN0540 (Analog Devices) provides an evaluation image for the board, which works without issue, however in my custom image which is using the same kernel fork (ADI Linux fork ), the same defconfig as far as I can tell (socfpga_adi_defconfig), and the same device tree (CN0540 dts ), and also the same HDL is loaded on the FPGA (CN0540 HDL ) I can't use the buffer from the ADC on the CN0540 (AD7768-1). I can read a single value from the ADC, either with libiio's
iio_info
command, or with the device file at sys/bus/iio/devices/iio:device0/in_voltage0_raw
, but I can't read from the buffer of the device E.g iio_readdev ad7768-1
returns Unable to refill buffer: Connection timed out (110)
, or doing
> echo 1 > scan_elements/in_voltage0_en
> echo 1 > buffer/enable
> cat /dev/iio:device0 | hexdump
which causes the device to crash, unless I set the length of the buffer to 1 with echo 1 > buffer/length
which causes the device to output
[ 441.310599] rcu: INFO: rcu_sched self-detected stall on CPU
[ 441.316258] rcu: 0-....: (2099 ticks this GP) idle=10f/1/0x40000002 softirq=2509/2509 fqs=1033
[ 441.325163] (t=2100 jiffies g=497 q=7)
[ 441.329057] NMI backtrace for cpu 0
[ 441.332592] CPU: 0 PID: 163 Comm: cat Not tainted 5.15.0-yocto-standard-adi #1
[ 441.339927] Hardware name: Altera SOCFPGA
[ 441.343988] Backtrace:
[ 441.346453] [] (dump_backtrace) from [] (show_stack+0x20/0x24)
[ 441.354073] r7:c010edfc r6:00000000 r5:60070193 r4:c143b218
[ 441.359801] [] (show_stack) from [] (dump_stack_lvl+0x48/0x54)
[ 441.367360] [] (dump_stack_lvl) from [] (dump_stack+0x18/0x1c)
[ 441.374907] r5:00000000 r4:20070193
[ 441.378525] [] (dump_stack) from [] (nmi_cpu_backtrace+0xe0/0x114)
[ 441.386424] [] (nmi_cpu_backtrace) from [] (nmi_trigger_cpumask_backtrace+0xe8/0x134)
[ 441.395965] r7:c010edfc r6:c0e01ee4 r5:c170469c r4:00000000
[ 441.401597] [] (nmi_trigger_cpumask_backtrace) from [] (arch_trigger_cpumask_backtrace+0x20/0x24)
[ 441.412180] r9:c1703f10 r8:c0e01ee0 r7:c1835438 r6:00000000 r5:c1703fa4 r4:c171e840
[ 441.419886] [] (arch_trigger_cpumask_backtrace) from [] (rcu_dump_cpu_stacks+0x144/0x174)
[ 441.429922] [] (rcu_dump_cpu_stacks) from [] (rcu_sched_clock_irq+0x6a8/0xa58)
[ 441.438860] r10:2e138000 r9:c1702d00 r8:c1693f40 r7:c18361a0 r6:00000000 r5:ef7cbf40
[ 441.446784] r4:c171e840
[ 441.449304] [] (rcu_sched_clock_irq) from [] (update_process_times+0x98/0xc4)
[ 441.458174] r10:c1702d80 r9:c1702d40 r8:c184fd40 r7:2e138000 r6:c1702d00 r5:00000000
[ 441.465969] r4:ef7c5540
[ 441.468524] [] (update_process_times) from [] (tick_sched_timer+0x88/0x2d8)
[ 441.477198] r7:c1ea9dc0 r6:00000066 r5:bf87a4da r4:ef7c6128
[ 441.482830] [] (tick_sched_timer) from [] (__hrtimer_run_queues+0x1fc/0x36c)
[ 441.491730] r10:ef7c5e14 r9:ef7c6128 r8:20070193 r7:00000000 r6:c01b7458 r5:ef7c5dc0
[ 441.499645] r4:ef7c5e00
[ 441.502183] [] (__hrtimer_run_queues) from [] (hrtimer_interrupt+0x13c/0x2c8)
[ 441.511041] r10:ef7c5e98 r9:ef7c5e70 r8:ef7c5e48 r7:ef7c5dcc r6:00000003 r5:20070193
[ 441.518836] r4:ef7c5dc0
[ 441.521357] [] (hrtimer_interrupt) from [] (twd_handler+0x44/0x4c)
[ 441.529394] r10:c1ea8000 r9:c1ea9dc0 r8:f080210c r7:c1d08240 r6:00000018 r5:c17046b4
[ 441.537301] r4:00000001
[ 441.539821] [] (twd_handler) from [] (handle_percpu_devid_irq+0x9c/0x200)
[ 441.548321] r5:c17046b4 r4:c1d09000
[ 441.551888] [] (handle_percpu_devid_irq) from [] (handle_domain_irq+0x6c/0x88)
[ 441.560961] r7:0000001d r6:00000000 r5:00000000 r4:c1692a14
[ 441.566593] [] (handle_domain_irq) from [] (gic_handle_irq+0x88/0x9c)
[ 441.574767] r7:c1692a20 r6:f0802100 r5:c177a344 r4:c17046b4
[ 441.580494] [] (gic_handle_irq) from [] (__irq_svc+0x5c/0x78)
[ 441.587952] Exception stack(0xc1ea9dc0 to 0xc1ea9e08)
[ 441.593047] 9dc0: c28b3700 00000000 00000000 00000003 00001000 c28b3700 c2b47f40 befe9c04
[ 441.601193] 9de0: c28b3774 befe9c04 c1ea8000 c1ea9e24 c1ea9e28 c1ea9e10 c0a95530 c0a949ac
[ 441.609342] 9e00: 20070013 ffffffff
[ 441.612863] r9:c1ea8000 r8:c28b3774 r7:c1ea9df4 r6:ffffffff r5:20070013 r4:c0a949ac
[ 441.620699] [] (iio_dma_buffer_dequeue) from [] (iio_dma_buffer_read+0x148/0x19c)
[ 441.629894] r5:c28b3700 r4:00001000
[ 441.633452] [] (iio_dma_buffer_read) from [] (iio_buffer_read+0x178/0x228)
[ 441.642168] r10:c1ea8000 r9:befe9c04 r8:00001000 r7:00000400 r6:00000002 r5:c1e43000
[ 441.649962] r4:c28b3700
[ 441.652483] [] (iio_buffer_read) from [] (iio_buffer_read_wrapper+0x2c/0x38)
[ 441.661248] r10:00000003 r9:c0954af8 r8:00001000 r7:00000001 r6:c1ea8000 r5:c1ea9f60
[ 441.669050] r4:c2b28540
[ 441.671571] [] (iio_buffer_read_wrapper) from [] (vfs_read+0xc4/0x320)
[ 441.679817] [] (vfs_read) from [] (ksys_read+0x74/0xec)
[ 441.686766] r10:00000003 r9:00000000 r8:00000000 r7:befe9c04 r6:c1ea8000 r5:c2b28540
[ 441.694560] r4:c2b28540
[ 441.697081] [] (ksys_read) from [] (sys_read+0x18/0x1c)
[ 441.704027] r9:c1ea8000 r8:c0100244 r7:00000003 r6:b6f681a0 r5:befe9c04 r4:00001000
[ 441.711733] [] (sys_read) from [] (ret_fast_syscall+0x0/0x48)
[ 441.719310] Exception stack(0xc1ea9fa8 to 0xc1ea9ff0)
[ 441.724344] 9fa0: 00001000 befe9c04 00000003 befe9c04 00001000 00000000
[ 441.732488] 9fc0: 00001000 befe9c04 b6f681a0 00000003 00000000 01000000 00000003 befe9c04
[ 441.740769] 9fe0: 00000003 befe9bb8 b6e6070f b6de1ae6
and that output repeats every ~20 seconds.
The device is supposed to send an interrupt to the OS when the buffer is ready, so I probed the DRDY pin (which is the pin for the interrupt) of the device with an MCU, and the pin never goes high.
I also tried switching the libiio version I was using to the same as the evaluation image, 0.23 to 0.21 and the error when running iio_readdev ad7768-1
changed from Unable to refill buffer: Connection timed out (110)
to
Unable to refill buffer: Connection timed out
ERROR: Error during buffer disable: No such file or directory
which I'm pretty sure is functionally the same error, so I changed the libiio version back to 0.23
I patched the device driver and libiio in an attempt to find the problem and found out that the problem line from calling iio_readdev ad7768-1
in libiio is this one ret = poll(pollfd, 2, timeout_rel);
, and the problem function in the device driver seems to be this one hw_submit_block
.
What is causing the timed out error?
ThePumkinMelon
(3 rep)
May 19, 2023, 08:03 PM
• Last activity: Jul 24, 2023, 08:07 PM
1
votes
0
answers
71
views
DT bindings for ADT7516 sensor
I have a BeagleBone green and ADT7516's evaluation board connected with SDA and SCL pins. When I do i2cdetect -y -r 2, I can see the i2c address as 0x4b and I am able to probe the adt7316 driver present in IIO subsystem. adt7316 driver uses platform data to get the hardware description. But my goal...
I have a BeagleBone green and ADT7516's evaluation board connected with SDA and SCL pins.
When I do i2cdetect -y -r 2, I can see the i2c address as 0x4b and I am able to probe the adt7316 driver present in IIO subsystem.
adt7316 driver uses platform data to get the hardware description. But my goal is to remove platform data and use DT bindings.
I understand some basic things about the DT bindings like..
1. Compatible
2. reg
But when I have a close look at the driver, I can see that there are certain
things which are taken from the platform data and are used in the whole driver.
So my question is that how do I replace those things in the driver if I remove platform data and use DT bindings.
I am putting probe function's code here.
int adt7316_probe(struct device *dev, struct adt7316_bus *bus,
const char *name)
{
struct adt7316_chip_info *chip;
struct iio_dev *indio_dev;
unsigned short *adt7316_platform_data = dev->platform_data;
int ret = 0;
indio_dev = devm_iio_device_alloc(dev, sizeof(*chip));
if (!indio_dev)
return -ENOMEM;
chip = iio_priv(indio_dev);
/* this is only used for device removal purposes */
dev_set_drvdata(dev, indio_dev);
chip->bus = *bus;
if (name == '3')
chip->id = ID_ADT7316 + (name - '6');
else if (name == '5')
chip->id = ID_ADT7516 + (name - '6');
else
return -ENODEV;
chip->ldac_pin = adt7316_platform_data;
if (chip->ldac_pin) {
chip->config3 |= ADT7316_DA_EN_VIA_DAC_LDCA;
if ((chip->id & ID_FAMILY_MASK) == ID_ADT75XX)
chip->config1 |= ADT7516_SEL_AIN3;
}
chip->int_mask = ADT7316_TEMP_INT_MASK | ADT7316_VDD_INT_MASK;
if ((chip->id & ID_FAMILY_MASK) == ID_ADT75XX)
chip->int_mask |= ADT7516_AIN_INT_MASK;
indio_dev->dev.parent = dev;
if ((chip->id & ID_FAMILY_MASK) == ID_ADT75XX)
indio_dev->info = &adt7516_info;
else
indio_dev->info = &adt7316_info;
indio_dev->name = name;
indio_dev->modes = INDIO_DIRECT_MODE;
if (chip->bus.irq > 0) {
if (adt7316_platform_data)
chip->bus.irq_flags = adt7316_platform_data;
ret = devm_request_threaded_irq(dev, chip->bus.irq,
NULL,
adt7316_event_handler,
chip->bus.irq_flags |
IRQF_ONESHOT,
indio_dev->name,
indio_dev);
if (ret)
return ret;
if (chip->bus.irq_flags & IRQF_TRIGGER_HIGH)
chip->config1 |= ADT7316_INT_POLARITY;
}
ret = chip->bus.write(chip->bus.client, ADT7316_CONFIG1, chip->config1);
if (ret)
return -EIO;
ret = chip->bus.write(chip->bus.client, ADT7316_CONFIG3, chip->config3);
if (ret)
return -EIO;
ret = devm_iio_device_register(dev, indio_dev);
if (ret)
return ret;
dev_info(dev, "%s temperature sensor, ADC and DAC registered.\n",
indio_dev->name);
return 0;
}
EXPORT_SYMBOL(adt7316_probe);
So in the code we can see that **chip->ldac_pin** and **chip->bus.irq_flags** uses
platform data.
If I use DT bindings then platform data will have NULL value in it.
So how do I design my DT bindings here and how can I fetch that data in the driver?
I have seen many examples of DT bindings but I need specific help with adt7516 sensor.
**Datasheet of adt7516 sensor**
http://www.analog.com/media/en/technical-documentation/data-sheets/ADT7516_7517_7519.pdf
Shreeya Patel
(11 rep)
Sep 10, 2018, 06:05 PM
• Last activity: Dec 31, 2022, 07:58 PM
2
votes
0
answers
796
views
How to name a device in the device tree?
I have used a device tree overlay file (dtbo) to add a hardware reference over the i2c-2 node to my device tree. This device is an accelerometer that implements an existing driver that can be found here: https://elixir.bootlin.com/linux/v4.19.94/source/drivers/iio/accel/mma8452.c My device appears a...
I have used a device tree overlay file (dtbo) to add a hardware reference over the i2c-2 node to my device tree. This device is an accelerometer that implements an existing driver that can be found here: https://elixir.bootlin.com/linux/v4.19.94/source/drivers/iio/accel/mma8452.c
My device appears as
iio:device0
in the /dev directory:
debian@beaglebone:/dev$ ls
accel log spi tty27 tty53 urandom
apm_bios loop-control spidev1.0 tty28 tty54 vcs
autofs mapper spidev1.1 tty29 tty55 vcs1
block mem spidev2.0 tty3 tty56 vcs2
btrfs-control memory_bandwidth spidev2.1 tty30 tty57 vcs3
bus mmcblk0 stderr tty31 tty58 vcs4
char mmcblk0p1 stdin tty32 tty59 vcs5
console mmcblk1 stdout tty33 tty6 vcs6
cpu_dma_latency mmcblk1boot0 tty tty34 tty60 vcsa
cuse mmcblk1boot1 tty0 tty35 tty61 vcsa1
disk mmcblk1p1 tty1 tty36 tty62 vcsa2
dri mmcblk1rpmb tty10 tty37 tty63 vcsa3
fb0 mqueue tty11 tty38 tty7 vcsa4
fd net tty12 tty39 tty8 vcsa5
full network_latency tty13 tty4 tty9 vcsa6
fuse network_throughput tty14 tty40 ttyGS0 vcsu
gpiochip0 null tty15 tty41 ttyO0 vcsu1
gpiochip1 ppp tty16 tty42 ttyO1 vcsu2
gpiochip2 ptmx tty17 tty43 ttyO2 vcsu3
gpiochip3 pts tty18 tty44 ttyO4 vcsu4
hwrng pwm tty19 tty45 ttyO5 vcsu5
i2c-0 random tty2 tty46 ttyS0 vcsu6
i2c-1 remoteproc tty20 tty47 ttyS1 vhci
i2c-2 rfkill tty21 tty48 ttyS2 watchdog
iio:device0 rtc tty22 tty49 ttyS4 watchdog0
initctl rtc0 tty23 tty5 ttyS5 watchdog1
input shm tty24 tty50 ubi_ctrl zero
ion snapshot tty25 tty51 uhid
kmsg snd tty26 tty52 uinput
My device can also be viewed in:
debian@beaglebone:/sys/class/i2c-dev/i2c-2/subsystem/i2c-2/device/2-001c$ ls
driver modalias of_node subsystem uevent
iio:device0 name power trigger0
Here you can see the specifics of the device naming:
debian@beaglebone:/sys/class/i2c-dev/i2c-2/subsystem/i2c-2/device/2-001c/iio:device0$ cat uevent
MAJOR=248
MINOR=0
DEVNAME=iio:device0
DEVTYPE=iio_device
OF_NAME=accelerometer
OF_FULLNAME=/ocp/i2c@4819c000/accelerometer@1C
OF_COMPATIBLE_0=fsl,mma8451
OF_COMPATIBLE_N=1
**My question is, where does this device get its name as iio:device0
?** I assume this is simply a default name as I haven't specified one. **My question therefore becomes: How do I specify a name for my device in the device tree? It seems I would like to change the DEVNAME somehow.**
I do not see any reason for this name in my dtbo file, which can be seen below:
/*
* MIRA custom cape device tree overlay
* Supports MMA8451Q Accelerometer
*/
/dts-v1/;
/plugin/;
#include
/ {
/*
* Helper to show loaded overlays under: /proc/device-tree/chosen/overlays/
*/
fragment@0 {
target-path="/";
__overlay__ {
chosen {
overlays {
MIRA_EXTENSIONS = __TIMESTAMP__;
};
};
};
};
fragment@1 {
target = ;
__overlay__ {
status = "okay";
#address-cells = ;
#size-cells = ;
accelerometer@1C {
compatible = "fsl,mma8451";
reg = ;
interrupt-parent = ;
interrupts = ;
interrupt-names = "INT1";
};
};
};
};
Dillon McCardell
(83 rep)
Dec 14, 2022, 12:03 AM
• Last activity: Dec 31, 2022, 07:58 PM
1
votes
0
answers
159
views
A/D pins always read max (1023)
I am using the Aria G25 board from Acme Systems. I have their Terra board breakout. I have also asked this question on their google groups but thought it might be a more general issue so have posted here as well. I have built the ADC into the kernel (not as module) based on this guide: http://www.at...
I am using the Aria G25 board from Acme Systems. I have their Terra board breakout. I have also asked this question on their google groups but thought it might be a more general issue so have posted here as well. I have built the ADC into the kernel (not as module) based on this guide:
http://www.at91.com/linux4sam/bin/view/Linux4SAM/IioAdcDriver
At startup I am able to grep for iio and get:
root@acmeboard:~# dmesg | grep iio
iio iio:device0: Resolution used: 10 bits
iio iio:device0: ADC Touch screen is disabled.
After startup I have the appropriate sysfs structure:
root@acmeboard:~# ls -l /sys/bus/iio/devices/iio\:device0/
total 0
drwxr-xr-x 2 root root 0 Jan 1 01:06 buffer
-r--r--r-- 1 root root 4096 Jan 1 01:06 dev
-rw-r--r-- 1 root root 4096 Jan 1 01:01 in_voltage0_raw
-rw-r--r-- 1 root root 4096 Jan 1 01:01 in_voltage1_raw
-rw-r--r-- 1 root root 4096 Jan 1 01:01 in_voltage2_raw
-rw-r--r-- 1 root root 4096 Jan 1 01:01 in_voltage3_raw
-rw-r--r-- 1 root root 4096 Jan 1 01:06 in_voltage_scale
-r--r--r-- 1 root root 4096 Jan 1 01:06 name
drwxr-xr-x 2 root root 0 Jan 1 01:06 power
drwxr-xr-x 2 root root 0 Jan 1 01:06 scan_elements
lrwxrwxrwx 1 root root 0 Jan 1 01:06 subsystem -> ../../../../../bus/iio
drwxr-xr-x 2 root root 0 Jan 1 01:06 trigger
-rw-r--r-- 1 root root 4096 Jan 1 01:06 uevent
However when attempting to read the ADC value I always get 1023 (I have a potentiometer connected on one of their breakout boards, so I would expect to not read the max):
root@acmeboard:~# cat /sys/bus/iio/devices/iio\:device0/in_voltage0_raw
1023
I am relatively new to linux and sysfs so I could be missing something simple. Other point of interest. If I read the same pin (W20 on Aria) as a digital GPIO it appears to work. Spinning the pot I eventually read 0 and then 1 going the other way. Do I some how need to disable the GPIO functionality for this pin?
Finally here is the relevant lines in the DTS file (only thing I've changed):
adc0: adc@f804c000 {
status = "okay";
atmel,adc-channels-used = ;
atmel,adc-num-channels = ;
compatible = "atmel,at91sam9x5-adc";
atmel,adc-startup-time = ;
atmel,adc-status-register = ;
atmel,adc-trigger-register = ;
atmel,adc-use-external;
atmel,adc-vref = ;
atmel,adc-res = ;
atmel,adc-res-names = "lowres", "highres";
atmel,adc-use-res = "highres";
trigger@0 {
trigger-name = "continuous";
trigger-value = ;
};
};
DeusAduro
(123 rep)
Oct 2, 2015, 06:40 AM
• Last activity: Dec 31, 2022, 07:56 PM
6
votes
2
answers
7570
views
Change iio-sensors data via custom ACCEL_MOUNT_MATRIX
I have a tablet with builtin sensors which allow me automatic screen rotation, based on `iio-sensors-proxy`. However, the screen orientation is off, and I need to fix it. On it's GitHub page (https://github.com/systemd/systemd/blob/master/hwdb/60-sensor.hwdb) is explained how to change this behavior...
I have a tablet with builtin sensors which allow me automatic screen rotation, based on
iio-sensors-proxy
. However, the screen orientation is off, and I need to fix it.
On it's GitHub page (https://github.com/systemd/systemd/blob/master/hwdb/60-sensor.hwdb) is explained how to change this behavior: Create a file /etc/udev/hwdb.d/61-sensor-local.hwdb
and write to it
sensor:modalias::dmi:
and
ACCEL_MOUNT_MATRIX=1, 0, 0; 0, 1, 0; 0, 0, 1
(this matrix has to be changed ofc).
# Problem : I have no idea how to get the neccessary information for the first line, the sensor-prefix.
# Solution : Final file contains:
sensor:modalias:acpi:KIOX000A*:dmi:*:svnEVE*:pnEveV:*
ACCEL_MOUNT_MATRIX=0, 1, 0; -1, 0, 0; 0, 0, 1
What I've found so far:
This gives me device name:
udevadm info --export-db | grep iio
P: /devices/pci0000:00/0000:00:15.0/i2c_designware.0/i2c-0/i2c-KIOX000A:00/iio:device0
N: iio:device0
E: DEVNAME=/dev/iio:device0
E: DEVPATH=/devices/pci0000:00/0000:00:15.0/i2c_designware.0/i2c-0/i2c-KIOX000A:00/iio:device0
E: DEVTYPE=iio_device
E: IIO_SENSOR_PROXY_TYPE=iio-buffer-accel
E: SUBSYSTEM=iio
E: SYSTEMD_WANTS=iio-sensor-proxy.service
This gives me more info about the device:
udevadm info -n "/dev/iio:device0"
P: /devices/pci0000:00/0000:00:15.0/i2c_designware.0/i2c-0/i2c-KIOX000A:00/iio:device0
N: iio:device0
E: DEVNAME=/dev/iio:device0
E: DEVPATH=/devices/pci0000:00/0000:00:15.0/i2c_designware.0/i2c-0/i2c-KIOX000A:00/iio:device0
E: DEVTYPE=iio_device
E: IIO_SENSOR_PROXY_TYPE=iio-buffer-accel
E: MAJOR=245
E: MINOR=0
E: SUBSYSTEM=iio
E: SYSTEMD_WANTS=iio-sensor-proxy.service
E: TAGS=:systemd:
E: USEC_INITIALIZED=1959744
And via pci I find the so-called modalias:
cat /sys/devices/pci0000:00/0000:00:15.0/modalias
pci:v00008086d00009D60sv00008086sd00007270bc11sc80i00
Would really appreciate help from here on!
---
My system: Linux jva 4.14.5-1-ARCH #1 SMP PREEMPT Sun Dec 10 14:50:30 UTC 2017 x86_64 GNU/Linux running under GNOME 3.26.2 (Wayland-seesion)
Tablet: Eve V i7Y
vonAlenberg
(163 rep)
Dec 14, 2017, 09:18 AM
• Last activity: Dec 31, 2022, 07:56 PM
0
votes
1
answers
503
views
Is there a way to expose extra settings through sysfs using the IIO framework?
The driver I'm developing has a number of settings I want the user to be able to change that don't really fit into the IIO framework. For example, using the IIO_CHAN_INFO_SAMP_FREQ enum in my read function exposes a variable in /sys/bus/iio/devices/iio:device0/ called "in_voltage_sampling_frequency"...
The driver I'm developing has a number of settings I want the user to be able to change that don't really fit into the IIO framework. For example, using the IIO_CHAN_INFO_SAMP_FREQ enum in my read function exposes a variable in /sys/bus/iio/devices/iio:device0/ called "in_voltage_sampling_frequency" that allows the user to change the frequency on-the-go. I would also like to be able to pass in different modes (a string) through a similar mechanism. How would I do this? It doesn't look like the IIO interface supports ioctl calls.
So in short, what I want is a mechanism to expose a variable called "timer_mode" through IIO, that people could pass a string into that my driver can use.
z470
(101 rep)
Jun 4, 2015, 07:55 PM
• Last activity: Dec 31, 2022, 07:55 PM
1
votes
0
answers
540
views
How to properly read from a sensor with libiio?
I am trying to read one sample from a sensor using libiio, but for some reason I always get the same sample unless I restart the application. Here is a minimal example ```c #include #include #include #include #include /* Global objects */ static struct iio_buffer *device_buffer = NULL; static struct...
I am trying to read one sample from a sensor using libiio, but for some reason I always get the same sample unless I restart the application.
Here is a minimal example
#include
#include
#include
#include
#include
/* Global objects */
static struct iio_buffer *device_buffer = NULL;
static struct iio_channel *channel = NULL;
static struct iio_context *local_ctx = NULL;
static struct iio_device *dev = NULL;
static const char *dev_name = NULL;
static const char *channel_id = NULL;
static uint8_t *in_buf;
int main()
{
/* Getting local iio device context */
local_ctx = iio_create_local_context();
dev = iio_context_get_device(local_ctx, 0);
dev_name = iio_device_get_name(dev);
channel = iio_device_get_channel(dev, 0);
iio_channel_enable(channel);
if (iio_channel_is_enabled(channel))
return -1;
uint32_t sample_size = 3;
uint32_t buffer_length = 1;
struct iio_buffer *device_buffer =
iio_device_create_buffer(dev, buffer_length, false);
if (!device_buffer)
return -1;
while (true) {
ssize_t nbytes_rx = iio_buffer_refill(device_buffer);
if (nbytes_rx <= 0) {
printf("Error refilling buf %d\n", (int) nbytes_rx);
return -1;
}
in_buf = (uint8_t*)malloc(sample_size * buffer_length);
iio_channel_read(channel, device_buffer, in_buf, sample_size * buffer_length);
printf("%" PRIi32 "\n", ((int32_t *)in_buf));
free(in_buf);
}
}
In the actual code I am properly error checking, handling SIGINT and destroying all the buffers. Everything works. The only issue is that the same sample is printed over and over, whereas I would assume the buffer to get refilled and a new sample to get printed.
neolith
(273 rep)
Dec 27, 2022, 07:14 PM
• Last activity: Dec 27, 2022, 10:23 PM
Showing page 1 of 9 total questions