@@ -69,7 +69,10 @@ def __init__(self):
69
69
self .__checkFilesystemExport__ (pin )
70
70
if gpio_library :
71
71
gpio_library .setmode (gpio_library .ASUS )
72
- else :
72
+ elif not Hardware ().isRaspberryPi3 ():
73
+ # On the Pi 3 the memory mapped /dev/gpiomem file seems to give strange, inconsistent readings, like duplicated
74
+ # 4 byte sequences and "oipg" ASCII values. This might be some issue with the way Python mmap works since it didn't
75
+ # seem to happen with the wiringPi C library using uint32_t pointers. For now we just avoid using /dev/gpiomem on Pi 3.
73
76
try :
74
77
with open ('/dev/gpiomem' , 'rb' ) as gpiomem :
75
78
self .gpio_map = mmap .mmap (gpiomem .fileno (), BLOCK_SIZE , prot = mmap .PROT_READ )
@@ -350,31 +353,31 @@ def getFunction(self, channel):
350
353
return self .__getFunction__ (channel )
351
354
352
355
def getFunctionString (self , channel ):
353
- f = self . getFunction ( channel )
356
+ f = - 1
354
357
function_string = 'UNKNOWN'
355
358
functions = {0 :'IN' , 1 :'OUT' , 2 :'ALT5' , 3 :'ALT4' , 4 :'ALT0' , 5 :'ALT1' , 6 :'ALT2' , 7 :'ALT3' , 8 :'PWM' ,
356
359
40 :'SERIAL' , 41 :'SPI' , 42 :'I2C' , 43 :'PWM' , 44 :'GPIO' , 45 :'TS_XXXX' , 46 :'RESERVED' , 47 :'I2S' }
357
- if f >= 0 :
358
- try :
359
- function_string = functions [f ]
360
- except :
361
- pass
362
- try :
363
- # On Raspberry Pis using the spi_bcm2835 driver SPI chip select is done via software rather than hardware
364
- # so the pin function is OUT instead of ALT0. Here we override that (and the I2C to be safe) so the GPIO map
365
- # in the UI will display the appropriate pin info.
366
- if channel in self .spi_pins and self .system_config ['SPI' ] == 1 :
367
- function_string = functions [4 ]
368
- if channel in self .i2c_pins and self .system_config ['I2C' ] == 1 :
369
- function_string = functions [4 ]
370
- except :
371
- pass
372
- try :
373
- # If 1-Wire is enabled specify the pin function as a device tree overlay.
374
- if channel in self .overlay_pins :
375
- function_string = 'OVERLAY'
376
- except :
377
- pass
360
+ try :
361
+ f = self . getFunction ( channel )
362
+ function_string = functions [f ]
363
+ except :
364
+ pass
365
+ try :
366
+ # On Raspberry Pis using the spi_bcm2835 driver SPI chip select is done via software rather than hardware
367
+ # so the pin function is OUT instead of ALT0. Here we override that (and the I2C to be safe) so the GPIO map
368
+ # in the UI will display the appropriate pin info.
369
+ if channel in self .spi_pins and self .system_config ['SPI' ] == 1 :
370
+ function_string = functions [4 ]
371
+ if channel in self .i2c_pins and self .system_config ['I2C' ] == 1 :
372
+ function_string = functions [4 ]
373
+ except :
374
+ pass
375
+ try :
376
+ # If 1-Wire is enabled specify the pin function as a device tree overlay.
377
+ if channel in self .overlay_pins :
378
+ function_string = 'OVERLAY'
379
+ except :
380
+ pass
378
381
return function_string
379
382
380
383
def setPinMapping (self ):
0 commit comments