1
0
mirror of https://github.com/binary-kitchen/doorlockd synced 2024-11-16 12:09:10 +01:00
doorlockd-mirror/scripts/gen_protocol.sh
Ralf Ramsauer e27f6d02da pydoorlock: autogenerate Protocol.py
Signed-off-by: Ralf Ramsauer <ralf@binary-kitchen.de>
2019-06-14 21:37:47 +02:00

36 lines
696 B
Bash
Executable File

#!/bin/bash
#
# doorlock-avr, AVR code of Binary Kitchen's doorlock
#
# Copyright (c) Binary Kitchen, 2019
#
# Authors:
# Ralf Ramsauer <ralf@binary-kitchen.de>
#
# This work is licensed under the terms of the GNU GPL, version 2. See
# the COPYING file in the top-level directory.
PROTOCOL_H=$1
function find_defines() {
header=$1
prefix=$2
search="#define\s\+${prefix}\(\S*\)\s\+\(\S*\).*"
replace=" \1\t= b\2"
grep $prefix $header | sed -e "s/$search/$replace/"
}
AVR_COMM=$(find_defines $PROTOCOL_H AVR_)
cat <<END
# This file is autogenerated. If you need to change it, edit
# scripts/gen_protocol.sh instead.
from enum import Enum
class Protocol(Enum):
${AVR_COMM}
END