def _get_mode(self):
        buf = array.array('B', [0])

        # Get mode
        try:
            fcntl.ioctl(self._fd, SPI._SPI_IOC_RD_MODE, buf, True)
        except __HOLE__ as e:
            raise SPIError(e.errno, "Getting SPI mode: " + e.strerror)

        return buf[0] & 0x3
dataset/ETHPy150Open vsergeev/python-periphery/periphery/spi.py/SPI._get_mode