Skip to content

Commit

Permalink
Add dynamic parameter request option to C3_GetDeviceParam
Browse files Browse the repository at this point in the history
  • Loading branch information
vwout committed Dec 30, 2023
1 parent 980c14e commit e8e2458
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 19 deletions.
2 changes: 1 addition & 1 deletion c3/controldevice.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class ControlDeviceBase(ABC):
Param 3: 0 (null)
Operation 3: Enable/disable normal open state
Param 1: Door number
Param 2: Enable / disable (0: disable, 1: enable'
Param 2: Enable / disable (0: disable, 1: enable)
Param 3: 0 (null)
"""

Expand Down
3 changes: 1 addition & 2 deletions c3/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from dataclasses import dataclass, field
from typing import Dict, Optional

# import consts
from c3 import consts, controldevice, crc, rtlog, utils


Expand Down Expand Up @@ -182,7 +181,7 @@ def _receive(self) -> tuple[bytearray, int, int]:
message = self._get_message(header + payload)

if len(message) != data_size:
raise ValueError(f"Length of received message ({len(message)}) does not match specified size ({data_size})")
raise ValueError(f"Length of received message ({len(message)}) doesn't match specified ({data_size})")

if received_command == consts.C3_REPLY_OK:
pass
Expand Down
4 changes: 2 additions & 2 deletions cli/C3_CancelAlarms.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
import argparse
import logging
import sys
from c3 import C3
from c3 import controldevice

from c3 import C3, controldevice


def main():
Expand Down
1 change: 1 addition & 0 deletions cli/C3_Discover.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import argparse
import logging
import sys

from c3 import C3


Expand Down
21 changes: 12 additions & 9 deletions cli/C3_GetDeviceParam.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import argparse
import logging
import sys

from c3 import C3
from c3.utils import C3DateTime

Expand All @@ -10,6 +11,7 @@ def main():
parser = argparse.ArgumentParser()
parser.add_argument('host', help='C3 panel IP address or host name')
parser.add_argument('--password', help='Password')
parser.add_argument('--param', nargs='+', help='Parameter name(s) to request')
args = parser.parse_args()

print("Connecting to %s" % args.host)
Expand All @@ -22,15 +24,16 @@ def main():
print("Device:")
print(repr(panel))

params = panel.get_device_param(["~ZKFPVersion",
"~SerialNumber",
"FirmVer",
"DeviceName",
"LockCount",
"ReaderCount",
"AuxInCount",
"AuxOutCount",
"DateTime"])
param_names = args.param or ["~ZKFPVersion",
"~SerialNumber",
"FirmVer",
"DeviceName",
"LockCount",
"ReaderCount",
"AuxInCount",
"AuxOutCount",
"DateTime"]
params = panel.get_device_param(param_names)

for k in params:
if k == "DateTime":
Expand Down
4 changes: 2 additions & 2 deletions cli/C3_GetRTLog.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import logging
import sys
import time
from c3 import C3
from c3 import rtlog

from c3 import C3, rtlog


def main():
Expand Down
5 changes: 2 additions & 3 deletions cli/C3_OutputOperation.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
import argparse
import logging
import sys
from c3 import C3
from c3 import consts
from c3 import controldevice

from c3 import C3, consts, controldevice


def main():
Expand Down

0 comments on commit e8e2458

Please sign in to comment.