doceme / py-spidev

MIT License
459 stars 205 forks source link

Type interface to writebytes not clear #118

Open PeterWurmsdobler opened 3 years ago

PeterWurmsdobler commented 3 years ago

Hello,

first, thanks for providing this library that allows accessing devices over SPI in python; that is very convenient.

The name of the method writebytes alludes to the data type needing to be some kind of unsigned char or some uint8 from the ctypes. Having written code around this assumption I found that I always go a TypeError: Non-In/Long value in argument. Going through the c-code I realised that there a converion to __u8 is being performed. So my assumption was wrong.

Bottom line, it appears that writebytes accepts a list of int rather than bytes which are then cast to an unsigned 8 bit quantity. I wonder whether that could be made clearer in the documentation.

Cheers, peter.

doceme commented 1 year ago

Can you provide some sample code that demonstrates this problem?