mirror of
https://github.com/yoboujon/dumber.git
synced 2025-06-08 13:50:49 +02:00
Correction d'un bug uniquement existant hors debug, lié a une mauvaise gestion des chaines de caractere de taille nulle dans VerifyChecksum + reprise des priorité de taches (reduction de la priorité des taches moteurs
This commit is contained in:
parent
e1418a9144
commit
2932a2380d
9 changed files with 97 additions and 65 deletions
18
.gitignore
vendored
18
.gitignore
vendored
|
@ -43,6 +43,18 @@ GUI
|
|||
# Image rpi
|
||||
*.img
|
||||
|
||||
# Fichiers Images
|
||||
*.jpg
|
||||
*.jpeg
|
||||
*.png
|
||||
*.tiff
|
||||
*.bmp
|
||||
*.gif
|
||||
|
||||
# Fichiers documentation
|
||||
*.pdf
|
||||
*.chm
|
||||
|
||||
# Archives
|
||||
*.zip
|
||||
*.tar
|
||||
|
@ -65,3 +77,9 @@ GUI
|
|||
/software/raspberry/superviseur-robot/superviseur/dist/
|
||||
/software/raspberry/testeur/testeur/build/
|
||||
/software/raspberry/testeur/testeur/dist/
|
||||
/doc/Doc\ robot/doxygen/
|
||||
/software/robot/Debug/
|
||||
/software/robot/Release/
|
||||
/hardware/meca/Dumber_2022/Pieces/OldVersions/
|
||||
/hardware/meca/Dumber_2022/OldVersions/
|
||||
/hardware/meca/Dumber_2022/Pieces/export/
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
</tool>
|
||||
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.1474341646" name="MCU GCC Compiler" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler">
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.debuglevel.620486962" name="Debug level" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.debuglevel" useByScannerDiscovery="false" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.debuglevel.value.g3" valueType="enumerated"/>
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level.2040942504" name="Optimization level" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level" useByScannerDiscovery="false" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level.value.o2" valueType="enumerated"/>
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level.2040942504" name="Optimization level" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level" useByScannerDiscovery="false" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level.value.o0" valueType="enumerated"/>
|
||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.definedsymbols.1441075970" name="Define symbols (-D)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.definedsymbols" useByScannerDiscovery="false" valueType="definedSymbols">
|
||||
<listOptionValue builtIn="false" value="DEBUG"/>
|
||||
<listOptionValue builtIn="false" value="USE_HAL_DRIVER"/>
|
||||
|
@ -106,6 +106,7 @@
|
|||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_coreid.242496753" name="Core" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_coreid" useByScannerDiscovery="false" value="0" valueType="string"/>
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_board.176318081" name="Board" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_board" useByScannerDiscovery="false" value="genericBoard" valueType="string"/>
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.defaults.1275174120" name="Defaults" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.defaults" useByScannerDiscovery="false" value="com.st.stm32cube.ide.common.services.build.inputs.revA.1.0.5 || Release || false || Executable || com.st.stm32cube.ide.mcu.gnu.managedbuild.option.toolchain.value.workspace || STM32L071CBTx || 0 || 0 || arm-none-eabi- || ${gnu_tools_for_stm32_compiler_path} || ../Middlewares/Third_Party/FreeRTOS/Source/include | ../Drivers/CMSIS/Include | ../Core/Inc | ../Drivers/STM32L0xx_HAL_Driver/Inc | ../Drivers/CMSIS/Device/ST/STM32L0xx/Include | ../Drivers/STM32L0xx_HAL_Driver/Inc/Legacy | ../Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2 | ../Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM0 || || || USE_HAL_DRIVER | STM32L010x6 || || Drivers | Core/Startup | Middlewares | Core || || || ${workspace_loc:/${ProjName}/STM32L071CBTx_FLASH.ld} || true || NonSecure || || secure_nsclib.o || || None || " valueType="string"/>
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.converthex.689723227" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.converthex" value="true" valueType="boolean"/>
|
||||
<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.targetplatform.1084432067" isAbstract="false" osList="all" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.targetplatform"/>
|
||||
<builder buildPath="${workspace_loc:/Dumber3}/Release" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.builder.84530615" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" parallelBuildOn="true" parallelizationNumber="optimal" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.builder"/>
|
||||
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.1851868879" name="MCU GCC Assembler" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler">
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
*/
|
||||
|
||||
/**
|
||||
* @mainpage Dumber 3
|
||||
* @mainpage Dumber 3 version 3.1
|
||||
*
|
||||
* Dumber is a robot used at INSA-GEI, Toulouse, France for realtime computer science teaching.
|
||||
* Robot is basically controlled by a supervisor program and move depending on commands send by supervisor.
|
||||
|
@ -149,9 +149,6 @@ APPLICATION_Timeout systemTimeout = {0};
|
|||
* @return None
|
||||
*/
|
||||
void APPLICATION_Init(void) {
|
||||
/* Init du support RTOS (notamment le timer de run time) */
|
||||
//RTOS_SUPPORT_Init(); /* <- used for freertos run time usage */
|
||||
|
||||
/* Init des messages box */
|
||||
MESSAGE_Init();
|
||||
|
||||
|
@ -213,7 +210,6 @@ void APPLICATION_Thread(void* params) {
|
|||
|
||||
if (decodedCmd != NULL) {
|
||||
if (decodedCmd->type==CMD_NONE) {
|
||||
//XBEE_SendData("hello");
|
||||
cmdSendAnswer(ANS_UNKNOWN);
|
||||
} else if (decodedCmd->type == CMD_INVALID_CHECKSUM) {
|
||||
cmdSendAnswer(ANS_ERR);
|
||||
|
@ -266,7 +262,8 @@ void APPLICATION_Thread(void* params) {
|
|||
* Don't know real source of pb
|
||||
*/
|
||||
|
||||
if (decodedCmd->type!=CMD_NONE) free(receivedCMD);
|
||||
//if (decodedCmd->type!=CMD_NONE) free(receivedCMD);
|
||||
free(receivedCMD);
|
||||
|
||||
/* End workaround */
|
||||
|
||||
|
|
|
@ -88,7 +88,7 @@ char cmdVerifyChecksum(char* str);
|
|||
*
|
||||
* @warning This function use memory allocation for creating a copy of the original string. Be sure to free memory after use.
|
||||
*
|
||||
* @todo Error related to memory allocation (allocation failed) is not managed -> should generate a Panic
|
||||
* @remark Error related to memory allocation (allocation failed) is managed directly into malloc -> generate a Panic
|
||||
*
|
||||
* @param[in] str string without checksum
|
||||
* @return string with checksum added
|
||||
|
@ -97,6 +97,7 @@ char cmdVerifyChecksum(char* str);
|
|||
char* cmdAddChecksum(const char* str) {
|
||||
uint16_t j;
|
||||
unsigned char checksum=0;
|
||||
|
||||
char *outstr = (char*) malloc(strlen(str)+2); // +1 for checksum to add, +1 for zero ending
|
||||
|
||||
for (j = 0; str[j] != '\r'; j++) {
|
||||
|
@ -128,6 +129,7 @@ char cmdVerifyChecksum(char* str) {
|
|||
uint16_t j;
|
||||
uint16_t length;
|
||||
unsigned char checksum=0;
|
||||
char status=0;
|
||||
|
||||
length = strlen(str);
|
||||
/* Warning: str should be without ending CR (0x0D) character, so, a ping command should be
|
||||
|
@ -135,7 +137,10 @@ char cmdVerifyChecksum(char* str) {
|
|||
*
|
||||
* in the loop after, ending length is length of the caommand string whithout last char, the checksum
|
||||
* so, we have j<length-1
|
||||
*
|
||||
* In case string as length 0 (empty string, return 0
|
||||
*/
|
||||
if (length!=0) {
|
||||
for (j = 0; j<length-1; j++) {
|
||||
checksum ^= str[j];
|
||||
}
|
||||
|
@ -146,14 +151,17 @@ char cmdVerifyChecksum(char* str) {
|
|||
if (str[j] == checksum) {
|
||||
/*str[length - 2] = 13;
|
||||
str[length - 1] = 0;
|
||||
str[length] = 0;*/
|
||||
str[length] = 0;
|
||||
*/
|
||||
|
||||
str[length - 1] = 0; /* we remove checksum char */
|
||||
str[length] = 0;
|
||||
|
||||
return 1;
|
||||
} else
|
||||
return 0;
|
||||
status = 1;
|
||||
}
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -173,6 +181,8 @@ char cmdVerifyChecksum(char* str) {
|
|||
*
|
||||
* Generic structure returned may contains CMD_NONE if command is unknown or CMD_INVALID_CHECKSUM if checksum is not valid
|
||||
*
|
||||
* @remark Error related to memory allocation (allocation failed) is managed directly into malloc -> generate a Panic
|
||||
*
|
||||
* @remark Returned value is always cast on a CMD_Generic type, but may contains CMD_Move or CMD_Turn structure. It is
|
||||
* user responsibility to check type field inside structure and cast accordingly returned value to correct structure.
|
||||
*/
|
||||
|
@ -281,8 +291,6 @@ CMD_Generic* cmdDecode(char* cmd, uint8_t length) {
|
|||
* @warning This function use cmdAddChecksum, so indirectly make use of memory allocation for sending message to XBEE mailbox.
|
||||
* Be sure to release memory in XBEE driver after retrieving message from mailbox.
|
||||
*
|
||||
* @todo Error related to memory allocation (allocation failed) is not managed -> should generate a Panic
|
||||
*
|
||||
* @todo Maybe duplication between this function and cmdSendString: see if only one function with a macro/wrapper could be used
|
||||
*
|
||||
* @param[in] ans string containing answer to send, without checksum
|
||||
|
@ -312,8 +320,6 @@ void cmdSendAnswer(uint8_t ans) {
|
|||
* @warning This function use cmdAddChecksum, so indirectly make use of memory allocation for sending message to XBEE mailbox.
|
||||
* Be sure to release memory in XBEE driver after retrieving message from mailbox.
|
||||
*
|
||||
* @todo Error related to memory allocation (allocation failed) is not managed -> should generate a Panic
|
||||
*
|
||||
* @todo Maybe duplication between this function and cmdSendAnswer: see if only one function with a macro/wrapper could be used
|
||||
*
|
||||
* @param[in] str string containing answer to send without checksum
|
||||
|
@ -340,8 +346,6 @@ void cmdSendString(char *str) {
|
|||
* @warning This function use cmdAddChecksum, so indirectly make use of memory allocation for sending message to XBEE mailbox.
|
||||
* Be sure to release memory in XBEE driver after retrieving message from mailbox.
|
||||
*
|
||||
* @todo Error related to memory allocation (allocation failed) is not managed -> should generate a Panic
|
||||
*
|
||||
* @todo Check batterystate type used here: seems a bit overkill (16bit for only 6 states) -> enum should be better
|
||||
*
|
||||
* @param[in] batteryState current battery state
|
||||
|
@ -374,8 +378,6 @@ void cmdSendBatteryLevel(uint16_t batteryState) {
|
|||
* @warning This function use cmdAddChecksum, so indirectly make use of memory allocation for sending message to XBEE mailbox.
|
||||
* Be sure to release memory in XBEE driver after retrieving message from mailbox.
|
||||
*
|
||||
* @todo Error related to memory allocation (allocation failed) is not managed -> should generate a Panic
|
||||
*
|
||||
* @param None
|
||||
* @return None
|
||||
*/
|
||||
|
@ -399,8 +401,6 @@ void cmdSendVersion(void) {
|
|||
* @warning This function use cmdAddChecksum, so indirectly make use of memory allocation for sending message to XBEE mailbox.
|
||||
* Be sure to release memory in XBEE driver after retrieving message from mailbox.
|
||||
*
|
||||
* @todo Error related to memory allocation (allocation failed) is not managed -> should generate a Panic
|
||||
*
|
||||
* @param[in] state current robot state
|
||||
* @return None
|
||||
*/
|
||||
|
|
|
@ -44,8 +44,8 @@
|
|||
* Version in plain text and as a numeric value
|
||||
*/
|
||||
///@{
|
||||
#define SYSTEM_VERSION_STR "3.0"
|
||||
#define SYSTEM_VERSION 0x0300 // Upper byte: major version, lower byte: minor version
|
||||
#define SYSTEM_VERSION_STR "3.1"
|
||||
#define SYSTEM_VERSION 0x0301 // Upper byte: major version, lower byte: minor version
|
||||
///@}
|
||||
|
||||
#define STACK_SIZE 96
|
||||
|
@ -59,9 +59,9 @@
|
|||
#define PriorityXbeeRX (configMAX_PRIORITIES -2)
|
||||
#define PriorityXbeeTX (configMAX_PRIORITIES -3)
|
||||
#define PriorityLedsHandler (configMAX_PRIORITIES -4)
|
||||
#define PriorityMotorsAsservissement (configMAX_PRIORITIES -5)
|
||||
#define PriorityApplicationHandler (configMAX_PRIORITIES -6)
|
||||
#define PriorityBatteryHandler (configMAX_PRIORITIES -7)
|
||||
#define PriorityApplicationHandler (configMAX_PRIORITIES -5)
|
||||
#define PriorityBatteryHandler (configMAX_PRIORITIES -6)
|
||||
#define PriorityMotorsAsservissement (configMAX_PRIORITIES -7)
|
||||
#define PriorityMotorsHandler (configMAX_PRIORITIES -8)
|
||||
#define PrioritySequenceurTimeout (configMAX_PRIORITIES -9)
|
||||
|
||||
|
|
|
@ -102,9 +102,18 @@ void TIM7_IRQHandler(void) {
|
|||
RTOS_SUPPORT_counter16bitUpper++;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function only here to overload PreSleepProcessing function generated by CubeMX
|
||||
* and that reset ulExpectedIdleTime, disabling power saving
|
||||
* Creating this funcion here, that does not modify ulExpectedIdleTime, permit to enable
|
||||
* tickless power saving provided by FreeRTOS in idle task.
|
||||
*/
|
||||
void PreSleepProcessing(uint32_t *ulExpectedIdleTime)
|
||||
{
|
||||
|
||||
/*
|
||||
* Do nothing, do not modify ulExpectedIdleTime and, this way,
|
||||
* enable tickless power saving in idle task
|
||||
*/
|
||||
}
|
||||
/**
|
||||
* @}
|
||||
|
|
|
@ -35,6 +35,9 @@
|
|||
#include "stm32l0xx_ll_usart.h"
|
||||
|
||||
#include "panic.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/** @addtogroup Application_Software
|
||||
* @{
|
||||
*/
|
||||
|
@ -327,7 +330,9 @@ void XBEE_RX_IRQHandler(void) {
|
|||
*/
|
||||
|
||||
if (data != XBEE_ENDING_CHAR) { // end of command not received
|
||||
if (data != 0x00) {
|
||||
rxBuffer[rxIndex] = data;
|
||||
|
||||
rxIndex++;
|
||||
if (rxIndex>=XBEE_RX_BUFFER_MAX_LENGTH)
|
||||
rxIndex=0;
|
||||
|
@ -335,6 +340,7 @@ void XBEE_RX_IRQHandler(void) {
|
|||
rxCmdLength++;
|
||||
if (rxCmdLength>=XBEE_RX_BUFFER_MAX_LENGTH)
|
||||
rxCmdLength=0;
|
||||
}
|
||||
} else { // end of command received
|
||||
rxBuffer[rxIndex] = 0; // ending zero for C string
|
||||
xSemaphoreGiveFromISR( xHandleSemaphoreRX, &xHigherPriorityTaskWoken ); /* send event to receive task to process received task */
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include "stm32l0xx_it.h"
|
||||
/* Private includes ----------------------------------------------------------*/
|
||||
/* USER CODE BEGIN Includes */
|
||||
#include "leds.h"
|
||||
/* USER CODE END Includes */
|
||||
|
||||
/* Private typedef -----------------------------------------------------------*/
|
||||
|
|
|
@ -108,6 +108,6 @@
|
|||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
|
||||
<listEntry value="4"/>
|
||||
</listAttribute>
|
||||
<stringAttribute key="org.eclipse.dsf.launch.MEMORY_BLOCKS" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?><memoryBlockExpressionList context="reserved-for-future-use"/>"/>
|
||||
<stringAttribute key="org.eclipse.dsf.launch.MEMORY_BLOCKS" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?><memoryBlockExpressionList context="reserved-for-future-use"><gdbmemoryBlockExpression address="536879848" label="incomingData"/></memoryBlockExpressionList>"/>
|
||||
<stringAttribute key="process_factory_id" value="com.st.stm32cube.ide.mcu.debug.launch.HardwareDebugProcessFactory"/>
|
||||
</launchConfiguration>
|
||||
|
|
Loading…
Add table
Reference in a new issue