Skip to content

Instantly share code, notes, and snippets.

@howientc
howientc / xiobase.py
Created June 18, 2016 00:40
Gets the base of XIOs on C.H.I.P. computers. Currently on 4.3, it's 408, and on 4.4 it's 1016. This calculates it dynamically
import os
GPIO_PATH = "/sys/class/gpio" # The root of the GPIO directories
EXPANDER = "pcf8574a" # This is the expander that is used on CHIP for the XIOs
def get_xio_base():
'''
Determines the base of the XIOs on the system by iterating through the /sys/class/gpio
directory and looking for the expander that is used. It then looks for the
"base" file and returns its contents as an integer