Start protocol support mapping

parent 8d2f0bff
Byte Value Description
00 0xE0 High Nibble : Command
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
......
......@@ -37,12 +37,12 @@ PKTTIMEOUT=2 # Seconds
def checkSumCalc(message):
checksum = 0
return chr(sum(map(ord, m)) % 256)
return chr(sum(map(ord, message)) % 256)
def checkSumTest(message):
if len(message) == 37:
if message[36] == checkSumCalc(message[:36])
if message[36] == checkSumCalc(message[:36]):
return True
return False
......
###########################################################################
# Copyright (c) 2018- Franco (nextime) Lanza <franco@nexlab.it>
#
# Penguidom System client Daemon "penguidomd" [https://git.nexlab.net/domotika/Penguidom]
#
# This file is part of penguidom.
#
# penguidom is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import ctypes
c_uint8 = ctypes.c_uint8
class LowNibble_bits( ctypes.LittleEndianStructure ):
_fields_ = [
("evt_disable", c_uint8, 1 ),
("alarm", c_uint8, 1 ),
("winload", c_uint8, 1 ),
("neware", c_uint8, 1 ),
]
class Flags( ctypes.Union ):
_anonymous_ = ("bit",)
_fields_ = [
("bit", LowNibble_bits ),
("asByte", c_uint8 )
]
"""
flags = Flags()
flags.asByte = 0xe2
print( "event_disable: %i" % flags.evt_disable )
print( "alarm: %i" % flags.alarm )
print( "winload : %i" % flags.winload )
print( "neware : %i" % flags.neware )
"""
CMD_EVENT = 0xe
def checkCmd(byte, cmd):
return (byte >> 4) == cmd
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment