add: controller_info version reading
This commit is contained in:
parent
d8ad2c205a
commit
270c87e0bc
1 changed files with 14 additions and 3 deletions
|
@ -4,7 +4,8 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <uuid/uuid.h>
|
#include <uuid/uuid.h>
|
||||||
|
|
||||||
#include "controller.h"
|
#include <models/controller.h>
|
||||||
|
#include <models/controller_file_reader.h>
|
||||||
#include <macros.h>
|
#include <macros.h>
|
||||||
|
|
||||||
|
|
||||||
|
@ -32,7 +33,7 @@ controller*
|
||||||
controller_read(void)
|
controller_read(void)
|
||||||
{
|
{
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
controller *result;;
|
controller *result;
|
||||||
|
|
||||||
fp = fopen(CONTROLLER_FILE_NAME, "rb");
|
fp = fopen(CONTROLLER_FILE_NAME, "rb");
|
||||||
|
|
||||||
|
@ -50,6 +51,7 @@ controller_read(void)
|
||||||
read_size = fread(header, sizeof(*header), CONTROLLER_FILE_HEADER_SIZE, fp);
|
read_size = fread(header, sizeof(*header), CONTROLLER_FILE_HEADER_SIZE, fp);
|
||||||
if(ferror(fp) || read_size != CONTROLLER_FILE_HEADER_SIZE)
|
if(ferror(fp) || read_size != CONTROLLER_FILE_HEADER_SIZE)
|
||||||
{
|
{
|
||||||
|
fclose(fp);
|
||||||
LOG_ERROR("Error reading header");
|
LOG_ERROR("Error reading header");
|
||||||
result = controller_create();
|
result = controller_create();
|
||||||
|
|
||||||
|
@ -59,8 +61,17 @@ controller_read(void)
|
||||||
uint8_t version = header[0];
|
uint8_t version = header[0];
|
||||||
printf("%d\n", version);
|
printf("%d\n", version);
|
||||||
|
|
||||||
|
switch(version)
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
controller_file_reader_1(fp);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
fclose(fp);
|
||||||
|
LOG_ERROR("Error unsupported version number");
|
||||||
|
|
||||||
// size_t fread(void *ptr, size_t size_of_elements, size_t number_of_elements, FILE *a_file);
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue