versionsprüfung

This commit is contained in:
Tristan Krause 2019-06-28 14:21:10 +02:00
parent ae6920cdf9
commit d7179914ad
68 changed files with 189 additions and 89 deletions

View file

@ -42,7 +42,7 @@ OBJECTS_CLI = cli.o ui/view.o ui/view_selection.o ui/view_promt.o ui/view_info
all: drv cli
drv: $(OBJECTS_DRV) $(OUT_TMP_DRV)
drv: commit_hash $(OBJECTS_DRV) $(OUT_TMP_DRV)
cli: drv $(OBJECTS_CLI)
@ -55,6 +55,11 @@ doc: style
@echo "Creating documentation with doxygen..."
$(PATH_DOXYGEN) doxygen-cfg
@echo problems found: `($(PATH_DOXYGEN) doxygen-cfg 3>&2 2>&1 1>&3) 2>/dev/null | wc -l`
$(OUT_TMP_DRV):
@echo "Linking driver library..."
@mkdir -p ../lib
$(PATH_COMPILER) $(CFLAGS) $(OBJECTS_DRV) -shared -o $(OUT_TMP_DRV) $(LDFLAGS_CLI_DRV)
style:
@echo "Formatting source code with astyle..."
@ -87,10 +92,9 @@ clean:
-rm -rf $(OUT_DOC)
-find . -type f -name '*.orig' -delete
commit_hash:
@echo "Updating commit hash..."
@bash -c 'echo -e "#ifndef COMMIT_HASH_H\n#define COMMIT_HASH_H\nconst char COMMIT_HASH[] = \"`git log --pretty=format:'%H' -n 1`\";\n#endif // COMMIT_HASH_H" > commit_hash.h'
.cpp.o:
$(PATH_COMPILER) $(CFLAGS) -c $< -o $@
$(OUT_TMP_DRV):
@echo "Linking driver library..."
@mkdir -p ../lib
$(PATH_COMPILER) $(CFLAGS) $(OBJECTS_DRV) -shared -o $(OUT_TMP_DRV) $(LDFLAGS_CLI_DRV)

View file

@ -0,0 +1,4 @@
#ifndef COMMIT_HASH_H
#define COMMIT_HASH_H
const char COMMIT_HASH[] = "ae6920cdf9fed20780ed671c86150b00283c67b6";
#endif // COMMIT_HASH_H

View file

@ -119,8 +119,8 @@ std::vector<std::string> B15F::getBoardInfo(void)
usart.receive(&len, 0, sizeof(len));
char str[len + 1];
str[len] = '\0';
usart.receive(reinterpret_cast<uint8_t *>(&str[0]), 0, len);
str[len] = '\0';
info.push_back(std::string(str));
}
@ -686,4 +686,14 @@ void B15F::init()
std::vector<std::string> info = getBoardInfo();
std::cout << PRE << "AVR Firmware Version: " << info[0] << " um " << info[1] << " Uhr (" << info[2] << ")"
<< std::endl;
// Überprüfe Version
std::string& avr_commit_hash = info[3];
if(avr_commit_hash.compare(COMMIT_HASH))
{
std::cout << PRE << "Unterschiedliche commit hashes: " << std::endl;
std::cout << std::string(PRE.length(), ' ') << "AVR: " << avr_commit_hash << std::endl;
std::cout << std::string(PRE.length(), ' ') << "Control: " << COMMIT_HASH << std::endl << std::endl;
abort("Versionen inkompatibel. Bitte Software aktualisieren!");
}
}

View file

@ -15,6 +15,7 @@
#include <sys/ioctl.h>
#include <termios.h>
#include "../commit_hash.h"
#include "requests.h"
#include "usart.h"
#include "driverexception.h"