periph icon indicating copy to clipboard operation
periph copied to clipboard

sysfs-spi: half duplex fails

Open bodokaiser opened this issue 7 years ago • 3 comments

When passing spi.HalfDuplex as parameter to spidev.Connect(...) I get

sysfs-spi: setting mode Mode3|HalfDuplex failed: invalid argument

I was able to track the error down to this line:

https://github.com/google/periph/blob/a72045d66f9be001cc8da21c9f67ef35d54f1675/host/sysfs/spi.go#L299

Any ideas what goes wrong over here?

Variables found op=92929 and arg=19 and

// yields 1073834753
op|0x40000000

// yields 284528680
uintptr(unsafe.Pointer(&arg))

tracked this down to

https://github.com/google/periph/blob/a72045d66f9be001cc8da21c9f67ef35d54f1675/host/fs/fs_linux.go#L12

bodokaiser avatar Apr 25 '18 11:04 bodokaiser

Maybe the driver didn't want it? I haven't tested this flag at all. :(

maruel avatar Apr 25 '18 20:04 maruel

I wonder about the error code? Further the kernel docs actually say that half duplex is enabled per default.

Any suggestions how I could test this detached from go / periph.io? What docs did you use for spi maybe I can write a c file to test.

bodokaiser avatar Apr 25 '18 20:04 bodokaiser

I looked at /usr/include/linux/spi/spidev.h on my workstation and built a small C program to confirm the values.

maruel avatar Apr 25 '18 20:04 maruel

I'll close this issue since it is quite old. If this persists please reopen at https://github.com/periph/host. Thanks!

maruel avatar Sep 20 '23 17:09 maruel