From 71e945dc7e8c3cd525a09fcf648723e55c6b8d8c Mon Sep 17 00:00:00 2001 From: Michal Horn Date: Thu, 12 Sep 2013 12:38:36 +0200 Subject: [PATCH] Disable FlexRay configuratin commands after the driver was initialized --- commands/cmd_fr_basic_test.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/commands/cmd_fr_basic_test.c b/commands/cmd_fr_basic_test.c index 3daea06..115326d 100644 --- a/commands/cmd_fr_basic_test.c +++ b/commands/cmd_fr_basic_test.c @@ -49,6 +49,10 @@ static inline int badpar(const char *msg) return -CMDERR_BADPAR; } +/** + * Flag to recognize whether the FlexRay driver was already initialized. If it was, no further configuration is allowed. + */ +static boolean_t fr_initialized = FALSE; /** * This structure contains global FlexRay configuration. @@ -681,6 +685,11 @@ int cmd_do_fr_config_fifo(cmd_io_t *cmd_io, const struct cmd_des *des, char *par unsigned depth, slot, cycleset, maxpayload; Fr_TMS570LS_BufferConfigType tmp_buffer; + if (fr_initialized) { + rpp_sci_printf("FlexRay configuration can not be modified after frbtinit was called.\n"); + return -CMDERR_BADCFG; + } + ret = sscanf(param[2], "slot%i depth%i %2s cyc%i max%i %10s %10s", &slot, &depth, @@ -759,6 +768,11 @@ int cmd_do_fr_config_bufer(cmd_io_t *cmd_io, const struct cmd_des *des, char *pa char buf_type, channel[3],rxtx[3], single_continuous[11]; unsigned buffer, slot, cycleset, maxpayload, intr, preamb; + if (fr_initialized) { + rpp_sci_printf("FlexRay configuration can not be modified after frbtinit was called.\n"); + return -CMDERR_BADCFG; + } + ret = sscanf(param[1], "%c%i slot%i %2s cyc%i %2s max%i %10s ppi%i int%i", &buf_type, &buffer, @@ -870,6 +884,12 @@ int cmd_do_fr_config_bufer(cmd_io_t *cmd_io, const struct cmd_des *des, char *pa */ int cmd_do_fr_user_config(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[]) { char* token; + + if (fr_initialized) { + rpp_sci_printf("FlexRay configuration can not be modified after frbtinit was called.\n"); + return -CMDERR_BADCFG; + } + token = strtok(param[1], " "); if (strcmp(token, "cluster") == 0) { if (cmd_fr_config_cluster_params(param[2]) == FAILURE) { @@ -924,6 +944,7 @@ int cmd_do_fr_init(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[]) { retVal = rpp_fr_init_driver(Fr_ConfigPtr, &error); if (retVal == SUCCESS) { rpp_sci_printf("FlexRay driver initialized.\r\n"); + fr_initialized = TRUE; } else { retVal = rpp_fr_init_controller(0, &error); -- 2.39.2