JohnpeiW
Posts: 1
Joined: Thu Jul 23, 2020 5:04 pm

mcp3422 IIO Driver reads incorrect channel when polled by multiple programs/threads

Thu Jul 23, 2020 5:30 pm

Rpi 4
Linux raspberrypi 4.19.127-v7l
#1 SMP Tue Jul 7 16:03:29 PDT 2020 armv7l GNU/Linux

when I read any channels with a threaded program OR multiple programs that just read the file
The values between channels get switched, copied and overwritten, just from reads.

I'm using C style read
/sys/bus/iio/devices/iio\:device1/in_voltage0_raw
..in_voltage1_raw
..in_voltage2_raw
..in_voltage3_raw

when I read a specific channel with one program, no problem

I found a similar IIO driver problem https://www.toradex.com/community/quest ... alues.html

Heres a little ncurses program that just reads each file @ 100ms
Image
With one program reading the channels no problem the channels all read the correct values

Heres what happens when 3 programs are running. 2 programs also produces the error just less frequently.
Image
With multiple programs reading the values get copied and overwritten

I started to notice this as soon as I added one more thread to a main program and I can reproduce it by reading from even just 1 channel with multiple programs.

I looked over the driver for maybe interrupt based issues, but it doesn't use interrupts so i'm at a bit of a loss
https://git.toradex.com/cgit/linux-tora ... d2598d0892

Return to “Advanced users”