doceme / py-spidev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Type interface to writebytes not clear

PeterWurmsdobler opened this issue · comments

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.

Can you provide some sample code that demonstrates this problem?