Ejemplo n.º 1
0
def setDigitalMap(index=0, direction="out"):
    helper.ShellCommand("echo '{}' > {}/unexport".format(index, GPIO_SYSFS),
                        exit=False)
    helper.ShellCommand("echo '{}' > {}/export".format(index, GPIO_SYSFS),
                        exit=False)
    helper.ShellCommand(command="echo '{}' > {}/gpio{}/direction".format(
        direction, GPIO_SYSFS, index),
                        exit=False)
Ejemplo n.º 2
0
 def set_configure(self, index=0, direction="out", drive="strong"):
     ## Direction
     self.index = index
     helper.ShellCommand("echo '{}' > {}/export".format(
         self.index, GPIO_SYSFS),
                         exit=False)
     helper.ShellCommand(command="echo '{}' > {}/gpio{}/direction".format(
         direction, GPIO_SYSFS, index),
                         exit=False)
    def set_value(self, value):
        logging.info("Set Value (Index : {}, Value {}".format(
            self.index, value))
        logging.info("echo '{}' > {}{}/value".format(value, GPIO_SYSFS,
                                                     self.index))
        helper.ShellCommand(command="echo '{}' > {}{}/value".format(
            value, GPIO_SYSFS, self.index),
                            exit=True)

        result = self.cursor.execute(
            "UPDATE pinmap SET V={} WHERE phy={}".format(value, self.index),
            "")
        self.mydb.commit()
 def get_value(self):
     result = helper.ShellCommand(command="cat {}{}/value".format(
         GPIO_SYSFS, self.index),
                                  exit=True)
     logging.info("cat {}{}/value".format(GPIO_SYSFS, self.index))
     return result
Ejemplo n.º 5
0
def read(index=0):
    result = helper.ShellCommand(command="cat {}gpio{}/value".format(
        GPIO_SYSFS, index),
                                 exit=True)
    return result["out"].decode("utf-8")
Ejemplo n.º 6
0
def write(index=0, value=True):
    logging.info("Set Value (Index : {}, Value {}".format(index, value))
    logging.info("echo '{}' > {}gpio{}/value".format(value, GPIO_SYSFS, index))
    helper.ShellCommand(command="echo '{}' > {}gpio{}/value".format(
        value, GPIO_SYSFS, index),
                        exit=True)