1
0
mirror of https://github.com/binary-kitchen/doorlockd synced 2024-12-22 10:24:26 +01:00
doorlockd-mirror/scripts/gen_protocol.sh

36 lines
696 B
Bash
Raw Normal View History

#!/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