Skip to content

Commit

Permalink
Merge pull request #28 from vapor-ware/mhink-lock-board2
Browse files Browse the repository at this point in the history
Support rev2 door lock hardware. vec and gpio handles are singletons.
  • Loading branch information
MatthewHink committed Jan 25, 2018
2 parents b0f9df9 + 4090bae commit 1b78cd9
Show file tree
Hide file tree
Showing 3 changed files with 550 additions and 642 deletions.
21 changes: 8 additions & 13 deletions synse/devicebus/devices/i2c/rci3525_lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
\/apor IO
-------------------------------
Copyright (C) 2015-17 Vapor IO
Copyright (C) 2015-18 Vapor IO
This file is part of Synse.
Expand All @@ -26,8 +26,6 @@
import logging
import sys

import lockfile

import synse.strings as _s_
from synse.devicebus.constants import CommandId as cid
from synse.devicebus.response import Response
Expand All @@ -54,8 +52,6 @@ def __init__(self, **kwargs):
self._command_map[cid.READ] = self._read
self._command_map[cid.LOCK] = self._lock_function

self._lock = lockfile.LockFile(self.serial_lock)

self.channel = int(kwargs['channel'], 16)

self.board_id = int(kwargs['board_offset']) + int(kwargs['board_id_range'][0])
Expand Down Expand Up @@ -151,14 +147,13 @@ def _direct_sensor_read(self):
Returns:
dict: Key is lock_status. Data are:
0 - Electrically unlocked and mechanically unlocked.
1 - Electrically unlocked and mechanically locked.
2 - Electrically locked and mechanically unlocked.
1 - Electrically locked and mechanically unlocked.
2 - Electrically unlocked and mechanically locked.
3 - Electrically locked and mechanically locked.
"""
with self._lock:
logger.debug('RCI3525Lock _direct_sensor_read: {}')
reading = i2c_common.lock_status(self.lock_number)
return {'lock_status': reading}
logger.debug('RCI3525Lock _direct_sensor_read: {}')
reading = i2c_common.lock_status(self.lock_number)
return {'lock_status': reading}

# Needs to be called something other than _lock since that is self._lock is
# a lockfile in subclasses of I2CDevice.
Expand Down Expand Up @@ -224,10 +219,10 @@ def _return_lock_status(self, action):
# caller.
if action == 'lock':
# Set bit 1 to denote electrically locked.
reading['lock_status'] = reading['lock_status'] | 0x2
reading['lock_status'] = reading['lock_status'] | 0x1
elif action == 'unlock' or action == 'momentary_unlock':
# Clear bit 1 to denote electrically unlocked.
reading['lock_status'] = reading['lock_status'] & 0xFD
reading['lock_status'] = reading['lock_status'] & 0xFE
else:
raise SynseException('Invalid action provided for lock control.')
return reading

0 comments on commit 1b78cd9

Please sign in to comment.