Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
P
Penguidom
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
domotika
Penguidom
Commits
8e84257a
Commit
8e84257a
authored
Jan 06, 2018
by
Franco (nextime) Lanza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
start checksumming and parsing messages
parent
5a6ea953
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
103 additions
and
15 deletions
+103
-15
Paradox_37byte_protocol.txt
penguidom/plugins/paradox/Paradox_37byte_protocol.txt
+46
-0
paradox.py
penguidom/plugins/paradox/paradox.py
+57
-15
paradox_serial_protocol.png
penguidom/plugins/paradox/paradox_serial_protocol.png
+0
-0
No files found.
penguidom/plugins/paradox/Paradox_37byte_protocol.txt
0 → 100644
View file @
8e84257a
Byte Value Description
00 0xE0 High Nibble : Command
Low Nibble : Bit 3 - Event Report Enable (0) / Disable (1)
01 0xXX Century
02 0xXX Year
03 0xXX Month
04 0xXX Day
05 0xXX Hour
06 0xXX Minute
07 0xXX Event Group Number
08 0xXX Event Sub Group Number
09 0xXX Partition Number
10 0xXX Module Serial Number (Digit 1 and 2)
11 0xXX Module Serial Number (Digit 3 and 4)
12 0xXX Module Serial Number (Digit 5 and 6)
13 0xXX Module Serial Number (Digit 6 and 8)
14 0xXX Label Type
0 = Zone Label
1 = User Label
2 = Partition Label
3 = PGM Label
4 = Bus Module Label
5 = Wireless Repeater Label
6 = Wireless Keypad Label
15 0xXX Module / User / Partition Label Byte 00
16 0xXX Module / User / Partition Label Byte 01
17 0xXX Module / User / Partition Label Byte 02
18 0xXX Module / User / Partition Label Byte 03
19 0xXX Module / User / Partition Label Byte 04
20 0xXX Module / User / Partition Label Byte 05
21 0xXX Module / User / Partition Label Byte 06
22 0xXX Module / User / Partition Label Byte 07
23 0xXX Module / User / Partition Label Byte 08
24 0xXX Module / User / Partition Label Byte 09
25 0xXX Module / User / Partition Label Byte 10
26 0xXX Module / User / Partition Label Byte 11
27 0xXX Module / User / Partition Label Byte 12
28 0xXX Module / User / Partition Label Byte 13
29 0xXX Module / User / Partition Label Byte 14
30 0xXX Module / User / Partition Label Byte 15
31 0xXX Not Used (Reserved)
32 0xXX Not Used (Reserved)
33 0xXX Not Used (Reserved)
34 0xXX Not Used (Reserved)
35 0xXX Not Used (Reserved)
36 0xXX Checksum
penguidom/plugins/paradox/paradox.py
View file @
8e84257a
...
@@ -6,23 +6,29 @@ from twisted.internet.serialport import SerialPort
...
@@ -6,23 +6,29 @@ from twisted.internet.serialport import SerialPort
from
twisted.internet.protocol
import
BaseProtocol
from
twisted.internet.protocol
import
BaseProtocol
from
twisted.internet
import
reactor
from
twisted.internet
import
reactor
import
serial
import
serial
import
time
SERIAL_PORT
=
"/dev/ttyUSB0"
SERIAL_PORT
=
"/dev/ttyUSB0"
BAUDRATE
=
9600
BAUDRATE
=
9600
PKTTIMEOUT
=
2
# Seconds
def
format37ByteMessage
(
message
):
def
checkSumCalc
(
message
):
checksum
=
0
checksum
=
0
return
chr
(
sum
(
map
(
ord
,
m
))
%
256
)
if
len
(
message
)
%
37
!=
0
:
for
val
in
message
:
checksum
+=
ord
(
val
)
while
checksum
>
255
:
checksum
=
checksum
-
(
checksum
/
256
)
*
256
message
+=
bytes
(
bytearray
([
checksum
]))
# Add check to end of message
def
checkSumTest
(
message
):
if
len
(
message
)
==
37
:
if
message
[
36
]
==
checkSumCalc
(
message
[:
36
])
return
True
return
False
def
format37ByteMessage
(
message
):
checksum
=
0
message
=
message
.
ljust
(
36
,
'
\x00
'
)
if
len
(
message
)
%
37
!=
0
:
message
+=
checkSumCalc
(
message
)
# Add check to end of message
return
message
return
message
...
@@ -30,17 +36,38 @@ class ParadoxProtocol(BaseProtocol):
...
@@ -30,17 +36,38 @@ class ParadoxProtocol(BaseProtocol):
packet
=
[]
packet
=
[]
queue
=
[]
packettimeout
=
0
waitreply
=
0
def
__init__
(
self
,
logger
,
core
):
def
__init__
(
self
,
logger
,
core
):
self
.
log
=
logger
self
.
log
=
logger
self
.
core
=
core
self
.
core
=
core
def
dataReceived
(
self
,
data
):
def
_queueData
(
self
):
if
len
(
self
.
packet
)
<
37
:
self
.
packet
+=
[
data
]
if
len
(
self
.
packet
)
>=
37
:
if
len
(
self
.
packet
)
>=
37
:
self
.
log
.
debug
(
"RECEIVED: "
+
str
(
self
.
packet
))
if
self
.
waitreply
>
0
:
self
.
packet
=
[]
self
.
waitreply
-=
1
packet
=
""
.
join
(
self
.
packet
[:
37
])
self
.
log
.
debug
(
"MESSAGE QUEUED: "
+
''
.
join
(
[
"
\\
x
%02
X"
%
ord
(
x
)
for
x
in
packet
]
)
.
strip
())
#+str(packet).encode("hex"))
print
packet
self
.
queue
+=
[
packet
]
self
.
packet
=
self
.
packet
[
37
:]
reactor
.
callLater
(
0
,
self
.
_queueData
)
reactor
.
callLater
(
0
,
self
.
_processQueue
)
elif
len
(
self
.
packet
)
>
0
:
self
.
packettimeout
=
time
.
time
()
def
_processQueue
(
self
):
pass
def
dataReceived
(
self
,
data
):
if
len
(
self
.
packet
)
>
0
and
(
time
.
time
()
-
self
.
packettimeout
)
>
PKTTIMEOUT
:
self
.
log
.
debug
(
"Serial Timeout: discard packet "
+
''
.
join
(
[
"
\\
x
%02
X"
%
ord
(
x
)
for
x
in
self
.
packet
]
)
.
strip
())
self
.
packet
=
[]
self
.
packet
+=
list
(
data
)
self
.
_queueData
()
def
connectionMade
(
self
):
def
connectionMade
(
self
):
...
@@ -48,8 +75,23 @@ class ParadoxProtocol(BaseProtocol):
...
@@ -48,8 +75,23 @@ class ParadoxProtocol(BaseProtocol):
self
.
login
()
self
.
login
()
def
login
(
self
):
def
login
(
self
):
message
=
'
\x72\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
'
#message = '\x72\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
self
.
transport
.
write
(
format37ByteMessage
(
message
))
message
=
'
\x72
'
self
.
write
(
message
)
message
=
'
\x50\x00\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
'
self
.
write
(
message
)
message
=
'
\x5f\x20\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
'
self
.
write
(
message
)
def
write
(
self
,
message
):
if
self
.
waitreply
==
0
:
self
.
transport
.
write
(
format37ByteMessage
(
message
))
self
.
waitreply
+=
1
else
:
reactor
.
callLater
(
0
,
self
.
write
,
message
)
class
Paradox
(
object
):
class
Paradox
(
object
):
implements
(
IPlugin
,
imodules
.
IModules
)
implements
(
IPlugin
,
imodules
.
IModules
)
...
...
penguidom/plugins/paradox/paradox_serial_protocol.png
0 → 100644
View file @
8e84257a
51.3 KB
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment