drop cmd stuff
This commit is contained in:
111
cube/Makefile
111
cube/Makefile
@ -1,8 +1,11 @@
|
|||||||
# Processed by ../tools/insertMyCode.sh
|
# Processed by ../tools/insertMyCode.sh
|
||||||
##########################################################################################################################
|
##########################################################################################################################
|
||||||
# File automatically-generated by tool: [projectgenerator] version: [3.10.0-B14] date: [Sat Feb 13 18:28:59 CET 2021]
|
# File automatically-generated by tool: [projectgenerator] version: [3.10.0-B14] date: [Sat Feb 13 18:28:59 CET 2021]
|
||||||
##########################################################################################################################
|
##########################################################################################################################
|
||||||
|
|
||||||
|
# FILE NOT LONGER UNDER CONTROL OF THE GENERATOR BUT MANUALLY MAINTAINED, 2020-02-16 #
|
||||||
|
|
||||||
|
|
||||||
# ------------------------------------------------
|
# ------------------------------------------------
|
||||||
# Generic Makefile (based on gcc)
|
# Generic Makefile (based on gcc)
|
||||||
#
|
#
|
||||||
@ -11,6 +14,9 @@
|
|||||||
# 2015-07-22 - first version
|
# 2015-07-22 - first version
|
||||||
# ------------------------------------------------
|
# ------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
NETWORK = LAN
|
||||||
|
|
||||||
######################################
|
######################################
|
||||||
# target
|
# target
|
||||||
######################################
|
######################################
|
||||||
@ -36,36 +42,47 @@ BUILD_DIR = build
|
|||||||
# source
|
# source
|
||||||
######################################
|
######################################
|
||||||
# C sources
|
# C sources
|
||||||
C_SOURCES = \
|
C_SOURCES = \
|
||||||
User/Src/cmdHandler.c User/Src/config.c User/Src/configCmds.c User/Src/counter.c User/Src/eeprom.c User/Src/logger.c User/Src/main2.c User/Src/ports.c User/Src/regularCmds.c User/Src/ringbuffer.c User/Src/sha256.c User/Src/show.c User/Src/utils.c User/Src/wizHelper.c hottislib/PontCoopScheduler.c \
|
User/Src/config.c \
|
||||||
Core/Src/main.c \
|
User/Src/counter.c \
|
||||||
Core/Src/gpio.c \
|
User/Src/eeprom.c \
|
||||||
Core/Src/iwdg.c \
|
User/Src/logger.c \
|
||||||
Core/Src/spi.c \
|
User/Src/main2.c \
|
||||||
Core/Src/tim.c \
|
User/Src/ports.c \
|
||||||
Core/Src/usart.c \
|
User/Src/ringbuffer.c \
|
||||||
Core/Src/stm32f1xx_it.c \
|
User/Src/sha256.c \
|
||||||
Core/Src/stm32f1xx_hal_msp.c \
|
User/Src/show.c \
|
||||||
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio_ex.c \
|
User/Src/utils.c \
|
||||||
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_iwdg.c \
|
User/Src/wizHelper.c \
|
||||||
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.c \
|
hottislib/PontCoopScheduler.c \
|
||||||
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc.c \
|
Core/Src/main.c \
|
||||||
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc_ex.c \
|
Core/Src/gpio.c \
|
||||||
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio.c \
|
Core/Src/iwdg.c \
|
||||||
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_dma.c \
|
Core/Src/spi.c \
|
||||||
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_cortex.c \
|
Core/Src/tim.c \
|
||||||
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pwr.c \
|
Core/Src/usart.c \
|
||||||
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash.c \
|
Core/Src/stm32f1xx_it.c \
|
||||||
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash_ex.c \
|
Core/Src/stm32f1xx_hal_msp.c \
|
||||||
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_exti.c \
|
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio_ex.c \
|
||||||
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_spi.c \
|
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_iwdg.c \
|
||||||
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim.c \
|
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.c \
|
||||||
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim_ex.c \
|
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc.c \
|
||||||
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_uart.c \
|
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc_ex.c \
|
||||||
|
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio.c \
|
||||||
|
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_dma.c \
|
||||||
|
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_cortex.c \
|
||||||
|
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pwr.c \
|
||||||
|
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash.c \
|
||||||
|
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash_ex.c \
|
||||||
|
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_exti.c \
|
||||||
|
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_spi.c \
|
||||||
|
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim.c \
|
||||||
|
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim_ex.c \
|
||||||
|
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_uart.c \
|
||||||
Core/Src/system_stm32f1xx.c
|
Core/Src/system_stm32f1xx.c
|
||||||
|
|
||||||
# ASM sources
|
# ASM sources
|
||||||
ASM_SOURCES = \
|
ASM_SOURCES = \
|
||||||
startup_stm32f103xb.s
|
startup_stm32f103xb.s
|
||||||
|
|
||||||
|
|
||||||
@ -109,8 +126,8 @@ MCU = $(CPU) -mthumb $(FPU) $(FLOAT-ABI)
|
|||||||
AS_DEFS =
|
AS_DEFS =
|
||||||
|
|
||||||
# C defines
|
# C defines
|
||||||
C_DEFS = \
|
C_DEFS = \
|
||||||
-DUSE_HAL_DRIVER \
|
-DUSE_HAL_DRIVER \
|
||||||
-DSTM32F103xB
|
-DSTM32F103xB
|
||||||
|
|
||||||
|
|
||||||
@ -118,25 +135,25 @@ C_DEFS = \
|
|||||||
AS_INCLUDES =
|
AS_INCLUDES =
|
||||||
|
|
||||||
# C includes
|
# C includes
|
||||||
C_INCLUDES = \
|
C_INCLUDES = \
|
||||||
-Ihottislib \
|
-Ihottislib \
|
||||||
-IUser/Inc \
|
-IUser/Inc \
|
||||||
-IioLibrary_Driver/Internet/SNTP \
|
-IioLibrary_Driver/Internet/SNTP \
|
||||||
-IioLibrary_Driver/Internet/DNS \
|
-IioLibrary_Driver/Internet/DNS \
|
||||||
-IioLibrary_Driver/Internet/DHCP \
|
-IioLibrary_Driver/Internet/DHCP \
|
||||||
-IioLibrary_Driver/Ethernet \
|
-IioLibrary_Driver/Ethernet \
|
||||||
-ICore/Inc \
|
-ICore/Inc \
|
||||||
-IDrivers/STM32F1xx_HAL_Driver/Inc \
|
-IDrivers/STM32F1xx_HAL_Driver/Inc \
|
||||||
-IDrivers/STM32F1xx_HAL_Driver/Inc/Legacy \
|
-IDrivers/STM32F1xx_HAL_Driver/Inc/Legacy \
|
||||||
-IDrivers/CMSIS/Device/ST/STM32F1xx/Include \
|
-IDrivers/CMSIS/Device/ST/STM32F1xx/Include \
|
||||||
-IDrivers/CMSIS/Include \
|
-IDrivers/CMSIS/Include \
|
||||||
-IDrivers/CMSIS/Include
|
-IDrivers/CMSIS/Include
|
||||||
|
|
||||||
|
|
||||||
# compile gcc flags
|
# compile gcc flags
|
||||||
ASFLAGS = $(MCU) $(AS_DEFS) $(AS_INCLUDES) $(OPT) -Wall -Werror -fdata-sections -ffunction-sections
|
ASFLAGS = $(MCU) $(AS_DEFS) $(AS_INCLUDES) $(OPT) -Wall -Werror -fdata-sections -ffunction-sections
|
||||||
|
|
||||||
CFLAGS = $(MCU) $(C_DEFS) $(C_INCLUDES) $(OPT) -Wall -Werror -fdata-sections -ffunction-sections
|
CFLAGS = $(MCU) $(C_DEFS) $(C_INCLUDES) $(OPT) -DNETWORK="\"$(NETWORK)\"" -Wall -Werror -fdata-sections -ffunction-sections
|
||||||
|
|
||||||
ifeq ($(DEBUG), 1)
|
ifeq ($(DEBUG), 1)
|
||||||
CFLAGS += -g -gdwarf-2
|
CFLAGS += -g -gdwarf-2
|
||||||
@ -168,14 +185,14 @@ all: $(BUILD_DIR)/$(TARGET).elf $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET
|
|||||||
# list of objects
|
# list of objects
|
||||||
OBJECTS = $(addprefix $(BUILD_DIR)/,$(notdir $(C_SOURCES:.c=.o)))
|
OBJECTS = $(addprefix $(BUILD_DIR)/,$(notdir $(C_SOURCES:.c=.o)))
|
||||||
vpath %.c $(sort $(dir $(C_SOURCES)))
|
vpath %.c $(sort $(dir $(C_SOURCES)))
|
||||||
OBJECTS += $(addprefix $(BUILD_DIR)/,w5500.a)
|
OBJECTS += $(addprefix $(BUILD_DIR)/,w5500.a)
|
||||||
# list of ASM program objects
|
# list of ASM program objects
|
||||||
OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(ASM_SOURCES:.s=.o)))
|
OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(ASM_SOURCES:.s=.o)))
|
||||||
vpath %.s $(sort $(dir $(ASM_SOURCES)))
|
vpath %.s $(sort $(dir $(ASM_SOURCES)))
|
||||||
|
|
||||||
$(BUILD_DIR)/w5500.a:
|
$(BUILD_DIR)/w5500.a:
|
||||||
(cd ioLibrary_Driver && $(MAKE) && cp w5500.a ../$(BUILD_DIR) && cd ..)
|
(cd ioLibrary_Driver && $(MAKE) && cp w5500.a ../$(BUILD_DIR) && cd ..)
|
||||||
|
|
||||||
$(BUILD_DIR)/%.o: %.c Makefile | $(BUILD_DIR)
|
$(BUILD_DIR)/%.o: %.c Makefile | $(BUILD_DIR)
|
||||||
$(CC) -c $(CFLAGS) -Wa,-a,-ad,-alms=$(BUILD_DIR)/$(notdir $(<:.c=.lst)) $< -o $@
|
$(CC) -c $(CFLAGS) -Wa,-a,-ad,-alms=$(BUILD_DIR)/$(notdir $(<:.c=.lst)) $< -o $@
|
||||||
|
|
||||||
|
@ -1,9 +0,0 @@
|
|||||||
#ifndef _CMDHANDLER_H_
|
|
||||||
#define _CMDHANDLER_H_
|
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
void cmdHandlerInit();
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* _CMDHANDLER_H_ */
|
|
@ -1,23 +0,0 @@
|
|||||||
#ifndef _CMDHELPER_H_
|
|
||||||
#define _CMDHELPER_H_
|
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <stdbool.h>
|
|
||||||
|
|
||||||
|
|
||||||
typedef bool (*cmdFunc_t)(uint8_t argc, char **args);
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
char name[24];
|
|
||||||
char help[512];
|
|
||||||
cmdFunc_t cmdFunc;
|
|
||||||
} cmd_t;
|
|
||||||
|
|
||||||
void sendString(const char *buf);
|
|
||||||
bool sendFormatString(const char *format, ...);
|
|
||||||
|
|
||||||
const cmd_t *getRegularCommands();
|
|
||||||
const cmd_t *getAdminCommands();
|
|
||||||
const cmd_t *getConfigCommands();
|
|
||||||
|
|
||||||
#endif /* _CMDHELPER_H_ */
|
|
@ -40,7 +40,6 @@ void eepromRead(uint16_t addr, uint8_t *buf, uint8_t len);
|
|||||||
void eepromSpiTxCpltCallback(SPI_HandleTypeDef *hspi);
|
void eepromSpiTxCpltCallback(SPI_HandleTypeDef *hspi);
|
||||||
t_deviceStats* getGlobalDeviceStats();
|
t_deviceStats* getGlobalDeviceStats();
|
||||||
void eepromReadConfigBlock(t_configBlock *destConfigBlock);
|
void eepromReadConfigBlock(t_configBlock *destConfigBlock);
|
||||||
void eepromWriteConfigBlock(t_configBlock *srcConfigBlock);
|
|
||||||
void eepromHourlyUpdateDeviceStats(void *handle);
|
void eepromHourlyUpdateDeviceStats(void *handle);
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,326 +0,0 @@
|
|||||||
#include <cmdHandler.h>
|
|
||||||
#include <cmdHelper.h>
|
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdarg.h>
|
|
||||||
|
|
||||||
#include <socket.h>
|
|
||||||
|
|
||||||
#include <logger.h>
|
|
||||||
#include <PontCoopScheduler.h>
|
|
||||||
#include <wizHelper.h>
|
|
||||||
#include <config.h>
|
|
||||||
|
|
||||||
|
|
||||||
extern const uint8_t CMD_SOCK;
|
|
||||||
|
|
||||||
const uint16_t cmdPort = 23;
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
CH_INIT,
|
|
||||||
CH_LISTEN,
|
|
||||||
CH_WAITING,
|
|
||||||
CH_BANNER,
|
|
||||||
CH_PROMPT,
|
|
||||||
CH_RECEIVE,
|
|
||||||
CH_DISCONNECT,
|
|
||||||
CH_DISCONNECT_WAIT,
|
|
||||||
CH_ERROR
|
|
||||||
} chState_t;
|
|
||||||
|
|
||||||
void sendString(const char *buf) {
|
|
||||||
send(CMD_SOCK, (uint8_t*)buf, strlen(buf));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool sendFormatString(const char *format, ...) {
|
|
||||||
bool retCode = true;
|
|
||||||
va_list vl;
|
|
||||||
va_start(vl, format);
|
|
||||||
char buf[4096];
|
|
||||||
int vcnt = vsnprintf(buf, sizeof(buf), format, vl);
|
|
||||||
retCode = (vcnt < sizeof(buf));
|
|
||||||
va_end(vl);
|
|
||||||
sendString(buf);
|
|
||||||
return retCode;
|
|
||||||
}
|
|
||||||
|
|
||||||
// returns 0 to continue waiting for input
|
|
||||||
// returns -1 to close the connection
|
|
||||||
// returns 1 to toggle to admin mode
|
|
||||||
// returns 2 to toggle to config mode
|
|
||||||
// returns 3 to toggle back to default mode
|
|
||||||
static int8_t cmdExecuteCommand(uint8_t *cmdLine, bool resetSpecialModes) {
|
|
||||||
const static char HELP_MSG[] = \
|
|
||||||
"Usage\n\r" \
|
|
||||||
"\n\r" \
|
|
||||||
"help ................................. Show this help page\n\r" \
|
|
||||||
"quit ................................. Terminate the console session\n\r" \
|
|
||||||
"config ............................... Enter configuration mode\n\r" \
|
|
||||||
;
|
|
||||||
const static char CONFIG_INTRO_MSG[] = \
|
|
||||||
"In configuration mode each command changing the configuration\n\r" \
|
|
||||||
"will save changes directly to the EEPROM.\n\r" \
|
|
||||||
"However, the system will only consider these changes after a\n\r" \
|
|
||||||
"restart since only in this sitution the EEPROM is read.\n\r" \
|
|
||||||
"\n\r" \
|
|
||||||
;
|
|
||||||
const static char GOODBYE_MSG[] = "Good bye\n\r";
|
|
||||||
const static char OK_MSG[] = "OK\n\r";
|
|
||||||
const static char FAILED_MSG[] = "Failed\n\r";
|
|
||||||
const static char UNKNOWN_COMMAND[] = "Unknown command\n\r";
|
|
||||||
uint8_t *messageToSend = NULL;
|
|
||||||
|
|
||||||
static bool configMode = false;
|
|
||||||
|
|
||||||
if (resetSpecialModes) {
|
|
||||||
configMode = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
cmd_t const * commands = getRegularCommands();
|
|
||||||
if (configMode) {
|
|
||||||
commands = getConfigCommands();
|
|
||||||
}
|
|
||||||
|
|
||||||
coloredMsg(LOG_YELLOW, "ch cec cmdLine is %s", cmdLine);;
|
|
||||||
|
|
||||||
#define MAX_NUM_OF_ARGS 8
|
|
||||||
char *args[MAX_NUM_OF_TASKS];
|
|
||||||
uint8_t argc = 0;
|
|
||||||
char *inCmdLine = (char*)cmdLine;
|
|
||||||
do {
|
|
||||||
args[argc++] = strtok(inCmdLine, " ");
|
|
||||||
inCmdLine = NULL;
|
|
||||||
} while (args[argc - 1] != NULL);
|
|
||||||
if (argc > 0) {
|
|
||||||
argc--;
|
|
||||||
}
|
|
||||||
char *cmd = args[0];
|
|
||||||
|
|
||||||
int8_t retCode = 0;
|
|
||||||
coloredMsg(LOG_YELLOW, "ch cec cmd is %s, number of arguments %d", cmd, argc);
|
|
||||||
|
|
||||||
if (0 == strcmp(cmd, "quit")) {
|
|
||||||
messageToSend = (uint8_t*)GOODBYE_MSG;
|
|
||||||
retCode = -1;
|
|
||||||
} else if (0 == strcmp(cmd, "help")) {
|
|
||||||
if (configMode) {
|
|
||||||
sendString(CONFIG_INTRO_MSG);
|
|
||||||
}
|
|
||||||
sendString(HELP_MSG);
|
|
||||||
uint8_t cmdIdx = 0;
|
|
||||||
while (true) {
|
|
||||||
cmd_t command = commands[cmdIdx];
|
|
||||||
if (0 == strcmp("END_OF_CMDS", command.name)) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
sendString(command.help);
|
|
||||||
cmdIdx++;
|
|
||||||
}
|
|
||||||
messageToSend = NULL;
|
|
||||||
} else if (0 == strcmp(cmd, "config")) {
|
|
||||||
coloredMsg(LOG_YELLOW, "ch cec enable config mode");
|
|
||||||
configMode = true;
|
|
||||||
retCode = 2;
|
|
||||||
} else {
|
|
||||||
uint8_t cmdIdx = 0;
|
|
||||||
while (true) {
|
|
||||||
cmd_t command = commands[cmdIdx];
|
|
||||||
if (0 == strcmp("END_OF_CMDS", command.name)) {
|
|
||||||
messageToSend = (uint8_t*) UNKNOWN_COMMAND;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (0 == strcmp(cmd, command.name)) {
|
|
||||||
messageToSend = command.cmdFunc(argc, args) ? (uint8_t*)OK_MSG : (uint8_t*)FAILED_MSG;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
cmdIdx++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (messageToSend) {
|
|
||||||
coloredMsg(LOG_YELLOW, "ch cec command finally returns %s", messageToSend);
|
|
||||||
send(CMD_SOCK, messageToSend, strlen((char*)messageToSend));
|
|
||||||
}
|
|
||||||
|
|
||||||
return retCode;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void cmdHandlerEngine(void *handle) {
|
|
||||||
static uint8_t receiveBuffer[256];
|
|
||||||
|
|
||||||
static chState_t state = CH_INIT;
|
|
||||||
static bool resetSpecialModes = false;
|
|
||||||
|
|
||||||
static char banner[] = \
|
|
||||||
"MBGW3\n\r" \
|
|
||||||
"Type help for usage help\n\r" \
|
|
||||||
"or quit to close the connection.\n\r";
|
|
||||||
|
|
||||||
static char *prompt;
|
|
||||||
static char defaultPrompt[] = " > ";
|
|
||||||
static char configPrompt[] = " (config) $ ";
|
|
||||||
|
|
||||||
|
|
||||||
int8_t res = 0;
|
|
||||||
uint8_t sockState;
|
|
||||||
int32_t resultSend;
|
|
||||||
int16_t receivedOctets;
|
|
||||||
int32_t resultRecv;
|
|
||||||
uint8_t resultDisconnect;
|
|
||||||
|
|
||||||
|
|
||||||
if (isNetworkAvailable()) {
|
|
||||||
switch (state) {
|
|
||||||
case CH_INIT:
|
|
||||||
coloredMsg(LOG_YELLOW, "ch che initializing socket");
|
|
||||||
|
|
||||||
res = socket(CMD_SOCK, Sn_MR_TCP, cmdPort, SF_IO_NONBLOCK);
|
|
||||||
coloredMsg(LOG_YELLOW, "ch che socket returns %d", res);
|
|
||||||
|
|
||||||
if (res == CMD_SOCK) {
|
|
||||||
coloredMsg(LOG_YELLOW, "ch che socket is initialized");
|
|
||||||
state = CH_LISTEN;
|
|
||||||
} else {
|
|
||||||
state = CH_ERROR;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case CH_LISTEN:
|
|
||||||
coloredMsg(LOG_YELLOW, "ch che listening");
|
|
||||||
|
|
||||||
res = listen(CMD_SOCK);
|
|
||||||
coloredMsg(LOG_YELLOW, "ch che listen returns %d", res);
|
|
||||||
|
|
||||||
if (res == SOCK_OK) {
|
|
||||||
coloredMsg(LOG_YELLOW, "ch che ok, waiting for established");
|
|
||||||
state = CH_WAITING;
|
|
||||||
} else {
|
|
||||||
state = CH_ERROR;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case CH_WAITING:
|
|
||||||
sockState = getSn_SR(CMD_SOCK);
|
|
||||||
if (sockState != SOCK_LISTEN) {
|
|
||||||
coloredMsg(LOG_YELLOW, "ch che socket state is 0x%02x", sockState);
|
|
||||||
state = CH_DISCONNECT;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sockState == SOCK_ESTABLISHED) {
|
|
||||||
coloredMsg(LOG_YELLOW, "ch che connection is established");
|
|
||||||
state = CH_BANNER;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case CH_BANNER:
|
|
||||||
coloredMsg(LOG_YELLOW, "ch che send banner");
|
|
||||||
sockState = getSn_SR(CMD_SOCK);
|
|
||||||
if (sockState != SOCK_ESTABLISHED) {
|
|
||||||
coloredMsg(LOG_YELLOW, "ch che sockState is 0x%02x when trying to send banner", sockState);
|
|
||||||
state = CH_DISCONNECT;
|
|
||||||
} else {
|
|
||||||
resultSend = send(CMD_SOCK, (uint8_t*)banner, strlen(banner));
|
|
||||||
coloredMsg(LOG_YELLOW, "ch che sent banner, send returns 0x%02x", resultSend);
|
|
||||||
prompt = defaultPrompt;
|
|
||||||
resetSpecialModes = true;
|
|
||||||
state = CH_PROMPT;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case CH_PROMPT:
|
|
||||||
coloredMsg(LOG_YELLOW, "ch che send prompt");
|
|
||||||
sockState = getSn_SR(CMD_SOCK);
|
|
||||||
if (sockState != SOCK_ESTABLISHED) {
|
|
||||||
coloredMsg(LOG_YELLOW, "ch che sockState is 0x%02x when trying to send promt", sockState);
|
|
||||||
state = CH_DISCONNECT;
|
|
||||||
} else {
|
|
||||||
sendFormatString("%s %s", getConfig()->deviceName, prompt);
|
|
||||||
coloredMsg(LOG_YELLOW, "ch che sent prompt %s %s", getConfig()->deviceName, prompt);
|
|
||||||
state = CH_RECEIVE;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case CH_RECEIVE:
|
|
||||||
sockState = getSn_SR(CMD_SOCK);
|
|
||||||
if (sockState != SOCK_ESTABLISHED) {
|
|
||||||
coloredMsg(LOG_YELLOW, "ch che sockState is 0x%02x when trying to receive something", sockState);
|
|
||||||
state = CH_DISCONNECT;
|
|
||||||
} else {
|
|
||||||
receivedOctets = getSn_RX_RSR(CMD_SOCK);
|
|
||||||
|
|
||||||
if (receivedOctets > 0) {
|
|
||||||
memset(receiveBuffer, 0, sizeof(receiveBuffer));
|
|
||||||
resultRecv = recv(CMD_SOCK, receiveBuffer, sizeof(receiveBuffer));
|
|
||||||
coloredMsg(LOG_YELLOW, "ch che recv returns 0x%02x", resultRecv);
|
|
||||||
if (resultRecv > 0) {
|
|
||||||
if ((receiveBuffer[strlen((char*)receiveBuffer) - 1] == 0x0a) ||
|
|
||||||
(receiveBuffer[strlen((char*)receiveBuffer) - 1] == 0x0d)) {
|
|
||||||
receiveBuffer[strlen((char*)receiveBuffer) - 1] = 0;
|
|
||||||
}
|
|
||||||
if ((receiveBuffer[strlen((char*)receiveBuffer) - 1] == 0x0a) ||
|
|
||||||
(receiveBuffer[strlen((char*)receiveBuffer) - 1] == 0x0d)) {
|
|
||||||
receiveBuffer[strlen((char*)receiveBuffer) - 1] = 0;
|
|
||||||
}
|
|
||||||
coloredMsg(LOG_YELLOW, "ch che received: %s", receiveBuffer);
|
|
||||||
int8_t resCEC = cmdExecuteCommand(receiveBuffer, resetSpecialModes);
|
|
||||||
resetSpecialModes = false;
|
|
||||||
switch (resCEC) {
|
|
||||||
case 0:
|
|
||||||
state = CH_PROMPT;
|
|
||||||
break;
|
|
||||||
case -1:
|
|
||||||
state = CH_DISCONNECT;
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
prompt = configPrompt;
|
|
||||||
state = CH_PROMPT;
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
prompt = defaultPrompt;
|
|
||||||
state = CH_PROMPT;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
state = CH_DISCONNECT;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case CH_DISCONNECT:
|
|
||||||
coloredMsg(LOG_YELLOW, "ch che close our end");
|
|
||||||
resultDisconnect = disconnect(CMD_SOCK);
|
|
||||||
coloredMsg(LOG_YELLOW, "ch che disconnect returns 0x%02x", resultDisconnect);
|
|
||||||
state = CH_DISCONNECT_WAIT;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case CH_DISCONNECT_WAIT:
|
|
||||||
//coloredMsg(LOG_YELLOW, "ch che waiting after disconnect");
|
|
||||||
sockState = getSn_SR(CMD_SOCK);
|
|
||||||
//coloredMsg(LOG_YELLOW, "ch che sockState is 0x%02x", sockState);
|
|
||||||
if (sockState == SOCK_CLOSED) {
|
|
||||||
coloredMsg(LOG_YELLOW, "ch che socket is closed now");
|
|
||||||
state = CH_INIT;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
|
|
||||||
case CH_ERROR:
|
|
||||||
coloredMsg(LOG_YELLOW, "ch che error state, will stop here");
|
|
||||||
schDel(cmdHandlerEngine, NULL);
|
|
||||||
state = CH_INIT;
|
|
||||||
schAdd(cmdHandlerEngine, NULL, 5000, 100);
|
|
||||||
coloredMsg(LOG_YELLOW, "ch che restart command handler engine in 5s");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void cmdHandlerInit() {
|
|
||||||
schAdd(cmdHandlerEngine, NULL, 0, 100);
|
|
||||||
}
|
|
@ -1,212 +0,0 @@
|
|||||||
#include <cmdHelper.h>
|
|
||||||
#include <logger.h>
|
|
||||||
|
|
||||||
#include <eeprom.h>
|
|
||||||
#include <config.h>
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static bool showConfigCmd(uint8_t argc, char **args) {
|
|
||||||
bool retCode = true;
|
|
||||||
|
|
||||||
t_configBlock configBlock;
|
|
||||||
eepromReadConfigBlock(&configBlock);
|
|
||||||
sendString("This is the saved configuration.\n\r");
|
|
||||||
sendString("It is not necessarily the active configuration.\n\r");
|
|
||||||
sendFormatString("configMagic: %lx\n\r", configBlock.configMagic);
|
|
||||||
sendFormatString("deviceName: %s\n\r", configBlock.deviceName);
|
|
||||||
sendFormatString("MAC address: %02x:%02x:%02x:%02x:%02x:%02x\n\r", configBlock.macAddress[0],
|
|
||||||
configBlock.macAddress[1],
|
|
||||||
configBlock.macAddress[2],
|
|
||||||
configBlock.macAddress[3],
|
|
||||||
configBlock.macAddress[4],
|
|
||||||
configBlock.macAddress[5]);
|
|
||||||
sendFormatString("NTP Server: %s\n\r", configBlock.ntpServer);
|
|
||||||
sendFormatString("deviceId: %s\n\r", configBlock.deviceId);
|
|
||||||
sendFormatString("sharedSecret: (will not be displayed)\n\r");
|
|
||||||
sendFormatString("Sink Server: %s\n\r", configBlock.sinkServer);
|
|
||||||
|
|
||||||
return retCode;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool setStringParameterCmd(uint8_t argc, char **args, size_t offset, size_t length) {
|
|
||||||
bool retCode = true;
|
|
||||||
|
|
||||||
t_configBlock configBlock;
|
|
||||||
char *parameterName = args[1];
|
|
||||||
char *newParameterValue = args[2];
|
|
||||||
if (strlen(newParameterValue) >= length) {
|
|
||||||
sendString("given new value for is too long\n\r");
|
|
||||||
retCode = false;
|
|
||||||
} else {
|
|
||||||
sendFormatString("set %s to %s\n\r", parameterName, newParameterValue);
|
|
||||||
|
|
||||||
eepromReadConfigBlock(&configBlock);
|
|
||||||
strcpy((((char*)&configBlock) + offset), newParameterValue);
|
|
||||||
eepromWriteConfigBlock(&configBlock);
|
|
||||||
}
|
|
||||||
|
|
||||||
return retCode;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
static bool setInt32ParameterCmd(uint8_t argc, char **args, size_t offset, int32_t minV, int32_t maxV) {
|
|
||||||
bool retCode = true;
|
|
||||||
|
|
||||||
t_configBlock configBlock;
|
|
||||||
char *parameterName = args[1];
|
|
||||||
char *newParameterValue = args[2];
|
|
||||||
long int value = strtol(newParameterValue, NULL, 10);
|
|
||||||
if (value < minV) {
|
|
||||||
sendString("value is too small\n\r");
|
|
||||||
retCode = false;
|
|
||||||
} else if (value > maxV) {
|
|
||||||
sendString("value is too large\n\r");
|
|
||||||
} else {
|
|
||||||
int32_t v = (int32_t) value;
|
|
||||||
sendFormatString("set %s to %ld\n\r", parameterName, v);
|
|
||||||
|
|
||||||
eepromReadConfigBlock(&configBlock);
|
|
||||||
*((int32_t*)(((uint8_t*)&configBlock) + offset)) = v;
|
|
||||||
eepromWriteConfigBlock(&configBlock);
|
|
||||||
}
|
|
||||||
|
|
||||||
return retCode;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
static bool setDeviceNameCmd(uint8_t argc, char **args) {
|
|
||||||
return setStringParameterCmd(argc, args,
|
|
||||||
offsetof(t_configBlock, deviceName),
|
|
||||||
sizeof(((t_configBlock*)0)->deviceName));
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool setNtpServerCmd(uint8_t argc, char **args) {
|
|
||||||
return setStringParameterCmd(argc, args,
|
|
||||||
offsetof(t_configBlock, ntpServer),
|
|
||||||
sizeof(((t_configBlock*)0)->ntpServer));
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool setDeviceIdCmd(uint8_t argc, char **args) {
|
|
||||||
return setStringParameterCmd(argc, args,
|
|
||||||
offsetof(t_configBlock, deviceId),
|
|
||||||
sizeof(((t_configBlock*)0)->deviceId));
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool setSharedSecretCmd(uint8_t argc, char **args) {
|
|
||||||
return setStringParameterCmd(argc, args,
|
|
||||||
offsetof(t_configBlock, sharedSecret),
|
|
||||||
sizeof(((t_configBlock*)0)->sharedSecret));
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool setSinkServerCmd(uint8_t argc, char **args) {
|
|
||||||
return setStringParameterCmd(argc, args,
|
|
||||||
offsetof(t_configBlock, sinkServer),
|
|
||||||
sizeof(((t_configBlock*)0)->sinkServer));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
const static cmd_t SET_COMMANDS[] = {
|
|
||||||
{ .name = "devicename", .cmdFunc = setDeviceNameCmd,
|
|
||||||
.help = \
|
|
||||||
"devicename ........................... Name of this device\n\r"
|
|
||||||
},
|
|
||||||
{ .name = "ntpserver", .cmdFunc = setNtpServerCmd,
|
|
||||||
.help = \
|
|
||||||
"ntpserver ............................ Name of the NTP server\n\r"
|
|
||||||
},
|
|
||||||
{ .name = "deviceid", .cmdFunc = setDeviceIdCmd,
|
|
||||||
.help = \
|
|
||||||
"deviceid ............................. ID of this device\n\r"
|
|
||||||
},
|
|
||||||
{ .name = "sharedSecret", .cmdFunc = setSharedSecretCmd,
|
|
||||||
.help = \
|
|
||||||
"sharedsecret ......................... Shared secret\n\r"
|
|
||||||
},
|
|
||||||
{ .name = "sinkserver", .cmdFunc = setSinkServerCmd,
|
|
||||||
.help = \
|
|
||||||
"sinkserver ........................... Name of the sink server\n\r"
|
|
||||||
},
|
|
||||||
{ .name = "END_OF_CMDS", .help = "",.cmdFunc = NULL }
|
|
||||||
};
|
|
||||||
|
|
||||||
const static char UNKNOWN_PARAMETER[] = "unknown parameter\n\r";
|
|
||||||
const static char OK_MSG[] = "OK\n\r";
|
|
||||||
const static char FAILED_MSG[] = "Failed\n\r";
|
|
||||||
|
|
||||||
static bool setCmd(uint8_t argc, char **args) {
|
|
||||||
bool retCode = false;
|
|
||||||
uint8_t *messageToSend = NULL;
|
|
||||||
|
|
||||||
char *cmd = args[1];
|
|
||||||
if (argc >= 2) {
|
|
||||||
if (0 == strcmp("help", cmd)) {
|
|
||||||
sendString("You can set the following parameters:\n\r");
|
|
||||||
uint8_t cmdIdx = 0;
|
|
||||||
while (true) {
|
|
||||||
cmd_t command = SET_COMMANDS[cmdIdx];
|
|
||||||
if (0 == strcmp("END_OF_CMDS", command.name)) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
sendString(command.help);
|
|
||||||
cmdIdx++;
|
|
||||||
}
|
|
||||||
retCode = true;
|
|
||||||
} else {
|
|
||||||
uint8_t cmdIdx = 0;
|
|
||||||
while (true) {
|
|
||||||
cmd_t command = SET_COMMANDS[cmdIdx];
|
|
||||||
if (0 == strcmp("END_OF_CMDS", command.name)) {
|
|
||||||
messageToSend = (uint8_t*) UNKNOWN_PARAMETER;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (0 == strcmp(cmd, command.name)) {
|
|
||||||
retCode = command.cmdFunc(argc, args);
|
|
||||||
messageToSend = retCode ? (uint8_t*)OK_MSG : (uint8_t*)FAILED_MSG;
|
|
||||||
sendString("Remember you need to restart to active this change.\n\r");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
cmdIdx++;
|
|
||||||
}
|
|
||||||
sendString((const char*)messageToSend);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return retCode;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool restartCmd(uint8_t argc, char **args) {
|
|
||||||
HAL_NVIC_SystemReset();
|
|
||||||
// you won't come here ...
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const cmd_t CONFIG_COMMANDS[] = {
|
|
||||||
{ .name = "show", .cmdFunc = showConfigCmd,
|
|
||||||
.help = \
|
|
||||||
"show ................................. Show the configuration\n\r"
|
|
||||||
},
|
|
||||||
{ .name = "set", .cmdFunc = setCmd,
|
|
||||||
.help = \
|
|
||||||
"set .................................. Set configuration parameters\n\r" \
|
|
||||||
" Argument help gives a list of \n\r" \
|
|
||||||
" parameters\n\r"
|
|
||||||
},
|
|
||||||
{ .name = "restart", .cmdFunc = restartCmd,
|
|
||||||
.help = \
|
|
||||||
"restart .............................. Restart the system,\n\r" \
|
|
||||||
" Required to reload config\n\r"
|
|
||||||
},
|
|
||||||
{ .name = "END_OF_CMDS", .help = "",.cmdFunc = NULL }
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const cmd_t *getConfigCommands() {
|
|
||||||
return CONFIG_COMMANDS;
|
|
||||||
}
|
|
@ -130,7 +130,7 @@ void eepromReadConfigBlock(t_configBlock *destConfigBlock) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void eepromWriteConfigBlock(t_configBlock *srcConfigBlock) {
|
static void eepromWriteConfigBlock(t_configBlock *srcConfigBlock) {
|
||||||
for (uint8_t i = 0; i < (sizeof(*srcConfigBlock) / EEPROM_WRITE_BLOCK_SIZE); i++) {
|
for (uint8_t i = 0; i < (sizeof(*srcConfigBlock) / EEPROM_WRITE_BLOCK_SIZE); i++) {
|
||||||
eepromWrite(CONFIG_BLOCK_ADDR + (i * EEPROM_WRITE_BLOCK_SIZE), ((uint8_t*)srcConfigBlock) + (i * EEPROM_WRITE_BLOCK_SIZE), EEPROM_WRITE_BLOCK_SIZE);
|
eepromWrite(CONFIG_BLOCK_ADDR + (i * EEPROM_WRITE_BLOCK_SIZE), ((uint8_t*)srcConfigBlock) + (i * EEPROM_WRITE_BLOCK_SIZE), EEPROM_WRITE_BLOCK_SIZE);
|
||||||
eepromActiveDelay(EEPROM_AFTER_WRITE_DELAY);
|
eepromActiveDelay(EEPROM_AFTER_WRITE_DELAY);
|
||||||
|
@ -14,7 +14,6 @@
|
|||||||
#include <logger.h>
|
#include <logger.h>
|
||||||
#include <eeprom.h>
|
#include <eeprom.h>
|
||||||
#include <wizHelper.h>
|
#include <wizHelper.h>
|
||||||
#include <cmdHandler.h>
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#include <counter.h>
|
#include <counter.h>
|
||||||
|
|
||||||
@ -40,12 +39,6 @@ void my_setup_2() {
|
|||||||
|
|
||||||
wizInit();
|
wizInit();
|
||||||
|
|
||||||
if (HAL_GPIO_ReadPin(ADMIN_MODE_GPIO_Port, ADMIN_MODE_Pin)) {
|
|
||||||
show(LED_BLUE, BLINK);
|
|
||||||
coloredMsg(LED_RED, "STARTING ADMIN MODE");
|
|
||||||
cmdHandlerInit();
|
|
||||||
}
|
|
||||||
|
|
||||||
counterInit();
|
counterInit();
|
||||||
|
|
||||||
logMsg("Application running");
|
logMsg("Application running");
|
||||||
|
@ -1,52 +0,0 @@
|
|||||||
#include <cmdHelper.h>
|
|
||||||
#include <logger.h>
|
|
||||||
#include <PontCoopScheduler.h>
|
|
||||||
|
|
||||||
#include <eeprom.h>
|
|
||||||
|
|
||||||
|
|
||||||
static bool globalStatsCmd(uint8_t argc, char **args) {
|
|
||||||
uint32_t uptime = HAL_GetTick() / 1000;
|
|
||||||
sendFormatString(\
|
|
||||||
"Current uptime: %ld\n\r" \
|
|
||||||
"\n\r",
|
|
||||||
uptime
|
|
||||||
);
|
|
||||||
|
|
||||||
t_deviceStats *deviceStats = getGlobalDeviceStats();
|
|
||||||
sendFormatString(\
|
|
||||||
"Global Device statistics\n\r" \
|
|
||||||
" Total running hours: %ld\n\r" \
|
|
||||||
" Total power cycles: %ld\n\r" \
|
|
||||||
" Total watchdog resets: %ld\n\r" \
|
|
||||||
"\n\r",
|
|
||||||
deviceStats->totalRunningHours, deviceStats->totalPowercycles,
|
|
||||||
deviceStats->totalWatchdogResets
|
|
||||||
);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool resetStatsCmd(uint8_t argc, char **args) {
|
|
||||||
t_deviceStats *deviceStats = getGlobalDeviceStats();
|
|
||||||
deviceStats->totalWatchdogResets = 0;
|
|
||||||
schAdd(eepromHourlyUpdateDeviceStats, NULL, 1, 0);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
const cmd_t COMMANDS[] = {
|
|
||||||
{ .name = "stats", .cmdFunc = globalStatsCmd,
|
|
||||||
.help = \
|
|
||||||
"stats .......................... Show the device statistics\n\r"
|
|
||||||
},
|
|
||||||
{ .name = "resetStats", .cmdFunc = resetStatsCmd,
|
|
||||||
.help = \
|
|
||||||
"resetStats ..................... Reset the device statistics\n\r"
|
|
||||||
},
|
|
||||||
{ .name = "END_OF_CMDS", .help = "",.cmdFunc = NULL }
|
|
||||||
};
|
|
||||||
|
|
||||||
const cmd_t *getRegularCommands() {
|
|
||||||
return COMMANDS;
|
|
||||||
}
|
|
@ -6,8 +6,8 @@ MAIN_C_BAK=${MAIN_C}-bak
|
|||||||
IT_C=./Core/Src/stm32f1xx_it.c
|
IT_C=./Core/Src/stm32f1xx_it.c
|
||||||
IT_C_BAK=${IT_C}-bak
|
IT_C_BAK=${IT_C}-bak
|
||||||
|
|
||||||
MAKEFILE=./Makefile
|
# MAKEFILE=./Makefile
|
||||||
MAKEFILE_BAK=${MAKEFILE}-bak
|
# MAKEFILE_BAK=${MAKEFILE}-bak
|
||||||
|
|
||||||
PROCESSED="Processed by $0"
|
PROCESSED="Processed by $0"
|
||||||
|
|
||||||
@ -31,7 +31,7 @@ checkFile () {
|
|||||||
|
|
||||||
|
|
||||||
checkFile $MAIN_C $MAIN_C_BAK
|
checkFile $MAIN_C $MAIN_C_BAK
|
||||||
checkFile $MAKEFILE $MAKEFILE_BAK
|
# checkFile $MAKEFILE $MAKEFILE_BAK
|
||||||
checkFile $IT_C $IT_C_BAK
|
checkFile $IT_C $IT_C_BAK
|
||||||
|
|
||||||
cp $MAIN_C $MAIN_C_BAK
|
cp $MAIN_C $MAIN_C_BAK
|
||||||
@ -62,22 +62,22 @@ for I in hottislib/*.c; do
|
|||||||
SRC_EXT+="$I "
|
SRC_EXT+="$I "
|
||||||
done
|
done
|
||||||
|
|
||||||
cp $MAKEFILE $MAKEFILE_BAK
|
# cp $MAKEFILE $MAKEFILE_BAK
|
||||||
echo "# $PROCESSED" > $MAKEFILE
|
# echo "# $PROCESSED" > $MAKEFILE
|
||||||
cat $MAKEFILE_BAK | \
|
# cat $MAKEFILE_BAK | \
|
||||||
sed -e 's/\(-specs=nano.specs\)/\1 -u _printf_float/' \
|
# sed -e 's/\(-specs=nano.specs\)/\1 -u _printf_float/' \
|
||||||
-e 's/\(-Wall\)/\1 -Werror/' \
|
# -e 's/\(-Wall\)/\1 -Werror/' \
|
||||||
-e 's%\(# list of ASM program objects\)%OBJECTS += $(addprefix $(BUILD_DIR)/,w5500.a)\n\1%' \
|
# -e 's%\(# list of ASM program objects\)%OBJECTS += $(addprefix $(BUILD_DIR)/,w5500.a)\n\1%' \
|
||||||
-e 's,\($(BUILD_DIR)/%.o: %.c Makefile | $(BUILD_DIR)\),$(BUILD_DIR)/w5500.a:\n\t(cd ioLibrary_Driver \&\& $(MAKE) \&\& cp w5500.a ../$(BUILD_DIR) \&\& cd ..)\n\n\1,' \
|
# -e 's,\($(BUILD_DIR)/%.o: %.c Makefile | $(BUILD_DIR)\),$(BUILD_DIR)/w5500.a:\n\t(cd ioLibrary_Driver \&\& $(MAKE) \&\& cp w5500.a ../$(BUILD_DIR) \&\& cd ..)\n\n\1,' \
|
||||||
-e 's,\(C_SOURCES = \\\),\1\n'"$SRC_EXT"' \\,' \
|
# -e 's,\(C_SOURCES = \\\),\1\n'"$SRC_EXT"' \\,' \
|
||||||
-e 's,\(C_INCLUDES = \\\),\1\n-IioLibrary_Driver/Ethernet \\,' \
|
# -e 's,\(C_INCLUDES = \\\),\1\n-IioLibrary_Driver/Ethernet \\,' \
|
||||||
-e 's,\(C_INCLUDES = \\\),\1\n-IioLibrary_Driver/Internet/DHCP \\,' \
|
# -e 's,\(C_INCLUDES = \\\),\1\n-IioLibrary_Driver/Internet/DHCP \\,' \
|
||||||
-e 's,\(C_INCLUDES = \\\),\1\n-IioLibrary_Driver/Internet/DNS \\,' \
|
# -e 's,\(C_INCLUDES = \\\),\1\n-IioLibrary_Driver/Internet/DNS \\,' \
|
||||||
-e 's,\(C_INCLUDES = \\\),\1\n-IioLibrary_Driver/Internet/SNTP \\,' \
|
# -e 's,\(C_INCLUDES = \\\),\1\n-IioLibrary_Driver/Internet/SNTP \\,' \
|
||||||
-e 's,\(C_INCLUDES = \\\),\1\n-IUser/Inc \\,' \
|
# -e 's,\(C_INCLUDES = \\\),\1\n-IUser/Inc \\,' \
|
||||||
-e 's,\(C_INCLUDES = \\\),\1\n-Ihottislib \\,' \
|
# -e 's,\(C_INCLUDES = \\\),\1\n-Ihottislib \\,' \
|
||||||
>> $MAKEFILE
|
# >> $MAKEFILE
|
||||||
|
cp Makefile.sav Makefile
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
cp Makefile Makefile.sav
|
||||||
rm -rf build/ Core/ Drivers/ Makefile Makefile-bak startup_stm32f103xb.s STM32F103C8Tx_FLASH.ld
|
rm -rf build/ Core/ Drivers/ Makefile Makefile-bak startup_stm32f103xb.s STM32F103C8Tx_FLASH.ld
|
||||||
|
Reference in New Issue
Block a user