User Tools

Site Tools


odroid_c2_pps

[Start] [Cat] [About] [Syntax] [Scraps]


https://www.ntpsec.org/white-papers/stratum-1-microserver-howto/clockmaker

class OdroidC2:
    "Odroid C2 capabilities"
    # See: http://forum.odroid.com/viewtopic.php?f=136&t=21733&p=147199#p147199
    mf = "/etc/modprobe.d/pps-gpio.conf"
    options = "options pps-gpio gpio_pin="
    gpio_re = re.compile(options + "([0-9]*)")

    def __init__(self):
        self.name = "Odroid C2"
        self.gpsdev = "ttyS1"
        self.default_login = "odroid"
        self.gpiomap = (("Adafruit", 249),
                        ("Uputronics", 238),
                        ("SKU 42425", 228))
        self.revision_dict = {}

    @staticmethod
    def identify_me():
        return "ODROID-C2" in open("/proc/cpuinfo").read()

    def get_pps_gpio(self):
        if not os.path.exists(OdroidC2.mf):
            return None
        else:
            with open(OdroidC2.mf) as rp:
                config_txt = rp.read()
            m = OdroidC2.gpio_re.search(config_txt)
            if m:
                return dict([(str(y), x) for (x, y) in
                            self.gpiomap])[m.group(1)]
            else:
                return None

    def set_pps_gpio(self, newpin):
        with open("/etc/modules-load.d/pps-gpio.conf", "w") as wp:
            wp.write("pps-gpio\n")
        with open(OdroidC2.mf, "w") as wp:
            wp.write(OdroidC2.options + str(newpin) + "\n")
        os.system("modprobe")
        
odroid_c2_pps.txt ยท Last modified: 2024/11/14 02:30 by 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki