doceme / py-spidev

MIT License
461 stars 203 forks source link

Conflict with spidev 3.5 and kernel 5.4.51 using Raspberry Pi and luma.led_matrix #106

Closed linuxminty closed 2 years ago

linuxminty commented 4 years ago

Following a recent upgrade to kernel 5.4.51 on my Raspberry Pi, I got the following error when trying to run luma.led_matrix:

Traceback (most recent call last):
  File "luma7datetime.py", line 58, in <module>
    main()
  File "luma7datetime.py", line 47, in main
    serial = spi(port=0, device=0, gpio=noop())
  File "/usr/local/lib/python3.7/dist-packages/luma/core/interface/serial.py", line 285, in __init__
    self._spi.cshigh = cs_high
SystemError: error return without exception set

rm-hull has solved the issue for me by suggesting a downgrade to spi 3.4. For details see: https://github.com/rm-hull/luma.led_matrix/issues/225

Although the problem has been resolved for me by reverting to spidev 3.4, it seems appropriate to open an issue here so that you're aware of this conflict with spidev 3.5.

Gadgetoid commented 4 years ago

The use of cshigh is no longer supported by the underlying ioctls, IE: no change will occur, so when spidev attempts to read back the chain it will fail in this manner.

I raised this upstream for an explanation, see: https://github.com/raspberrypi/linux/issues/3745

If a display genuinely requires cshigh to be True (I think False is the default?) then I believe manual, GPIO Chip-Select control would be required independent of the SPI drivers.

Spidev 3.4 doesn't fix the problem so much as fail silently. I'm going to hazard a guess in your case that cs_high is False, and thus the fact that changing this property is silently failing will have no bearing on your hardware.

I don't think anything should necessary change in spidev, but the code that checks whether cshigh (aka SPI_CS_HIGH) has been successfully set should probably fail with a slightly clearer exception.