-
Notifications
You must be signed in to change notification settings - Fork 2
Feature/sec arch #96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
caiussouza
wants to merge
37
commits into
develop
Choose a base branch
from
feature/sec_arch
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Feature/sec arch #96
Changes from all commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
a9e97fe
creation of file sensor_data_processing
caiussouza 4fe37f6
creation of moving average logic
caiussouza b77eab7
completing the moving average
caiussouza b148b00
cross validation sketch
caiussouza ea57e3c
cross validation logic implemented
caiussouza c45a78f
security architecture sketch
caiussouza de6a3c9
Merge branch 'develop' of https://github.com/Tesla-UFMG/ECU into feat…
caiussouza fd5d772
cross validation task development
caiussouza 9660b35
creation of timer
caiussouza 4f91fe0
debugging
caiussouza a2e083a
bug fixing
caiussouza e911744
bug fixing
caiussouza 4288f83
building errors fixed
caiussouza 233fbe4
ready for tests
caiussouza ca7452c
moving average fixing
caiussouza c378251
pr ready version
caiussouza b619d25
Merge branch 'develop' of https://github.com/Tesla-UFMG/ECU into feat…
caiussouza 67af997
refactoring
caiussouza e68d337
datalogging function added
caiussouza 877245f
ready for tests
caiussouza 283f0d5
clang format fixing
caiussouza 2a23b7d
clang tidy fixing
caiussouza 55d37eb
clang format
caiussouza 9afa923
fixing
caiussouza 9812801
Warnings fixing
caiussouza bd66c2f
flag number fixing
caiussouza 97edb1c
flag neme fixing
caiussouza cca8756
Merge branch 'develop' of https://github.com/Tesla-UFMG/ECU into feat…
caiussouza 7fb72a3
merge conflicts fixing
caiussouza 41fc941
clang format
caiussouza f18bf21
.ioc fixing
caiussouza 0defa6f
variable name refactor on ioc
caiussouza d76d67b
now the task works for all the time the car is active
caiussouza ff6bc57
atualizando ids de can
caiussouza a07503b
reverting can ids changes
caiussouza 133028e
ready for tests
caiussouza 787aa83
security arch implemented for all 4 speed sensors
caiussouza File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| /* | ||
| * security_architecture.h | ||
| * | ||
| * Created on: Mar 7, 2023 | ||
| * Author: caius | ||
| */ | ||
|
|
||
| #ifndef INC_DYNAMIC_CONTROLS_SECURITY_ARCHITECTURE_H_ | ||
| #define INC_DYNAMIC_CONTROLS_SECURITY_ARCHITECTURE_H_ | ||
|
|
||
| // TODO(caius): add the threshold values and the timer time | ||
|
|
||
| #include "stdbool.h" | ||
| #include "stdint.h" | ||
|
|
||
| #define IMU_NULL_ACCEL_MARGIN_ERROR 1 | ||
| #define NULL_SPEED_MARGIN_ERROR 1 | ||
|
|
||
| #define CROSS_VALIDATION_ERROR_TIME 1 | ||
| #define CROSS_VALIDATION_DELAY 1 | ||
|
|
||
| bool is_there_imu_bse_error(); | ||
| bool is_there_imu_speed_error(); | ||
| void cross_validation_error_callback(); | ||
| void cross_validation_status_datalog(); | ||
|
|
||
| #endif /* INC_DYNAMIC_CONTROLS_SECURITY_ARCHITECTURE_H_ */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| /* | ||
| * sensor_data_processing.h | ||
| * | ||
| * Created on: Mar 2, 2023 | ||
| * Author: caius | ||
| */ | ||
|
|
||
| #ifndef INC_SENSORS_SENSOR_DATA_PROCESSING_H_ | ||
| #define INC_SENSORS_SENSOR_DATA_PROCESSING_H_ | ||
|
|
||
| #include "stdbool.h" | ||
| #include "stdint.h" | ||
|
|
||
| #define MAX_BUFFER_SIZE 100 | ||
|
|
||
| typedef struct { | ||
| float buffer[MAX_BUFFER_SIZE]; | ||
| uint8_t index; | ||
| uint8_t size; | ||
| bool max_points_reached; | ||
| } moving_average_t; | ||
|
|
||
| // void moving_average(float* mov_avg, float const* data); | ||
| float get_add_moving_average(moving_average_t* moving_average, float const data); | ||
|
|
||
| #endif /* INC_SENSORS_SENSOR_DATA_PROCESSING_H_ */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,98 @@ | ||
| /* | ||
| * security_architecture.c | ||
| * | ||
| * Created on: 2 de mar de 2023 | ||
| * Author: caius | ||
| */ | ||
|
|
||
| #include "dynamic_controls/security_architecture.h" | ||
|
|
||
| #include "CAN/general_can_data_manager.h" | ||
| #include "datalogging/datalog_handler.h" | ||
| #include "sensors/sensor_data_processing.h" | ||
| #include "util/global_instances.h" | ||
| #include "util/util.h" | ||
|
|
||
| static moving_average_t speedFL_mov_avg; | ||
| static moving_average_t speedFR_mov_avg; | ||
| static moving_average_t speedRL_mov_avg; | ||
| static moving_average_t speedRR_mov_avg; | ||
| static moving_average_t IMU_long_accel_mov_avg; | ||
|
|
||
| static BRAKE_STATUS_t bse_active; | ||
|
|
||
| static float speedFL_mov_ave_value; | ||
| static float speedFR_mov_ave_value; | ||
| static float speedRL_mov_ave_value; | ||
| static float speedRR_mov_ave_value; | ||
| static float IMU_long_accel_mov_ave_value; | ||
|
|
||
| static bool imu_bse_error_status; | ||
| static bool imu_speed_error_status; | ||
|
|
||
| void cross_validation(void* argument) { | ||
| UNUSED(argument); | ||
|
|
||
| for (;;) { | ||
| ECU_ENABLE_BREAKPOINT_DEBUG(); | ||
|
|
||
| float IMU_long_accel_data = (float)general_get_value(accelerometer_z); | ||
|
|
||
| SPEEDS_t speed_var = get_global_var_value(SPEEDS); | ||
|
|
||
| float speedFL_data = (float)speed_var.wheels[FRONT_LEFT]; | ||
| float speedFR_data = (float)speed_var.wheels[FRONT_RIGHT]; | ||
| float speedRL_data = (float)speed_var.wheels[REAR_LEFT]; | ||
| float speedRR_data = (float)speed_var.wheels[REAR_RIGHT]; | ||
|
|
||
| bse_active = get_global_var_value(BRAKE_STATUS); | ||
|
|
||
| IMU_long_accel_mov_ave_value = | ||
| get_add_moving_average(&IMU_long_accel_mov_avg, IMU_long_accel_data); | ||
|
|
||
| speedFL_mov_ave_value = get_add_moving_average(&speedFL_mov_avg, speedFL_data); | ||
| speedFR_mov_ave_value = get_add_moving_average(&speedFR_mov_avg, speedFR_data); | ||
| speedRL_mov_ave_value = get_add_moving_average(&speedRL_mov_avg, speedRL_data); | ||
| speedRR_mov_ave_value = get_add_moving_average(&speedRR_mov_avg, speedRR_data); | ||
|
|
||
| imu_bse_error_status = is_there_imu_bse_error(); | ||
| imu_speed_error_status = is_there_imu_speed_error(); | ||
|
|
||
| if (imu_bse_error_status || imu_speed_error_status) { | ||
| osTimerStart(tim_cross_validation_errorHandle, CROSS_VALIDATION_ERROR_TIME); | ||
| } | ||
|
|
||
| else { | ||
| osTimerStop(tim_cross_validation_errorHandle); | ||
| } | ||
| cross_validation_status_datalog(); | ||
| osDelay(CROSS_VALIDATION_DELAY); | ||
| } | ||
|
caiussouza marked this conversation as resolved.
|
||
| } | ||
|
|
||
| bool is_there_imu_bse_error() { | ||
| if (bse_active && (IMU_long_accel_mov_ave_value > IMU_NULL_ACCEL_MARGIN_ERROR)) { | ||
| return true; | ||
| } | ||
| return false; | ||
| } | ||
|
|
||
| bool is_there_imu_speed_error() { | ||
| if (((speedFR_mov_ave_value < NULL_SPEED_MARGIN_ERROR) | ||
| || (speedFL_mov_ave_value < NULL_SPEED_MARGIN_ERROR) | ||
| || (speedRL_mov_ave_value < NULL_SPEED_MARGIN_ERROR) | ||
| || (speedRR_mov_ave_value < NULL_SPEED_MARGIN_ERROR)) | ||
| && (IMU_long_accel_mov_ave_value > IMU_NULL_ACCEL_MARGIN_ERROR)) { | ||
| return true; | ||
| } | ||
| return false; | ||
| } | ||
|
|
||
| void cross_validation_error_callback() { | ||
| osEventFlagsSet(e_ECU_control_flagsHandle, CROSS_VALIDATION_ERROR_WARN_FLAG); | ||
| } | ||
|
|
||
| void cross_validation_status_datalog() { | ||
| log_data(ID_IMU_BSE_ERROR, imu_bse_error_status); | ||
| log_data(ID_IMU_SPEED_ERROR, imu_speed_error_status); | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.