#NEWLINE# def _set_extra_flags( self , extra_flags ) : #NEWLINE# #INDENT# if ( not isinstance ( extra_flags , int ) ) : #NEWLINE# #INDENT# raise TypeError ( 'Invalid extra_flags type, should be integer.' ) #NEWLINE# #UNINDENT# if ( ( extra_flags < 0 ) or ( extra_flags > 255 ) ) : #NEWLINE# #INDENT# raise ValueError ( 'Invalid extra_flags, must be 0-255.' ) #NEWLINE# #UNINDENT# buf = array . array ( 'B' , [ 0 ] ) #NEWLINE# try : #NEWLINE# #INDENT# fcntl . ioctl ( self . _fd , SPI . _SPI_IOC_RD_MODE , buf , True ) #NEWLINE# #UNINDENT# except OSError as e : #NEWLINE# #INDENT# raise SPIError ( e . errno , ( 'Getting SPI mode: ' + e . strerror ) ) #NEWLINE# #UNINDENT# buf [ 0 ] = ( ( buf [ 0 ] & ( ( SPI . _SPI_LSB_FIRST | SPI . _SPI_CPHA ) | SPI . _SPI_CPOL ) ) | extra_flags ) #NEWLINE# try : #NEWLINE# #INDENT# fcntl . ioctl ( self . _fd , SPI . _SPI_IOC_WR_MODE , buf , False ) #NEWLINE# #UNINDENT# except OSError as e : #NEWLINE# #INDENT# raise SPIError ( e . errno , ( 'Setting SPI mode: ' + e . strerror ) )