You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: rfid.py
+12-2
Original file line number
Diff line number
Diff line change
@@ -96,10 +96,20 @@ def CRC_16_IBM(self, data):
96
96
listString[4:8] =struct.pack('<H', code).encode('hex') # switch order to little endian and return unsigned short, then replace characters in list with the CRC values
97
97
return"".join(listString)
98
98
99
-
defadd_user(self, badge):
99
+
defadd_user(self, badge, doors):
100
100
ifnotisinstance(badge, int):
101
101
raiseTypeError("RFID number must be set to an integer")
102
102
103
+
ifnotisinstance(doors, list):
104
+
raiseException("doors must be set to a list")
105
+
106
+
# create a list of "01"'s (enabled) and "00"'s (disabled), then later join to create "01000000" (which is only door 1 enabled)
107
+
doorsList= []
108
+
doorsList.append("01") if1indoorselsedoorsList.append("00") # door 1
109
+
doorsList.append("01") if2indoorselsedoorsList.append("00") # door 2
110
+
doorsList.append("01") if3indoorselsedoorsList.append("00") # door 3
111
+
doorsList.append("01") if4indoorselsedoorsList.append("00") # door 4
112
+
103
113
badge=struct.pack('<I', badge).encode('hex') # pack as little endian integer
0 commit comments