From f977752ee2ee67825b6267b0a86a3fe88d592687 Mon Sep 17 00:00:00 2001 From: Shlomo Hecht Date: Sat, 2 Feb 2019 23:46:36 +0200 Subject: try improved real time handling in control - not tested yet --- .../Embedded_SW/Embedded/Modules/Control/control.c | 41 ++++++++++++++++------ 1 file changed, 31 insertions(+), 10 deletions(-) (limited to 'Software/Embedded_SW/Embedded/Modules') diff --git a/Software/Embedded_SW/Embedded/Modules/Control/control.c b/Software/Embedded_SW/Embedded/Modules/Control/control.c index 984db7329..8349e7f91 100644 --- a/Software/Embedded_SW/Embedded/Modules/Control/control.c +++ b/Software/Embedded_SW/Embedded/Modules/Control/control.c @@ -56,7 +56,7 @@ #include "MillisecTask.h" /******************** Definitions ********************************************/ #define INVALID_MSG_ID 0xFFFF -#define MAX_TANGO_CONTROL_DEVICES 80 +#define MAX_TANGO_CONTROL_DEVICES 100 /******************** STRUCTURES AND ENUMs ********************************************/ @@ -94,9 +94,11 @@ static GateMutex_Handle gateControlDB; Task_Handle Control_Task_Handle; ControlDeviceStruc ControlArray[MAX_TANGO_CONTROL_DEVICES]; uint32_t ControlDatalog[MAX_TANGO_CONTROL_DEVICES]; -uint16_t ControlBacklog[1000]={0}; +#define MAX_BACKLOG_SIZE 100 +uint16_t ControlBacklog[MAX_BACKLOG_SIZE]={0}; uint16_t backlogindex = 0; uint32_t Control_timerBase = TIMER0_BASE; //Timer handle +uint32_t MaxHighDevices = 0; /******************** Functions ********************************************/ void OneMilliSecondFunction(UArg arg0); @@ -122,7 +124,7 @@ void ControlInit(void) ControlRestart = false; memset(ControlDatalog,0,sizeof(uint32_t)*MAX_TANGO_CONTROL_DEVICES); - + MaxHighDevices = 0; for (Device_i = 0; Device_i < MAX_TANGO_CONTROL_DEVICES; Device_i++) { ControlArray[Device_i].ControlActive = false; @@ -206,14 +208,31 @@ uint32_t AddControlCallback( ControlCBFunction Callback, CTRL_TIMING_ENUM CtrlF uint32_t device_i; uint32_t deviceId = 0xFF; - for(device_i = 0;device_i < MAX_TANGO_CONTROL_DEVICES;device_i++) + if (CtrlFrequency == eOneMillisecond) + { + for(device_i = 0;device_i < MAX_TANGO_CONTROL_DEVICES;device_i++) + { + if (ControlArray[device_i].ControlActive == false) + { + deviceId = device_i; + break; + } + } + if ((deviceId!=0xFF )&&(deviceId> MaxHighDevices)) + MaxHighDevices = deviceId; + } + else { - if (ControlArray[device_i].ControlActive == false) + for(device_i = MAX_TANGO_CONTROL_DEVICES-1;device_i >=0;device_i--) { - deviceId = device_i; - break; + if (ControlArray[device_i].ControlActive == false) + { + deviceId = device_i; + break; + } } } + if (deviceId == 0xFF) { LOG_ERROR(deviceId, "Add Callback failed"); @@ -329,12 +348,12 @@ uint32_t ControlLoop(uint32_t tick) Tick998 = (tick%eOneSecond == 996) ?true:false; */ //ROM_IntMasterDisable(); - for (ControlDevice_i = 0; ControlDevice_i < MAX_TANGO_CONTROL_DEVICES;ControlDevice_i++) + for (ControlDevice_i = 0; ControlDevice_i < MaxHighDevices;ControlDevice_i++) { if (ControlArray[ControlDevice_i].ControlActive) { ControlBacklog[backlogindex]=ControlDevice_i; - if ( ++backlogindex >= 999) + if ( ++backlogindex >= MAX_BACKLOG_SIZE) backlogindex = 0; switch (ControlArray[ControlDevice_i].ControlTiming) { @@ -377,10 +396,12 @@ uint32_t ControlLowLoop(uint32_t tick) { if (tick == ControlArray[ControlLowDevice_i].StartTick) continue; + if (ControlArray[ControlLowDevice_i].ControlTiming == eOneMillisecond) + continue; if (((tick - ControlArray[ControlLowDevice_i].StartTick)%ControlArray[ControlLowDevice_i].ControlTiming)==0) // run the control on exact intervals { ControlBacklog[backlogindex]=ControlLowDevice_i; - if ( ++backlogindex >= 999) + if ( ++backlogindex >= MAX_BACKLOG_SIZE) backlogindex = 0; if(ControlArray[ControlLowDevice_i].ControlDataReadPtr) -- cgit v1.3.1 From c72eff42c5aec18513b3ec9d92486ec02a6a716b Mon Sep 17 00:00:00 2001 From: Shlomo Hecht Date: Sun, 3 Feb 2019 08:54:15 +0200 Subject: file names short form --- .../Embedded/Common/SWUpdate/FileSystem.c | 55 ++--- .../Embedded/Common/protobuf-c/person-pb-c.c | 227 --------------------- .../Embedded/Common/protobuf-c/person-pb-c.h | 112 ---------- .../Embedded/Drivers/FPGA/FPGA_GPIO/FPGA_GPIO.c | 1 - .../Embedded/Modules/General/GeneralHardware.c | 2 +- .../Embedded/Modules/IDS/IDS_dispenser.c | 2 +- 6 files changed, 32 insertions(+), 367 deletions(-) delete mode 100644 Software/Embedded_SW/Embedded/Common/protobuf-c/person-pb-c.c delete mode 100644 Software/Embedded_SW/Embedded/Common/protobuf-c/person-pb-c.h (limited to 'Software/Embedded_SW/Embedded/Modules') diff --git a/Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c b/Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c index dc9bac054..ce36f57e6 100644 --- a/Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c +++ b/Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c @@ -91,6 +91,11 @@ uint32_t FileUploadRequestFunc(MessageContainer* requestContainer) strcpy(FileHandleChar, "1234"); response.uploadid = FileHandleChar; //supporting only single file at each time. } + else + { + free (FileHandle); + FileHandle = 0; + } } @@ -382,6 +387,7 @@ uint32_t GetStorageInfoRequestFunc(MessageContainer* requestContainer) response.capacity = tot_sect/2; response.has_freespace = true; response.freespace = fre_sect/2; + response.root = "0:"; } @@ -413,6 +419,7 @@ uint32_t GetFilesRequestFunc(MessageContainer* requestContainer) #define MAX_NUM_OF_FILES 10 DIR dir; FILINFO* fno[MAX_NUM_OF_FILES]; + char FullPath[MAX_NUM_OF_FILES][50]; int i,NumOfFiles = 0; FRESULT Fresult = FR_OK; @@ -429,36 +436,24 @@ uint32_t GetFilesRequestFunc(MessageContainer* requestContainer) fno[0] = my_malloc(sizeof(FILINFO)); memset (fno[0],0,sizeof(FILINFO)); - Fresult = f_stat(request->path,fno[0]); - if (Fresult == FR_OK) - { - if (isDirectory(fno[0]->fattrib)) - { - NumOfFiles++; - //============================ - Fresult = f_opendir(&dir, request->path); /* Open the directory */ + //============================ + Fresult = f_opendir(&dir, request->path); /* Open the directory */ + if (Fresult == FR_OK) + { + for (NumOfFiles = 1;NumOfFiles < MAX_NUM_OF_FILES;NumOfFiles++) + { + fno[NumOfFiles] = my_malloc(sizeof(FILINFO)); + memset (fno[NumOfFiles],0,sizeof(FILINFO)); + Fresult = f_readdir(&dir, fno[NumOfFiles]); /* Read a directory item */ if (Fresult == FR_OK) { - for (NumOfFiles = 1;NumOfFiles < MAX_NUM_OF_FILES;NumOfFiles++) + if(fno[NumOfFiles]->fname[0] ==0) { - fno[NumOfFiles] = my_malloc(sizeof(FILINFO)); - memset (fno[NumOfFiles],0,sizeof(FILINFO)); - Fresult = f_readdir(&dir, fno[NumOfFiles]); /* Read a directory item */ - if (Fresult == FR_OK) - { - if(fno[NumOfFiles]->fname[0] ==0) - { - break; - } - } + break; } } - } - else - { - Fresult = FR_DENIED; - } - } + } + } if ((Fresult == FR_OK)&&(NumOfFiles)) { @@ -474,6 +469,16 @@ uint32_t GetFilesRequestFunc(MessageContainer* requestContainer) Data[i].length = fno[i]->fsize; Data[i].lastmodifieddate = fno[i]->fdate; Data[i].lastmodifiedtime = fno[i]->ftime; + //strcpy(FullPath[i],request->path); + //strcat(FullPath[i],'\\'); + //strcat(FullPath[i],&fno[i]->fname); + //sprintf (FullPath[i], "%s/%s", request->path, &fno[i]->fname); + if (i==0) + usnprintf(&FullPath[i], 50, "%s", request->path); + else + usnprintf(&FullPath[i], 50, "%s%c%c%s", request->path,'\\','\\'/*"/"*/, fno[i]->fname); + Data[i].fullpath = &FullPath[i]; + } response.n_items = NumOfFiles; response.items = FilesInfo; diff --git a/Software/Embedded_SW/Embedded/Common/protobuf-c/person-pb-c.c b/Software/Embedded_SW/Embedded/Common/protobuf-c/person-pb-c.c deleted file mode 100644 index 7493ef609..000000000 --- a/Software/Embedded_SW/Embedded/Common/protobuf-c/person-pb-c.c +++ /dev/null @@ -1,227 +0,0 @@ -/* Generated by the protocol buffer compiler. DO NOT EDIT! */ -/* Generated from: person.proto */ - -/* Do not generate deprecated warnings for self */ -#ifndef PROTOBUF_C__NO_DEPRECATED -#define PROTOBUF_C__NO_DEPRECATED -#endif - -#include "person-pb-c.h" -void address__init - (Address *message) -{ - static const Address init_value = ADDRESS__INIT; - *message = init_value; -} -size_t address__get_packed_size - (const Address *message) -{ - assert(message->base.descriptor == &address__descriptor); - return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); -} -size_t address__pack - (const Address *message, - uint8_t *out) -{ - assert(message->base.descriptor == &address__descriptor); - return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); -} -size_t address__pack_to_buffer - (const Address *message, - ProtobufCBuffer *buffer) -{ - assert(message->base.descriptor == &address__descriptor); - return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); -} -Address * - address__unpack - (ProtobufCAllocator *allocator, - size_t len, - const uint8_t *data) -{ - return (Address *) - protobuf_c_message_unpack (&address__descriptor, - allocator, len, data); -} -void address__free_unpacked - (Address *message, - ProtobufCAllocator *allocator) -{ - if(!message) - return; - assert(message->base.descriptor == &address__descriptor); - protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); -} -void person__init - (Person *message) -{ - static const Person init_value = PERSON__INIT; - *message = init_value; -} -size_t person__get_packed_size - (const Person *message) -{ - assert(message->base.descriptor == &person__descriptor); - return protobuf_c_message_get_packed_size ((const ProtobufCMessage*)(message)); -} -size_t person__pack - (const Person *message, - uint8_t *out) -{ - assert(message->base.descriptor == &person__descriptor); - return protobuf_c_message_pack ((const ProtobufCMessage*)message, out); -} -size_t person__pack_to_buffer - (const Person *message, - ProtobufCBuffer *buffer) -{ - assert(message->base.descriptor == &person__descriptor); - return protobuf_c_message_pack_to_buffer ((const ProtobufCMessage*)message, buffer); -} -Person * - person__unpack - (ProtobufCAllocator *allocator, - size_t len, - const uint8_t *data) -{ - return (Person *) - protobuf_c_message_unpack (&person__descriptor, - allocator, len, data); -} -void person__free_unpacked - (Person *message, - ProtobufCAllocator *allocator) -{ - if(!message) - return; - assert(message->base.descriptor == &person__descriptor); - protobuf_c_message_free_unpacked ((ProtobufCMessage*)message, allocator); -} -static const ProtobufCFieldDescriptor address__field_descriptors[2] = -{ - { - "street", - 1, - PROTOBUF_C_LABEL_OPTIONAL, - PROTOBUF_C_TYPE_STRING, - 0, /* quantifier_offset */ - offsetof(Address, street), - NULL, - NULL, - 0, /* flags */ - 0,NULL,NULL /* reserved1,reserved2, etc */ - }, - { - "number", - 2, - PROTOBUF_C_LABEL_OPTIONAL, - PROTOBUF_C_TYPE_INT32, - offsetof(Address, has_number), - offsetof(Address, number), - NULL, - NULL, - 0, /* flags */ - 0,NULL,NULL /* reserved1,reserved2, etc */ - }, -}; -static const unsigned address__field_indices_by_name[] = { - 1, /* field[1] = number */ - 0, /* field[0] = street */ -}; -static const ProtobufCIntRange address__number_ranges[1 + 1] = -{ - { 1, 0 }, - { 0, 2 } -}; -const ProtobufCMessageDescriptor address__descriptor = -{ - PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, - "Address", - "Address", - "Address", - "", - sizeof(Address), - 2, - address__field_descriptors, - address__field_indices_by_name, - 1, address__number_ranges, - (ProtobufCMessageInit) address__init, - NULL,NULL,NULL /* reserved[123] */ -}; -static const ProtobufCFieldDescriptor person__field_descriptors[4] = -{ - { - "name", - 1, - PROTOBUF_C_LABEL_OPTIONAL, - PROTOBUF_C_TYPE_STRING, - 0, /* quantifier_offset */ - offsetof(Person, name), - NULL, - NULL, - 0, /* flags */ - 0,NULL,NULL /* reserved1,reserved2, etc */ - }, - { - "age", - 2, - PROTOBUF_C_LABEL_OPTIONAL, - PROTOBUF_C_TYPE_INT32, - offsetof(Person, has_age), - offsetof(Person, age), - NULL, - NULL, - 0, /* flags */ - 0,NULL,NULL /* reserved1,reserved2, etc */ - }, - { - "email", - 3, - PROTOBUF_C_LABEL_OPTIONAL, - PROTOBUF_C_TYPE_STRING, - 0, /* quantifier_offset */ - offsetof(Person, email), - NULL, - NULL, - 0, /* flags */ - 0,NULL,NULL /* reserved1,reserved2, etc */ - }, - { - "address", - 4, - PROTOBUF_C_LABEL_REPEATED, - PROTOBUF_C_TYPE_MESSAGE, - offsetof(Person, n_address), - offsetof(Person, address), - &address__descriptor, - NULL, - 0, /* flags */ - 0,NULL,NULL /* reserved1,reserved2, etc */ - }, -}; -static const unsigned person__field_indices_by_name[] = { - 3, /* field[3] = address */ - 1, /* field[1] = age */ - 2, /* field[2] = email */ - 0, /* field[0] = name */ -}; -static const ProtobufCIntRange person__number_ranges[1 + 1] = -{ - { 1, 0 }, - { 0, 4 } -}; -const ProtobufCMessageDescriptor person__descriptor = -{ - PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, - "Person", - "Person", - "Person", - "", - sizeof(Person), - 4, - person__field_descriptors, - person__field_indices_by_name, - 1, person__number_ranges, - (ProtobufCMessageInit) person__init, - NULL,NULL,NULL /* reserved[123] */ -}; diff --git a/Software/Embedded_SW/Embedded/Common/protobuf-c/person-pb-c.h b/Software/Embedded_SW/Embedded/Common/protobuf-c/person-pb-c.h deleted file mode 100644 index 87b0007b1..000000000 --- a/Software/Embedded_SW/Embedded/Common/protobuf-c/person-pb-c.h +++ /dev/null @@ -1,112 +0,0 @@ -/* Generated by the protocol buffer compiler. DO NOT EDIT! */ -/* Generated from: person.proto */ - -#ifndef PROTOBUF_C_person_2eproto__INCLUDED -#define PROTOBUF_C_person_2eproto__INCLUDED - -#include - -PROTOBUF_C__BEGIN_DECLS - -#if PROTOBUF_C_VERSION_NUMBER < 1003000 -# error This file was generated by a newer version of protoc-c which is incompatible with your libprotobuf-c headers. Please update your headers. -#elif 1003000 < PROTOBUF_C_MIN_COMPILER_VERSION -# error This file was generated by an older version of protoc-c which is incompatible with your libprotobuf-c headers. Please regenerate this file with a newer version of protoc-c. -#endif - - -typedef struct _Address Address; -typedef struct _Person Person; - - -/* --- enums --- */ - - -/* --- messages --- */ - -struct _Address -{ - ProtobufCMessage base; - char *street; - protobuf_c_boolean has_number; - int32_t number; -}; -#define ADDRESS__INIT \ - { PROTOBUF_C_MESSAGE_INIT (&address__descriptor) \ - , NULL, 0, 0 } - - -struct _Person -{ - ProtobufCMessage base; - char *name; - protobuf_c_boolean has_age; - int32_t age; - char *email; - size_t n_address; - Address **address; -}; -#define PERSON__INIT \ - { PROTOBUF_C_MESSAGE_INIT (&person__descriptor) \ - , NULL, 0, 0, NULL, 0,NULL } - - -/* Address methods */ -void address__init - (Address *message); -size_t address__get_packed_size - (const Address *message); -size_t address__pack - (const Address *message, - uint8_t *out); -size_t address__pack_to_buffer - (const Address *message, - ProtobufCBuffer *buffer); -Address * - address__unpack - (ProtobufCAllocator *allocator, - size_t len, - const uint8_t *data); -void address__free_unpacked - (Address *message, - ProtobufCAllocator *allocator); -/* Person methods */ -void person__init - (Person *message); -size_t person__get_packed_size - (const Person *message); -size_t person__pack - (const Person *message, - uint8_t *out); -size_t person__pack_to_buffer - (const Person *message, - ProtobufCBuffer *buffer); -Person * - person__unpack - (ProtobufCAllocator *allocator, - size_t len, - const uint8_t *data); -void person__free_unpacked - (Person *message, - ProtobufCAllocator *allocator); -/* --- per-message closures --- */ - -typedef void (*Address_Closure) - (const Address *message, - void *closure_data); -typedef void (*Person_Closure) - (const Person *message, - void *closure_data); - -/* --- services --- */ - - -/* --- descriptors --- */ - -extern const ProtobufCMessageDescriptor address__descriptor; -extern const ProtobufCMessageDescriptor person__descriptor; - -PROTOBUF_C__END_DECLS - - -#endif /* PROTOBUF_C_person_2eproto__INCLUDED */ diff --git a/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_GPIO/FPGA_GPIO.c b/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_GPIO/FPGA_GPIO.c index e12863077..58ab31a47 100644 --- a/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_GPIO/FPGA_GPIO.c +++ b/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_GPIO/FPGA_GPIO.c @@ -115,7 +115,6 @@ void FPGA_Read_LS_Safty_Ind_Reg() { uint8_t temp[8],i; - LS_Left.ushort = F1_GPI_LS2_D; Ls_Right_Screw_Spool.ushort = F1_GPI_LS3_D; LS_Dispenser_1_2.ushort = F2_LS_01_Direct; diff --git a/Software/Embedded_SW/Embedded/Modules/General/GeneralHardware.c b/Software/Embedded_SW/Embedded/Modules/General/GeneralHardware.c index f44ee39cd..a884c3e21 100644 --- a/Software/Embedded_SW/Embedded/Modules/General/GeneralHardware.c +++ b/Software/Embedded_SW/Embedded/Modules/General/GeneralHardware.c @@ -85,7 +85,7 @@ uint32_t HWConfigurationInit(void) return Fresult; } -char EmbeddedParametersPath[50] = "0://SWInfo//EmbeddedParameters.msg"; +char EmbeddedParametersPath[50] = "0://SWInfo//EmbParam.msg"; ConfigurationParameters EmbeddedParameters; void LoadConfigurationParameters(ConfigurationParameters *Params) { diff --git a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_dispenser.c b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_dispenser.c index cf5a5b76e..579c503bf 100644 --- a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_dispenser.c +++ b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_dispenser.c @@ -213,7 +213,7 @@ uint32_t IDS_Dispenser_Start_Motor_and_Open_Valve(int DispenserId, int MotorSpee DispenserRunningData IDS_Dispenser_Data[MAX_SYSTEM_DISPENSERS]; DispenserData IDSDispenserData; DispenserRunningData **dispenserdata; -char DispenserStorePath[50] = "0://SWInfo//DispenserStore.msg"; +char DispenserStorePath[50] = "0://SWInfo//DispStor.msg"; void IDS_Dispenser_Content_Init (void) { -- cgit v1.3.1