From cf1677d5bda7f39c2f51c26246fe2bd515251331 Mon Sep 17 00:00:00 2001 From: Oskar Weigl Date: Sun, 15 Oct 2017 02:03:02 -0700 Subject: [PATCH 1/3] lift up python tools, restructre other files --- Firmware/README.md | 4 +- Firmware/tools/.gitignore | 1 - .../motor_analysis}/350kvTP.PNG | Bin .../motor_analysis}/350kvVelli.PNG | Bin .../motor_analysis}/VelliPlot.m | 0 .../numeric_path_opt}/Main.m | 0 .../numeric_path_opt}/predictionmatrices.m | 0 {Firmware/tools => tools}/odrive/__init__.py | 0 {Firmware/tools => tools}/odrive/usbbulk.py | 0 {Firmware/tools => tools}/odrive/util.py | 0 .../test_communication.py | 0 various/path.c | 47 ------------------ 12 files changed, 2 insertions(+), 50 deletions(-) delete mode 100644 Firmware/tools/.gitignore rename {motor_analysis => analysis/motor_analysis}/350kvTP.PNG (100%) rename {motor_analysis => analysis/motor_analysis}/350kvVelli.PNG (100%) rename {motor_analysis => analysis/motor_analysis}/VelliPlot.m (100%) rename {numeric_path_opt => analysis/numeric_path_opt}/Main.m (100%) rename {numeric_path_opt => analysis/numeric_path_opt}/predictionmatrices.m (100%) rename {Firmware/tools => tools}/odrive/__init__.py (100%) rename {Firmware/tools => tools}/odrive/usbbulk.py (100%) rename {Firmware/tools => tools}/odrive/util.py (100%) rename Firmware/tools/test_bulk.py => tools/test_communication.py (100%) delete mode 100644 various/path.c diff --git a/Firmware/README.md b/Firmware/README.md index a1024e5c..5498b4b5 100644 --- a/Firmware/README.md +++ b/Firmware/README.md @@ -99,14 +99,14 @@ If you prefer to debug from eclipse, see [Setting up Eclipse development environ ## Communicating over USB There is currently a very primitive method to read/write configuration, commands and errors from the ODrive over the USB. -Please use the `ODriveFirmware/tools/test_bulk.py` python script for this. It is written for Python 3. +Please use the `tools/test_communication.py` python script for this. It is written for Python 3. Setup instructions as follows: * Install PyUSB (pip install --pre pysusb) * Plug in the STLink or another power source to power the ODrive board * Plug in a separate USB cable into the microUSB connector on ODrive * On Windows, use the [Zadig](http://zadig.akeo.ie/) utility to set ODrive (not STLink!) driver to libusb -* Run test_bulk.py +* Run `tools/test_communication.py` ### Command set The most accurate way to understand the commands is to read [the code](https://github.com/madcowswe/ODriveFirmware/blob/f19f1b78de4bd917284ff95bc61ca616ca9bacc4/MotorControl/low_level.c#L353) that parses the commands. diff --git a/Firmware/tools/.gitignore b/Firmware/tools/.gitignore deleted file mode 100644 index 9886e1ed..00000000 --- a/Firmware/tools/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.py[cod] diff --git a/motor_analysis/350kvTP.PNG b/analysis/motor_analysis/350kvTP.PNG similarity index 100% rename from motor_analysis/350kvTP.PNG rename to analysis/motor_analysis/350kvTP.PNG diff --git a/motor_analysis/350kvVelli.PNG b/analysis/motor_analysis/350kvVelli.PNG similarity index 100% rename from motor_analysis/350kvVelli.PNG rename to analysis/motor_analysis/350kvVelli.PNG diff --git a/motor_analysis/VelliPlot.m b/analysis/motor_analysis/VelliPlot.m similarity index 100% rename from motor_analysis/VelliPlot.m rename to analysis/motor_analysis/VelliPlot.m diff --git a/numeric_path_opt/Main.m b/analysis/numeric_path_opt/Main.m similarity index 100% rename from numeric_path_opt/Main.m rename to analysis/numeric_path_opt/Main.m diff --git a/numeric_path_opt/predictionmatrices.m b/analysis/numeric_path_opt/predictionmatrices.m similarity index 100% rename from numeric_path_opt/predictionmatrices.m rename to analysis/numeric_path_opt/predictionmatrices.m diff --git a/Firmware/tools/odrive/__init__.py b/tools/odrive/__init__.py similarity index 100% rename from Firmware/tools/odrive/__init__.py rename to tools/odrive/__init__.py diff --git a/Firmware/tools/odrive/usbbulk.py b/tools/odrive/usbbulk.py similarity index 100% rename from Firmware/tools/odrive/usbbulk.py rename to tools/odrive/usbbulk.py diff --git a/Firmware/tools/odrive/util.py b/tools/odrive/util.py similarity index 100% rename from Firmware/tools/odrive/util.py rename to tools/odrive/util.py diff --git a/Firmware/tools/test_bulk.py b/tools/test_communication.py similarity index 100% rename from Firmware/tools/test_bulk.py rename to tools/test_communication.py diff --git a/various/path.c b/various/path.c deleted file mode 100644 index 341e5c4b..00000000 --- a/various/path.c +++ /dev/null @@ -1,47 +0,0 @@ -#include - -#include - -void output(float x, float y, float str, float param) { - printf("{ %05.1ff, %05.1ff, %1.1ff, %06.1ff },\n", (x+1)*75, (y+1)*75, str, param); -} - -void searchat(float x, float y) { - output(x, y, 0.4, 500); - //output(x+0.02, y, 0.4, 1000); - //output(x, y+0.02, 0.4, 1000); - //output(x-0.02, y, 0.4, 1000); - //output(x, y-0.02, 0.4, 1000); -} - -void pickupto(float x, float y) { - output(x, y, 0.4, 0); - //output(x, y, 0.4, 1000); - output(x, y, 0, 1000); -} - -void moveto(float x, float y) { - output(x, y, 0, 0); -} - -#define POINTS 15 -#define TWOPI (3.1415*2.0) - -int main(int argc, char** argv) { - moveto(-1,-1); - - for (int j=0; j<2; j++) - for (int i=0; i Date: Tue, 17 Oct 2017 17:15:51 -0700 Subject: [PATCH 2/3] put float printf flag in LDFLAGS --- Firmware/Makefile | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/Firmware/Makefile b/Firmware/Makefile index 081f17b8..adba9237 100644 --- a/Firmware/Makefile +++ b/Firmware/Makefile @@ -13,9 +13,7 @@ TARGET = ODriveFirmware # debug build? DEBUG = 1 # optimization -# OPT = -O3 -ffast-math -flto -# OPT = -O3 -ffast-math -OPT = -O0 -ffast-math -u _printf_float -u _scanf_float +OPT = -Og -ffast-math ####################################### # pathes @@ -78,7 +76,7 @@ C_SOURCES = \ Src/usbd_cdc_if.c \ Src/syscalls.c \ MotorControl/utils.c \ - MotorControl/low_level.c + MotorControl/low_level.c ASM_SOURCES = \ startup/startup_stm32f405xx.s @@ -134,7 +132,7 @@ LDSCRIPT = STM32F405RGTx_FLASH.ld # libraries LIBS = -lc -lm -lnosys -larm_cortexM4lf_math LIBDIR = -LDrivers/CMSIS/Lib -LDFLAGS = -mthumb -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard -specs=nosys.specs -specs=nano.specs $(OPT) -T$(LDSCRIPT) $(LIBDIR) $(LIBS) -Wl,-Map=$(BUILD_DIR)/$(TARGET).map,--cref -Wl,--gc-sections +LDFLAGS = -mthumb -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard -specs=nosys.specs -specs=nano.specs -u _printf_float -u _scanf_float $(OPT) -T$(LDSCRIPT) $(LIBDIR) $(LIBS) -Wl,-Map=$(BUILD_DIR)/$(TARGET).map,--cref -Wl,--gc-sections # default action: build all all: $(BUILD_DIR)/$(TARGET).elf $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).bin @@ -152,7 +150,7 @@ vpath %.cpp $(sort $(dir $(CPP_SOURCES))) OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(ASM_SOURCES:.s=.o))) vpath %.s $(sort $(dir $(ASM_SOURCES))) -$(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 $@ $(BUILD_DIR)/%.o: %.s Makefile | $(BUILD_DIR) From 7dc6a464f48ccc03a5a0268def462ee9cff95d85 Mon Sep 17 00:00:00 2001 From: Oskar Weigl Date: Tue, 17 Oct 2017 17:28:35 -0700 Subject: [PATCH 3/3] fix USB buffer drop char error --- Firmware/Src/usbd_cdc_if.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Firmware/Src/usbd_cdc_if.c b/Firmware/Src/usbd_cdc_if.c index 09b2fc81..67b037bf 100644 --- a/Firmware/Src/usbd_cdc_if.c +++ b/Firmware/Src/usbd_cdc_if.c @@ -275,7 +275,7 @@ static int8_t CDC_Receive_FS (uint8_t* Buf, uint32_t *Len) int null_idx = MACRO_MIN(*Len, APP_RX_DATA_SIZE-1); Buf[null_idx] = 0; - motor_parse_cmd(Buf, *Len); + motor_parse_cmd(Buf, *Len+1); return (USBD_OK); /* USER CODE END 6 */