epeters13 / pyLoraRFM9x

Fork of the raspi-lora project with improved interrupt handling and reset support
MIT License
7 stars 9 forks source link

Multiply zero by int? #3

Closed martynwheeler closed 3 years ago

martynwheeler commented 3 years ago

I am looking at porting this library to micropython. While looking over the code I noticed an odd feature:

I was wondering why you had multiplied zero by a length in the function _spi_read "[register] + [0] * length, maybe it is me misunderstanding spidev but it seems unnecessary? Is is a left over from debugging?

    def _spi_read(self, register, length=1):
        if length == 1:
            with self._hw_lock:
                d = self.spi.xfer([register] + [0] * length)[1]            
            return d
        else:
            with self._hw_lock:
                d = self.spi.xfer([register] + [0] * length)[1:]
            return d