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
d890ecf6
Commit
d890ecf6
authored
Jan 07, 2018
by
Franco (nextime) Lanza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Starting to build 37 byte protocol support lib
parent
d4ddef56
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
96 additions
and
24 deletions
+96
-24
Paradox_37byte_protocol.txt
penguidom/plugins/paradox/docs/Paradox_37byte_protocol.txt
+0
-0
paradox_serial_protocol.png
penguidom/plugins/paradox/docs/paradox_serial_protocol.png
+0
-0
paradox.py
penguidom/plugins/paradox/paradox.py
+12
-23
paradox37b.py
penguidom/plugins/paradox/paradox37b.py
+84
-1
No files found.
penguidom/plugins/paradox/Paradox_37byte_protocol.txt
→
penguidom/plugins/paradox/
docs/
Paradox_37byte_protocol.txt
View file @
d890ecf6
File moved
penguidom/plugins/paradox/paradox_serial_protocol.png
→
penguidom/plugins/paradox/
docs/
paradox_serial_protocol.png
View file @
d890ecf6
File moved
penguidom/plugins/paradox/paradox.py
View file @
d890ecf6
...
...
@@ -30,30 +30,13 @@ from twisted.internet import reactor
import
serial
import
time
import
paradox37b
as
p37b
SERIAL_PORT
=
"/dev/ttyUSB0"
BAUDRATE
=
9600
PKTTIMEOUT
=
2
# Seconds
def
checkSumCalc
(
message
):
checksum
=
0
return
chr
(
sum
(
map
(
ord
,
message
))
%
256
)
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
class
ParadoxProtocol
(
BaseProtocol
):
...
...
@@ -65,6 +48,7 @@ class ParadoxProtocol(BaseProtocol):
def
__init__
(
self
,
logger
,
core
):
self
.
log
=
logger
self
.
core
=
core
reactor
.
addSystemEventTrigger
(
'before'
,
'shutdown'
,
self
.
_terminating
)
def
_queueData
(
self
):
if
len
(
self
.
packet
)
>=
37
:
...
...
@@ -96,10 +80,15 @@ class ParadoxProtocol(BaseProtocol):
self
.
log
.
info
(
"Serial port correctly connected"
)
self
.
login
()
def
_terminating
(
self
,
*
a
,
**
kw
):
self
.
log
.
debug
(
"Send Disconnect message"
)
self
.
write
(
p37b
.
MSG_DISCONNECT
)
def
connectionLost
(
self
,
reason
):
self
.
log
.
debug
(
"Connection lost for "
+
str
(
reason
))
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
'
self
.
write
(
message
)
self
.
write
(
p37b
.
MSG_LOGIN
)
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
)
...
...
@@ -109,7 +98,7 @@ class ParadoxProtocol(BaseProtocol):
def
write
(
self
,
message
):
if
self
.
waitreply
==
0
:
self
.
transport
.
write
(
format37ByteMessage
(
message
))
self
.
transport
.
write
(
p37b
.
format37ByteMessage
(
message
))
self
.
waitreply
+=
1
else
:
reactor
.
callLater
(
0
,
self
.
write
,
message
)
...
...
penguidom/plugins/paradox/paradox37b.py
View file @
d890ecf6
...
...
@@ -48,9 +48,92 @@ print( "winload : %i" % flags.winload )
print( "neware :
%
i"
%
flags.neware )
"""
CMD_EVENT
=
0xe
# This is the only message type we fully know how to parse, and lucky enough
# they are also really what you need to have.
# Byte Value Description
# 00 0xEX High Nibble : Command
# Low Nibble : Bit 3 - Event Report Enable (0) / Disable (1)
# Bit 2 - System in alarm
# Bit 1 - Winload connected
# Bit 0 - NEware connected
# 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
def
checkCmd
(
byte
,
cmd
):
return
(
byte
>>
4
)
==
cmd
# XXX I don't really like i don't fully understand
# the meaning of some messages (yet?), but those are needed and i know
# what the give me back at least.
#
# To save computational timing there is no need to format those messages
# at runtime, as they are static, so, full string included here.
MSG_LOGIN
=
'
\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
'
MSG_DISCONNECT
=
'
\x70\x00\x05\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\x01\x00\x00\x76
'
def
checkSumCalc
(
message
):
checksum
=
0
return
chr
(
sum
(
map
(
ord
,
message
))
%
256
)
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
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