diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json new file mode 100644 index 0000000..ee202d8 --- /dev/null +++ b/.vscode/c_cpp_properties.json @@ -0,0 +1,16 @@ +{ + "configurations": [ + { + "name": "Linux", + "includePath": [ + "${workspaceFolder}/**" + ], + "defines": [], + "compilerPath": "/usr/bin/clang", + "cStandard": "c11", + "cppStandard": "c++17", + "intelliSenseMode": "clang-x64" + } + ], + "version": 4 +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..29327bf --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,16 @@ +{ + // See https://go.microsoft.com/fwlink/?LinkId=733558 + // for the documentation about the tasks.json format + "version": "2.0.0", + "tasks": [ + { + "taskName": "Compile on raspberry", + "command": "rsync -az '${file}' 10.105.1.6:~ && ssh server.example.org 'chmod +x ./${fileBasename}; ./${fileBasename}'", + "type": "shell", + "group": { + "kind": "build", + "isDefault": true + } + } + ] +} \ No newline at end of file diff --git a/software/raspberry/superviseur-robot/Essai_VSC/CMakeLists.txt b/software/raspberry/superviseur-robot/Essai_VSC/CMakeLists.txt new file mode 100644 index 0000000..33ee530 --- /dev/null +++ b/software/raspberry/superviseur-robot/Essai_VSC/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.9) +project(stress) + +set(CMAKE_CXX_STANDARD 11) + +set(SOURCE_FILES main.cpp ../src/robot.cpp ../src/robot.h) +add_executable(stress ${SOURCE_FILES}) \ No newline at end of file diff --git a/software/raspberry/superviseur-robot/example/stress/main.cpp b/software/raspberry/superviseur-robot/Essai_VSC/main.cpp similarity index 94% rename from software/raspberry/superviseur-robot/example/stress/main.cpp rename to software/raspberry/superviseur-robot/Essai_VSC/main.cpp index 2fc71fc..94ec11e 100644 --- a/software/raspberry/superviseur-robot/example/stress/main.cpp +++ b/software/raspberry/superviseur-robot/Essai_VSC/main.cpp @@ -1,6 +1,6 @@ #include -#include "../../src/definitions.h" -#include "../../src/robot.h" +#include "../src/definitions.h" +#include "../src/robot.h" #include #define NB_TEST 50 @@ -19,7 +19,7 @@ int nb_unknown_cmd; int flipflop; int main() { - if (open_communication_robot("/dev/ttyUSB0") != 0) { + if (open_communication_robot() != 0) { std::cout << "Unable to open com port" << std::endl; return -1; diff --git a/software/raspberry/superviseur-robot/example/.cproject b/software/raspberry/superviseur-robot/example/.cproject new file mode 100644 index 0000000..f17ed7c --- /dev/null +++ b/software/raspberry/superviseur-robot/example/.cproject @@ -0,0 +1,145 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/software/raspberry/superviseur-robot/example/.gitignore b/software/raspberry/superviseur-robot/example/.gitignore new file mode 100644 index 0000000..0ae6ecd --- /dev/null +++ b/software/raspberry/superviseur-robot/example/.gitignore @@ -0,0 +1,2 @@ +/Debug/ +/Server test/ diff --git a/software/raspberry/superviseur-robot/example/.gitignores b/software/raspberry/superviseur-robot/example/.gitignores new file mode 100644 index 0000000..e69de29 diff --git a/software/raspberry/superviseur-robot/example/.project b/software/raspberry/superviseur-robot/example/.project new file mode 100644 index 0000000..9fdc26d --- /dev/null +++ b/software/raspberry/superviseur-robot/example/.project @@ -0,0 +1,27 @@ + + + Dumber-Robot-Exemple + + + + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder + clean,full,incremental, + + + + + org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder + full,incremental, + + + + + + org.eclipse.cdt.core.cnature + org.eclipse.cdt.core.ccnature + org.eclipse.cdt.managedbuilder.core.managedBuildNature + org.eclipse.cdt.managedbuilder.core.ScannerConfigNature + + diff --git a/software/raspberry/superviseur-robot/example/.settings/language.settings.xml b/software/raspberry/superviseur-robot/example/.settings/language.settings.xml new file mode 100644 index 0000000..9abb758 --- /dev/null +++ b/software/raspberry/superviseur-robot/example/.settings/language.settings.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/software/raspberry/superviseur-robot/example/stress/CMakeLists.txt b/software/raspberry/superviseur-robot/example/CMakeLists.txt similarity index 100% rename from software/raspberry/superviseur-robot/example/stress/CMakeLists.txt rename to software/raspberry/superviseur-robot/example/CMakeLists.txt diff --git a/software/raspberry/superviseur-robot/example/lib b/software/raspberry/superviseur-robot/example/lib new file mode 120000 index 0000000..e057607 --- /dev/null +++ b/software/raspberry/superviseur-robot/example/lib @@ -0,0 +1 @@ +../src/ \ No newline at end of file diff --git a/software/raspberry/superviseur-robot/example/serialTest/lib/subdir.mk b/software/raspberry/superviseur-robot/example/serialTest/lib/subdir.mk new file mode 100644 index 0000000..acc4132 --- /dev/null +++ b/software/raspberry/superviseur-robot/example/serialTest/lib/subdir.mk @@ -0,0 +1,28 @@ +################################################################################ +# Automatically-generated file. Do not edit! +################################################################################ + +# Add inputs and outputs from these tool invocations to the build variables +CPP_SRCS += \ +../lib/Robot.cpp \ +../lib/Serial.cpp \ +../lib/TcpServer.cpp \ +../lib/message.cpp + +OBJS += \ +./lib/Robot.o \ +./lib/Serial.o \ +./lib/TcpServer.o \ +./lib/message.o + +CPP_DEPS += \ +./lib/Robot.d \ +./lib/Serial.d \ +./lib/TcpServer.d \ +./lib/message.d + + +# Each subdirectory must supply rules for building sources it contributes +lib/%.o: ../lib/%.cpp + g++ -I"/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/example/lib" -I"/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/example/src" -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@)" -o "$@" "$<" + diff --git a/software/raspberry/superviseur-robot/example/serialTest/makefile b/software/raspberry/superviseur-robot/example/serialTest/makefile new file mode 100644 index 0000000..2e10274 --- /dev/null +++ b/software/raspberry/superviseur-robot/example/serialTest/makefile @@ -0,0 +1,56 @@ +################################################################################ +# Automatically-generated file. Do not edit! +################################################################################ + +-include ../makefile.init + +RM := rm -rf + +# All of the sources participating in the build are defined here +-include sources.mk +-include src/subdir.mk +-include lib/subdir.mk +-include subdir.mk +-include objects.mk + +ifneq ($(MAKECMDGOALS),clean) +ifneq ($(strip $(CC_DEPS)),) +-include $(CC_DEPS) +endif +ifneq ($(strip $(C++_DEPS)),) +-include $(C++_DEPS) +endif +ifneq ($(strip $(C_UPPER_DEPS)),) +-include $(C_UPPER_DEPS) +endif +ifneq ($(strip $(CXX_DEPS)),) +-include $(CXX_DEPS) +endif +ifneq ($(strip $(CPP_DEPS)),) +-include $(CPP_DEPS) +endif +ifneq ($(strip $(C_DEPS)),) +-include $(C_DEPS) +endif +endif + +-include ../makefile.defs + +# Add inputs and outputs from these tool invocations to the build variables + +# All Target +all: Dumber-Robot-Exemple + +# Tool invocations +Dumber-Robot-Exemple: $(OBJS) $(USER_OBJS) + g++ -o "Dumber-Robot-Exemple" $(OBJS) $(USER_OBJS) $(LIBS) + +# Other Targets +clean: + -$(RM) $(CC_DEPS)$(C++_DEPS)$(EXECUTABLES)$(C_UPPER_DEPS)$(CXX_DEPS)$(OBJS)$(CPP_DEPS)$(C_DEPS) Dumber-Robot-Exemple + -@echo ' ' + +.PHONY: all clean dependents +.SECONDARY: + +-include ../makefile.targets diff --git a/software/raspberry/superviseur-robot/example/serialTest/objects.mk b/software/raspberry/superviseur-robot/example/serialTest/objects.mk new file mode 100644 index 0000000..742c2da --- /dev/null +++ b/software/raspberry/superviseur-robot/example/serialTest/objects.mk @@ -0,0 +1,8 @@ +################################################################################ +# Automatically-generated file. Do not edit! +################################################################################ + +USER_OBJS := + +LIBS := + diff --git a/software/raspberry/superviseur-robot/example/serialTest/sources.mk b/software/raspberry/superviseur-robot/example/serialTest/sources.mk new file mode 100644 index 0000000..af09391 --- /dev/null +++ b/software/raspberry/superviseur-robot/example/serialTest/sources.mk @@ -0,0 +1,28 @@ +################################################################################ +# Automatically-generated file. Do not edit! +################################################################################ + +C_UPPER_SRCS := +CXX_SRCS := +C++_SRCS := +OBJ_SRCS := +CC_SRCS := +ASM_SRCS := +CPP_SRCS := +C_SRCS := +O_SRCS := +S_UPPER_SRCS := +CC_DEPS := +C++_DEPS := +EXECUTABLES := +C_UPPER_DEPS := +CXX_DEPS := +OBJS := +CPP_DEPS := +C_DEPS := + +# Every subdirectory with source files must be described here +SUBDIRS := \ +lib \ +src \ + diff --git a/software/raspberry/superviseur-robot/example/serialTest/src/subdir.mk b/software/raspberry/superviseur-robot/example/serialTest/src/subdir.mk new file mode 100644 index 0000000..b2d1bab --- /dev/null +++ b/software/raspberry/superviseur-robot/example/serialTest/src/subdir.mk @@ -0,0 +1,22 @@ +################################################################################ +# Automatically-generated file. Do not edit! +################################################################################ + +# Add inputs and outputs from these tool invocations to the build variables +CPP_SRCS += \ +../src/serialTest.cpp \ +../src/serverTest.cpp + +OBJS += \ +./src/serialTest.o \ +./src/serverTest.o + +CPP_DEPS += \ +./src/serialTest.d \ +./src/serverTest.d + + +# Each subdirectory must supply rules for building sources it contributes +src/%.o: ../src/%.cpp + g++ -I"/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/example/lib" -I"/home/dimercur/Documents/Travail/git/dumber/software/raspberry/superviseur-robot/example/src" -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@)" -o "$@" "$<" + diff --git a/software/raspberry/superviseur-robot/example/src/serialTest.cpp b/software/raspberry/superviseur-robot/example/src/serialTest.cpp new file mode 100644 index 0000000..ebf0666 --- /dev/null +++ b/software/raspberry/superviseur-robot/example/src/serialTest.cpp @@ -0,0 +1,186 @@ +/******************************************************************************* + * Copyright (c) 2018 INSA - GEI, Toulouse, France. + * All rights reserved. This program and the accompanying materials + * are made available "AS IS", without any warranty of any kind. + * + * INSA assumes no responsibility for errors or omissions in the + * software or documentation available. + * + * Part of code Copyright ST Microelectronics. + * + * Contributors: + * Lucien Senaneuch - Initial API and implementation + * Sebastien DI MERCURIO - Maintainer since Octobre 2018 + *******************************************************************************/ + +#include +#include +#include "Robot.h" +#include + +using namespace std; + +#define NB_TEST 50 +#define DELAY_BETWEEN_TEST 1000000 // 1 seconde + +int nb_retries; +int nb_test; + +int laststatus; +int nb_success; +int nb_timeout; +int nb_unknown_cmd; + +int flipflop; + +int Test(Robot rob) { + try { + if (flipflop == 0) { + rob.Move(100); + } else { + rob.Move(-100); + } + } catch (string e) { + //if (e.find("Timeout")==string.npos) + // status=ROBOT_TIMED_OUT; + + + } + + return rob.GetLastCommandStatus();; +} + +int main() { + Robot myRobot; + + if (myRobot.Open("/dev/ttyUSB0") == SUCCESS) { // ouverture de la com avec le robot + + std::cout << "Start robot: "; + try { + myRobot.StartWithoutWatchdog(); + } catch ( string e ) { + std::cerr << std::endl << e << std::endl; + return 1; + } + + if (myRobot.GetLastCommandStatus()==SUCCESS) + std::cout << "Ok" < +#include "Robot.h" +#include "TcpServer.h" + +int main (void) +{ + TcpServer server; + int clientFD; + string msgIn, msgOut,tmp; + bool finish; + + Robot robot; + + cout << "TCP server example" << endl; + + cout << "Bind and listen on port 1337: "; + try { + server.Listen(1337); + } + catch ( const invalid_argument &ia ) { + cerr << "Error binding server: " << ia.what() << endl; + return 1; + } + + cout << "Ok" < - - - - - - - - - - - - - \ No newline at end of file diff --git a/software/raspberry/superviseur-robot/example/stress/.idea/misc.xml b/software/raspberry/superviseur-robot/example/stress/.idea/misc.xml deleted file mode 100644 index 79b3c94..0000000 --- a/software/raspberry/superviseur-robot/example/stress/.idea/misc.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/software/raspberry/superviseur-robot/example/stress/.idea/modules.xml b/software/raspberry/superviseur-robot/example/stress/.idea/modules.xml deleted file mode 100644 index e99616d..0000000 --- a/software/raspberry/superviseur-robot/example/stress/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/software/raspberry/superviseur-robot/example/stress/.idea/stress.iml b/software/raspberry/superviseur-robot/example/stress/.idea/stress.iml deleted file mode 100644 index f08604b..0000000 --- a/software/raspberry/superviseur-robot/example/stress/.idea/stress.iml +++ /dev/null @@ -1,2 +0,0 @@ - - \ No newline at end of file diff --git a/software/raspberry/superviseur-robot/example/stress/.idea/vcs.xml b/software/raspberry/superviseur-robot/example/stress/.idea/vcs.xml deleted file mode 100644 index b2bdec2..0000000 --- a/software/raspberry/superviseur-robot/example/stress/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/software/raspberry/superviseur-robot/example/stress/.idea/workspace.xml b/software/raspberry/superviseur-robot/example/stress/.idea/workspace.xml deleted file mode 100644 index dd1259b..0000000 --- a/software/raspberry/superviseur-robot/example/stress/.idea/workspace.xml +++ /dev/null @@ -1,294 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - true - DEFINITION_ORDER - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -