コード例 #1
0
ファイル: i2c.py プロジェクト: tonywaite/scs_host_rpi
    def start_tx(cls, device):
        if cls.__FR is None or cls.__FW is None:
            raise RuntimeError("I2C.start_tx: bus is not open.")

        Lock.acquire(cls.__name__, 1.0)

        fcntl.ioctl(cls.__FR, I2C.__I2C_SLAVE, device)
        fcntl.ioctl(cls.__FW, I2C.__I2C_SLAVE, device)
コード例 #2
0
    def open(self, lock_timeout, comms_timeout):
        # lock...
        Lock.acquire(self.__lock_name, lock_timeout)

        # port...
        self._ser = serial.Serial(port=self.device_identifier, baudrate=self._baud_rate, timeout=comms_timeout)

        time.sleep(0.5)     # as GE910 - 0.3
コード例 #3
0
    def start_tx(self, device):
        if self.__fr is None or self.__fw is None:
            self.open_for_bus(self.__bus)

        Lock.acquire(self.__class__.__name__, self.__LOCK_TIMEOUT)

        fcntl.ioctl(self.__fr, self.__I2C_SLAVE, device)
        fcntl.ioctl(self.__fw, self.__I2C_SLAVE, device)
コード例 #4
0
    def close(self):
        try:
            # port...
            if self._ser:
                self._ser.close()
                self._ser = None

        finally:
            # lock...
            Lock.release(self.__lock_name)
コード例 #5
0
    def open(self, lock_timeout, comms_timeout):
        # lock...
        Lock.acquire(self.__lock_name, lock_timeout)

        # serial...
        self._ser = serial.Serial(port=self.port,
                                  baudrate=self._baud_rate,
                                  timeout=comms_timeout,
                                  parity=serial.PARITY_NONE,
                                  stopbits=serial.STOPBITS_ONE,
                                  bytesize=serial.EIGHTBITS)
コード例 #6
0
    def open(self, lock_timeout, comms_timeout):
        # lock...
        Lock.acquire(self.__lock_name, lock_timeout)

        # port...
        self._ser = serial.Serial(port=self._device_identifier,
                                  baudrate=self._baud_rate,
                                  timeout=comms_timeout,
                                  parity=serial.PARITY_NONE,
                                  stopbits=serial.STOPBITS_ONE,
                                  bytesize=serial.EIGHTBITS)

        time.sleep(0.5)  # as GE910 - 0.3
コード例 #7
0
ファイル: io.py プロジェクト: RawPlutonium/scs_dfe_eng
    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))
コード例 #8
0
ファイル: io.py プロジェクト: RawPlutonium/scs_dfe_eng
    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))
コード例 #9
0
ファイル: ads1115.py プロジェクト: RawPlutonium/scs_dfe_eng
 def obtain_lock(self):
     Lock.acquire(self.__lock_name, ADS1115.__LOCK_TIMEOUT)
コード例 #10
0
 def start_tx(self):
     Lock.acquire(self.__lock_name(Modem.__LOCK_PWR), Modem.__LOCK_TIMEOUT)
コード例 #11
0
 def obtain_lock(cls):
     Lock.acquire(cls.__lock_name(), DS1338.__LOCK_TIMEOUT)
コード例 #12
0
"""
Created on 16 Apr 2017

@author: Bruno Beloff ([email protected])
"""

from scs_host.lock.lock import Lock

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

Lock.init()
コード例 #13
0
 def obtain_lock(cls):
     Lock.acquire(cls.__name__, SPINDIRx1.__LOCK_TIMEOUT)
コード例 #14
0
 def obtain_lock(cls):
     Lock.acquire(cls.__name__, OPCN2.__LOCK_TIMEOUT)
コード例 #15
0
 def end_tx(self):
     Lock.release(self.__class__.__name__)
コード例 #16
0
#!/usr/bin/env python3
"""
Created on 17 Mar 2017

@author: Bruno Beloff ([email protected])
"""

import os

from scs_host.lock.lock import Lock

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

resource = "test"

print("resource: %s" % resource)
print("pid: %s" % os.getpid())

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

print("attempt 1...")
Lock.acquire(resource, 2)
print("OK")
print("-")

print("attempt 2...")
Lock.acquire(resource, 2)
print("OK")
print("-")
コード例 #17
0
 def obtain_lock(self):
     Lock.acquire(self.lock_name, self.lock_timeout())
コード例 #18
0
 def obtain_lock(self):
     Lock.acquire(self.__class__.__name__, MCP342X.__LOCK_TIMEOUT)
コード例 #19
0
 def release_lock(self):
     Lock.release(self.lock_name)
コード例 #20
0
 def acquire_lock(self):
     Lock.acquire(self.__lock_name, SPI.__LOCK_TIMEOUT)
コード例 #21
0
 def release_lock(cls):
     Lock.release(cls.__name__)
コード例 #22
0
ファイル: i2c.py プロジェクト: tonywaite/scs_host_rpi
 def end_tx(cls):
     Lock.release(cls.__name__)
コード例 #23
0
 def release_lock(self):
     Lock.release(self.__class__.__name__)
コード例 #24
0
ファイル: ge910.py プロジェクト: RawPlutonium/scs_comms_ge910
 def start_tx(self):
     Lock.acquire(self.__lock_name(GE910.__LOCK_TX), GE910.__LOCK_TIMEOUT)
コード例 #25
0
 def release_lock(cls):
     Lock.release(cls.__lock_name())
コード例 #26
0
ファイル: ge910.py プロジェクト: RawPlutonium/scs_comms_ge910
 def end_tx(self):
     Lock.release(self.__lock_name(GE910.__LOCK_TX))
コード例 #27
0
 def end_tx(self):
     Lock.release(self.__lock_name(Modem.__LOCK_PWR))
コード例 #28
0
"""

import os
import time

from scs_host.lock.lock import Lock

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

print("pid:%d" % os.getpid())

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

name = "TestLock"

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

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

print("-")

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

Lock.acquire(name, 4.0)

print("locked...")

try:
    exists = Lock.exists(name)