rust-spidev icon indicating copy to clipboard operation
rust-spidev copied to clipboard

Better documenation for Os { code: 90, kind: Other, message: "Message too long" }', libcore/result.rs:945:5?

Open caemor opened this issue 6 years ago • 1 comments

When I was finally able to test my progress with my library on hardware once more, I got the error from above. Since the only thing that returns error in my code is the SPI::Error, the error must come from here although the backtrace doesn't say much ( https://gist.github.com/rust-play/72982da05d7226a34b8794afac9ee20a)

After a day of debugging I finally realised the only the thing that i changed was, that I transmitted the full buffer for most of the operations at once now to the spi. After some more research this morning I found out, that the default limit for SPI is 4096 bytes on most linux systems. (https://raspberrypi.stackexchange.com/questions/65595/spi-transfer-fails-with-buffer-size-greater-than-4096).

Is it possible to...

  • ... automatically split the buffer when it's bigger than 4096 bytes inside the write implemenation? This would need some sort of variable, because sometimes people change the default spi size
  • ... add a warning in the documentation that there is a default limit of 4096 bytes for most linux systems?

caemor avatar Oct 12 '18 08:10 caemor

@caemor Right now the lib seeks to provide a safe but still relatively basic (easy to reason about) interface to the Linux kernel's spidev interface. Splitting messages, reloading the kernel module, etc. might be strategies that makes sense for some applications but are unlikely to be applicable in general.

Adding docs to the lib calling out the edge case is probably the best way forward. For write (which still seems useful to provide) we need to stick with io::Error and it seems reasonable to stick with it for transfer as well right now but perhaps revisit if other cases arise. I'd have to do a deep look at the kernel code to figure out, in practice, which errors are likely to be encountered.

posborne avatar Oct 06 '21 20:10 posborne