Example #1
0
    def close(self):
        try:
            # port...
            if self._ser:
                self._ser.close()
                self._ser = None

        finally:
            # lock...
            Lock.release(self.__lock_name)
Example #2
0
    def __get_output(self, mask):
        if self.__device is None:
            return None

        Lock.acquire(IO.__lock_name(IO.__LOCK), IO.__LOCK_TIMEOUT)

        try:
            byte = self.__device.state.byte

            return bool(byte & mask)

        finally:
            Lock.release(IO.__lock_name(IO.__LOCK))
Example #3
0
    def __set_output(self, mask, level):
        if self.__device is None:
            return

        Lock.acquire(IO.__lock_name(IO.__LOCK), IO.__LOCK_TIMEOUT)

        try:
            byte = self.__device.state.byte

            if level:
                byte |= mask
            else:
                byte &= ~mask

            self.__device.write(byte)
            self.__device.state = byte

        finally:
            Lock.release(IO.__lock_name(IO.__LOCK))
Example #4
0
 def end_tx(self):
     Lock.release(self.__lock_name(Modem.__LOCK_PWR))
Example #5
0
 def release_lock(cls):
     Lock.release(cls.__lock_name())
Example #6
0
 def release_lock(self):
     Lock.release(self.__class__.__name__)
 def release_lock(cls):
     Lock.release(cls.__name__)
Example #8
0
 def release_lock(self):
     Lock.release(self.lock_name)
Example #9
0
 def end_tx(self):
     Lock.release(self.__lock_name(GE910.__LOCK_TX))
Example #10
0
 def end_tx(cls):
     Lock.release(cls.__name__)
Example #11
0
 def end_tx(self):
     Lock.release(self.__class__.__name__)
Example #12
0
print("pid: %s" % str(pid))

print("-")

# --------------------------------------------------------------------------------------------------------------------

Lock.acquire(name, 4.0)

print("locked...")

try:
    exists = Lock.exists(name)
    print("exists: %s" % exists)

    pid = Lock.pid(name)
    print("pid: %s" % str(pid))

    print("-")

    while True:
        time.sleep(1)

except KeyboardInterrupt:
    pass

finally:
    Lock.release(name)

    print()
    print("unlocked")