diff --git a/README.md b/README.md index 073e1a2..b60e1ab 100644 --- a/README.md +++ b/README.md @@ -3,4 +3,18 @@ This repository contains the example of the device handler for the Arduino managing the temperaure, environmental and accelerometer sensors. It is employed the fsfw with the release 0.01. The code has the obejective of reading the serial data output of the Arduino (in SPC format) and saving them in global data pool. -The data will be then exploited by the termal controller. \ No newline at end of file +The data will be then exploited by the termal controller. + +# RUN + +In order to run the code it is necessary to connect the computer to the Arduino through USB interface. +Before building and running the code, the serial port should be open through the terminal. + +In my case the name of my port is: /dev/ttyACM0 + +The command to open the serial port in the terminal is: sudo chmod a+rw /dev/ttyACM0 + +In conclusion it is firstly necessary to know the name of the computer serial port. +This name should be substituted in line 52 of mission/DeviceHandler/ArduinoComIF.cpp as: +int serial_port = open("WRITE_SERIAL_PORT_NAME", O_RDWR); +Finally the command described here above must be inserted in the terminal. diff --git a/_bin/linux/debug/fsfw-example-linux.elf b/_bin/linux/debug/fsfw-example-linux.elf index 3de02bd..89a7454 100755 Binary files a/_bin/linux/debug/fsfw-example-linux.elf and b/_bin/linux/debug/fsfw-example-linux.elf differ diff --git a/_obj/linux/debug/bsp_linux/core/InitMission.o b/_obj/linux/debug/bsp_linux/core/InitMission.o index bd8fa4d..2d21bce 100644 Binary files a/_obj/linux/debug/bsp_linux/core/InitMission.o and b/_obj/linux/debug/bsp_linux/core/InitMission.o differ diff --git a/_obj/linux/debug/bsp_linux/fsfwconfig/datapool/dataPoolInit.o b/_obj/linux/debug/bsp_linux/fsfwconfig/datapool/dataPoolInit.o index 085c086..77492d4 100644 Binary files a/_obj/linux/debug/bsp_linux/fsfwconfig/datapool/dataPoolInit.o and b/_obj/linux/debug/bsp_linux/fsfwconfig/datapool/dataPoolInit.o differ diff --git a/_obj/linux/debug/bsp_linux/fsfwconfig/pollingsequence/PollingSequenceArduinoFunction.o b/_obj/linux/debug/bsp_linux/fsfwconfig/pollingsequence/PollingSequenceArduinoFunction.o index 83eb15b..09035b6 100644 Binary files a/_obj/linux/debug/bsp_linux/fsfwconfig/pollingsequence/PollingSequenceArduinoFunction.o and b/_obj/linux/debug/bsp_linux/fsfwconfig/pollingsequence/PollingSequenceArduinoFunction.o differ diff --git a/_obj/linux/debug/bsp_linux/main.o b/_obj/linux/debug/bsp_linux/main.o index 6749b2c..379cf1b 100644 Binary files a/_obj/linux/debug/bsp_linux/main.o and b/_obj/linux/debug/bsp_linux/main.o differ diff --git a/_obj/linux/debug/mission/Controller/TCS_ThermalComponent.o b/_obj/linux/debug/mission/Controller/TCS_ThermalComponent.o index 542bab4..b77e7e3 100644 Binary files a/_obj/linux/debug/mission/Controller/TCS_ThermalComponent.o and b/_obj/linux/debug/mission/Controller/TCS_ThermalComponent.o differ diff --git a/_obj/linux/debug/mission/Controller/ThermalController.o b/_obj/linux/debug/mission/Controller/ThermalController.o index de134f8..ead32d3 100644 Binary files a/_obj/linux/debug/mission/Controller/ThermalController.o and b/_obj/linux/debug/mission/Controller/ThermalController.o differ diff --git a/_obj/linux/debug/mission/DeviceHandler/ArduinoComIF.o b/_obj/linux/debug/mission/DeviceHandler/ArduinoComIF.o index 749bd59..ba52c52 100644 Binary files a/_obj/linux/debug/mission/DeviceHandler/ArduinoComIF.o and b/_obj/linux/debug/mission/DeviceHandler/ArduinoComIF.o differ diff --git a/_obj/linux/debug/mission/DeviceHandler/ArduinoCookie.o b/_obj/linux/debug/mission/DeviceHandler/ArduinoCookie.o index fcdae6b..ae4abf2 100644 Binary files a/_obj/linux/debug/mission/DeviceHandler/ArduinoCookie.o and b/_obj/linux/debug/mission/DeviceHandler/ArduinoCookie.o differ diff --git a/_obj/linux/debug/mission/DeviceHandler/ArduinoDeviceHandler.o b/_obj/linux/debug/mission/DeviceHandler/ArduinoDeviceHandler.o index 4687ff9..174de5e 100644 Binary files a/_obj/linux/debug/mission/DeviceHandler/ArduinoDeviceHandler.o and b/_obj/linux/debug/mission/DeviceHandler/ArduinoDeviceHandler.o differ diff --git a/_obj/linux/debug/mission/core/GenericFactory.o b/_obj/linux/debug/mission/core/GenericFactory.o index 5b0134c..6f74ba1 100644 Binary files a/_obj/linux/debug/mission/core/GenericFactory.o and b/_obj/linux/debug/mission/core/GenericFactory.o differ diff --git a/bsp_linux/core/InitMission.cpp b/bsp_linux/core/InitMission.cpp index 8a84b86..12c30f7 100644 --- a/bsp_linux/core/InitMission.cpp +++ b/bsp_linux/core/InitMission.cpp @@ -111,7 +111,7 @@ void InitMission::createTasks(){ FixedTimeslotTaskIF* arduinoTask = TaskFactory::instance()-> createFixedTimeslotTask("ARDUINO_TASK",40, - PeriodicTaskIF::MINIMUM_STACK_SIZE, 2, nullptr); + PeriodicTaskIF::MINIMUM_STACK_SIZE, 3.2, nullptr); result = pollingSequenceArduinoFunction(arduinoTask); if(result != HasReturnvaluesIF::RETURN_OK) { sif::error << "InitMission::createTasks:ArduinoPST initialization failed!" @@ -120,7 +120,7 @@ void InitMission::createTasks(){ PeriodicTaskIF* controllerTask = TaskFactory::instance()-> createPeriodicTask("CONTROLLER_TASK",40, - PeriodicTaskIF::MINIMUM_STACK_SIZE, 2, nullptr); + PeriodicTaskIF::MINIMUM_STACK_SIZE, 3, nullptr); //result = pollingSequenceControllerFunction(controllerTask); result = controllerTask->addComponent(objects::THERMAL_CONTROLLER); if(result != HasReturnvaluesIF::RETURN_OK) { diff --git a/bsp_linux/fsfwconfig/datapool/dataPoolInit.h b/bsp_linux/fsfwconfig/datapool/dataPoolInit.h index 8c08d37..c8018b0 100644 --- a/bsp_linux/fsfwconfig/datapool/dataPoolInit.h +++ b/bsp_linux/fsfwconfig/datapool/dataPoolInit.h @@ -58,15 +58,15 @@ namespace datapool { TEMP_SENSOR_CH1 = 0x100014, TEMP_SENSOR_CH2 = 0x100015, - + TargetState_COMPONENT_1 = 0x100016, + CurrentState_COMPONENT_1 = 0x100017, + HeaterRequest_COMPONENT_1 = 0x100018, + TargetState_COMPONENT_2 = 0x100019, + CurrentState_COMPONENT_2 = 0x100020, + HeaterRequest_COMPONENT_2 = 0x100021 //Temp_COMPONENT_1 = 0x100098, - TargetState_COMPONENT_1 = 0x100017, - CurrentState_COMPONENT_1 = 0x100018, - HeaterRequest_COMPONENT_1 = 0x100019, //Temp_COMPONENT_2 = 0x100099, - TargetState_COMPONENT_2 = 0x100021, - CurrentState_COMPONENT_2 = 0x100022, - HeaterRequest_COMPONENT_2 = 0x100023 + }; } diff --git a/bsp_linux/fsfwconfig/pollingsequence/PollingSequenceArduinoFunction.cpp b/bsp_linux/fsfwconfig/pollingsequence/PollingSequenceArduinoFunction.cpp index 624d04c..7368191 100644 --- a/bsp_linux/fsfwconfig/pollingsequence/PollingSequenceArduinoFunction.cpp +++ b/bsp_linux/fsfwconfig/pollingsequence/PollingSequenceArduinoFunction.cpp @@ -17,9 +17,9 @@ ReturnValue_t pollingSequenceArduinoFunction( uint32_t length = thisSequence->getPeriodMs(); thisSequence->addSlot(objects::ARDUINO_DEVICE_HANDLER, length * 0, 0); - thisSequence->addSlot(objects::ARDUINO_DEVICE_HANDLER, length * 0.8, 1); - thisSequence->addSlot(objects::ARDUINO_DEVICE_HANDLER, length * 0.8, 2); - thisSequence->addSlot(objects::ARDUINO_DEVICE_HANDLER, length * 0.8, 3); + thisSequence->addSlot(objects::ARDUINO_DEVICE_HANDLER, length * 0.3, 1); + thisSequence->addSlot(objects::ARDUINO_DEVICE_HANDLER, length * 0.3, 2); + thisSequence->addSlot(objects::ARDUINO_DEVICE_HANDLER, length * 0.4, 3); if (thisSequence->checkSequence() == HasReturnvaluesIF::RETURN_OK) { return HasReturnvaluesIF::RETURN_OK; diff --git a/mission/Controller/TCS_ThermalComponent.cpp b/mission/Controller/TCS_ThermalComponent.cpp index 8454b9c..1f170b5 100644 --- a/mission/Controller/TCS_ThermalComponent.cpp +++ b/mission/Controller/TCS_ThermalComponent.cpp @@ -23,18 +23,8 @@ TCS_ThermalComponent::TCS_ThermalComponent(object_id_t reportingObjectId, parameters.heaterSwitchoff }, priority, ThermalComponentIF::STATE_REQUEST_NON_OPERATIONAL), Heater(Heater), RedundantHeater(RedundantHeater), - nopParameters({ parameters.lowerNopLimit, parameters.upperNopLimit }) { - - //Set thermal state once, then leave to operator. - /*DataSet mySet; - PoolVariable writableTargetState(targetStatePoolId, &mySet, PoolVariableIF::VAR_WRITE); - writableTargetState = ThermalComponentIF::STATE_REQUEST_NON_OPERATIONAL; - mySet.commit(PoolVariableIF::VALID);*/ - -} - -TCS_ThermalComponent::~TCS_ThermalComponent() { -} + nopParameters({ parameters.lowerNopLimit, parameters.upperNopLimit }) {} +TCS_ThermalComponent::~TCS_ThermalComponent() {} ThermalComponentIF::HeaterRequest TCS_ThermalComponent::performOperation(uint8_t opCode, bool redundancy, bool dual) { diff --git a/mission/Controller/TCS_ThermalComponent.h b/mission/Controller/TCS_ThermalComponent.h index 324fc48..2f37990 100644 --- a/mission/Controller/TCS_ThermalComponent.h +++ b/mission/Controller/TCS_ThermalComponent.h @@ -5,7 +5,6 @@ #include #include #include -//#include class TCS_ThermalComponent: public CoreComponent { public: @@ -29,7 +28,7 @@ public: ArduinoTCSTemperatureSensor *secondRedundantSensor, TCS_Heater *Heater, TCS_Heater *RedundantHeater, ThermalModuleIF *thermalModule, Parameters parameters, - Priority priority); + Priority priority); virtual ~TCS_ThermalComponent(); diff --git a/mission/Controller/ThermalController.cpp b/mission/Controller/ThermalController.cpp index 5c92d90..0554bb6 100644 --- a/mission/Controller/ThermalController.cpp +++ b/mission/Controller/ThermalController.cpp @@ -122,11 +122,6 @@ ReturnValue_t ThermalController::performOperation(uint8_t opCode) { return HasReturnvaluesIF::RETURN_OK; } -/*MessageQueueId_t ThermalController::getCommandQueue() const { - return commandQueue.getId(); -}*/ - - void ThermalController::performControlOperation() { //Done by overwritten performOperation! } diff --git a/mission/Controller/ThermalController.h b/mission/Controller/ThermalController.h index 04c62cd..914e74f 100644 --- a/mission/Controller/ThermalController.h +++ b/mission/Controller/ThermalController.h @@ -15,7 +15,6 @@ #include #include #include -//#include #include #include @@ -23,24 +22,15 @@ class ThermalController: public ControllerBase { public: - //static const Mode_t MODE_ON = 1; - //static const Mode_t MODE_OFF = 2; static const Submode_t NO_REDUNDANCY = 1; static const Submode_t HEATER_REDUNDANCY = 2; - static const uint8_t COMPONENT_DOMAIN_ID = 1; //!< First number n of component domain IDs - - //static const Event TCS_CONTROL_STRATEGY = MAKE_EVENT(0, SEVERITY::INFO); //!< Announcement mode for the TCS controller strategy, strategy is in p1 - - //static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::ARDUINO_TCS; - //static const uint8_t INTERFACE_ID = CLASS_ID::THERMAL_CONTROLLER; ThermalController(object_id_t objectId, object_id_t powerSwitcher, size_t commandQueueDepth); virtual~ ThermalController(); ReturnValue_t initialize() override; ReturnValue_t performOperation(uint8_t opCode) override; - //virtual MessageQueueId_t getCommandQueue() const; private: @@ -71,31 +61,15 @@ private: TCS_Heater REDUNDANT_HEATER_2; std::list heaters; std::list redundant_heaters; - - /*--------------------------------------------------------------------------------*/ - - /*const float T_min = -50 + 273.15; // [K] - const float T_max = 50 + 273.15; // [K] - static const uint8_t margin = 5; // ESA qualification margin [K] - static const uint8_t DT_heater = 10; // margin of heater activation [K] - static const uint8_t DT_redundancy = 5; // margin of redundancy activation [K]*/ - // Start of the clock when heater is turned-on (one clock defined for each heater), reset when heater turned-off - // const float Dt[36] = {0.0}; // time interval for check of heater activation [s] - - //ThermalComponentIF* findComponentByObjectId(object_id_t id); protected: - //Mode_t mode; - //Submode_t submode; - /* Extended Controller Base overrides */ ReturnValue_t handleCommandMessage(CommandMessage *message) override; void performControlOperation() override; ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode, uint32_t *msToReachTheMode) override; void startTransition(Mode_t mode, Submode_t submode) override; //void calculateStrategy(bool announce, bool redundancy); - //void modeChanged(Mode_t mode, Submode_t submode) override; //void getMode(Mode_t *mode, Submode_t *submode) override; //void changeHK(Mode_t mode, Submode_t submode, bool enable) override; diff --git a/mission/DeviceHandler/ArduinoComIF.cpp b/mission/DeviceHandler/ArduinoComIF.cpp index 53b0e66..e6d446f 100644 --- a/mission/DeviceHandler/ArduinoComIF.cpp +++ b/mission/DeviceHandler/ArduinoComIF.cpp @@ -8,25 +8,20 @@ #include #include - #include #include #include - -// C library headers #include #include #include - +#include +#include // Linux headers #include // Contains file controls like O_RDWR #include // Error integer and strerror() function #include // Contains POSIX terminal control definitions #include // write(), read(), close() -#include -#include - ArduinoComIF::ArduinoComIF(object_id_t objectId) : SystemObject(objectId) { } @@ -50,7 +45,7 @@ ReturnValue_t ArduinoComIF::initializeInterface(CookieIF *cookie) { // Here the serial port parameters are defined exploiting a // special tty configuration struct. - // Open the serial port. Change device path as needed. + // Open the serial port. Change device path as needed (see README in InterfaceCode/testArduino/testArduino/ ). int serial_port = open("/dev/ttyACM0", O_RDWR); // Create new termios struc, we call it 'tty' for convention. @@ -122,14 +117,10 @@ ReturnValue_t ArduinoComIF::readReceivedMessage(CookieIF *cookie, ArduinoCookie *Cookie = dynamic_cast(cookie); // The buffer array to store the data read are initialized. - // The whole data packet to be read is 2034 bytes, but - // the limit for one reading (VMAX) is 255 bytes. - // Therefore the reading is divided in 8 separate stages - // which employ 8 different buffer array. - // At the end these 8 arrays are concatenated in - // the main buffer array read_buf. - - uint8_t read_buf[2034]; // 2034 bytes from SPC serial output + // The whole data packet to be read is 2580 bytes, but the limit for one reading (VMAX) is 255 bytes. + // Therefore the reading is divided in 11 separate stages which employ 11 different buffer array. + // At the end these 11 arrays are concatenated in the main buffer array read_buf. + uint8_t read_buf[2580]; // 2580 bytes from SPC serial output uint8_t read_buf1[255]; // 255 bytes uint8_t read_buf2[255]; // 255 bytes uint8_t read_buf3[255]; // 255 bytes @@ -137,42 +128,43 @@ ReturnValue_t ArduinoComIF::readReceivedMessage(CookieIF *cookie, uint8_t read_buf5[255]; // 255 bytes uint8_t read_buf6[255]; // 255 bytes uint8_t read_buf7[255]; // 255 bytes - uint8_t read_buf8[249]; // 249 bytes + uint8_t read_buf8[255]; // 255 bytes + uint8_t read_buf9[255]; // 255 bytes + uint8_t read_buf10[255]; // 255 bytes + uint8_t read_buf11[30]; // 30 bytes - // The buffer elements are initially set to 0 so we can call printf() easily. + // The buffer elements are initially set to 0. memset(&read_buf, '\0', sizeof(read_buf)); - memset(&read_buf1, '\0', sizeof(read_buf)); - memset(&read_buf2, '\0', sizeof(read_buf)); - memset(&read_buf3, '\0', sizeof(read_buf)); - memset(&read_buf4, '\0', sizeof(read_buf)); - memset(&read_buf5, '\0', sizeof(read_buf)); - memset(&read_buf6, '\0', sizeof(read_buf)); - memset(&read_buf7, '\0', sizeof(read_buf)); - memset(&read_buf8, '\0', sizeof(read_buf)); + memset(&read_buf1, '\0', sizeof(read_buf1)); + memset(&read_buf2, '\0', sizeof(read_buf2)); + memset(&read_buf3, '\0', sizeof(read_buf3)); + memset(&read_buf4, '\0', sizeof(read_buf4)); + memset(&read_buf5, '\0', sizeof(read_buf5)); + memset(&read_buf6, '\0', sizeof(read_buf6)); + memset(&read_buf7, '\0', sizeof(read_buf7)); + memset(&read_buf8, '\0', sizeof(read_buf8)); + memset(&read_buf9, '\0', sizeof(read_buf9)); + memset(&read_buf10, '\0', sizeof(read_buf10)); + memset(&read_buf11, '\0', sizeof(read_buf11)); // Read bytes. The behaviour of read() (e.g. does it block?, how long does it block for?) // depends on the configuration settings above, specifically VMIN and VTIME. - - int num_bytes1 = read(Cookie->Serial_port_number, &read_buf1, - sizeof(read_buf1)); - int num_bytes2 = read(Cookie->Serial_port_number, &read_buf2, - sizeof(read_buf2)); - int num_bytes3 = read(Cookie->Serial_port_number, &read_buf3, - sizeof(read_buf3)); - int num_bytes4 = read(Cookie->Serial_port_number, &read_buf4, - sizeof(read_buf4)); - int num_bytes5 = read(Cookie->Serial_port_number, &read_buf5, - sizeof(read_buf5)); - int num_bytes6 = read(Cookie->Serial_port_number, &read_buf6, - sizeof(read_buf6)); - int num_bytes7 = read(Cookie->Serial_port_number, &read_buf7, - sizeof(read_buf7)); - int num_bytes8 = read(Cookie->Serial_port_number, &read_buf8, - sizeof(read_buf8)); + int num_bytes1 = read(Cookie->Serial_port_number, &read_buf1, sizeof(read_buf1)); + int num_bytes2 = read(Cookie->Serial_port_number, &read_buf2, sizeof(read_buf2)); + int num_bytes3 = read(Cookie->Serial_port_number, &read_buf3, sizeof(read_buf3)); + int num_bytes4 = read(Cookie->Serial_port_number, &read_buf4, sizeof(read_buf4)); + int num_bytes5 = read(Cookie->Serial_port_number, &read_buf5, sizeof(read_buf5)); + int num_bytes6 = read(Cookie->Serial_port_number, &read_buf6, sizeof(read_buf6)); + int num_bytes7 = read(Cookie->Serial_port_number, &read_buf7, sizeof(read_buf7)); + int num_bytes8 = read(Cookie->Serial_port_number, &read_buf8, sizeof(read_buf8)); + int num_bytes9 = read(Cookie->Serial_port_number, &read_buf9, sizeof(read_buf9)); + int num_bytes10 = read(Cookie->Serial_port_number, &read_buf10, sizeof(read_buf10)); + int num_bytes11 = read(Cookie->Serial_port_number, &read_buf11, sizeof(read_buf11)); int num_bytes = num_bytes1 + num_bytes2 + num_bytes3 + num_bytes4 - + num_bytes5 + num_bytes6 + num_bytes7 + num_bytes8; + + num_bytes5 + num_bytes6 + num_bytes7 + num_bytes8 + + num_bytes9 + num_bytes10 + num_bytes11; - // The 8 buffer arrays are here concatenated in one single vector. + // The 11 buffer arrays are here concatenated in one single vector. std::copy(read_buf1, read_buf1 + 255, read_buf); std::copy(read_buf2, read_buf2 + 255, read_buf + 255); std::copy(read_buf3, read_buf3 + 255, read_buf + 2 * 255); @@ -180,7 +172,10 @@ ReturnValue_t ArduinoComIF::readReceivedMessage(CookieIF *cookie, std::copy(read_buf5, read_buf5 + 255, read_buf + 4 * 255); std::copy(read_buf6, read_buf6 + 255, read_buf + 5 * 255); std::copy(read_buf7, read_buf7 + 255, read_buf + 6 * 255); - std::copy(read_buf8, read_buf8 + 249, read_buf + 7 * 255); + std::copy(read_buf8, read_buf8 + 255, read_buf + 7 * 255); + std::copy(read_buf9, read_buf9 + 255, read_buf + 8 * 255); + std::copy(read_buf10, read_buf10 + 255, read_buf + 9 * 255); + std::copy(read_buf11, read_buf11 + 30, read_buf + 10 * 255); // num_bytes is the number of bytes read (n=0: no bytes received, n=-1: error). if (num_bytes < 0) { @@ -191,15 +186,9 @@ ReturnValue_t ArduinoComIF::readReceivedMessage(CookieIF *cookie, printf("Read %i bytes.\n", num_bytes); // Definition of buffer array and buffer size to return after reading. - - *size = 2034; - - /*uint8_t *buf_ptr; - buf_ptr = read_buf; - buffer = &buf_ptr;*/ + *size = 2580; *buffer = read_buf; - //close(Cookie->Serial_port_number); return RETURN_OK; } diff --git a/mission/DeviceHandler/ArduinoComIF.h b/mission/DeviceHandler/ArduinoComIF.h index c9bf91a..913d2e9 100644 --- a/mission/DeviceHandler/ArduinoComIF.h +++ b/mission/DeviceHandler/ArduinoComIF.h @@ -43,24 +43,6 @@ public: ReturnValue_t readReceivedMessage(CookieIF *cookie, uint8_t **buffer, size_t *size) override; -private: - - // DELETE - /** - * Send TM packet which contains received data as TM[17,130]. - * Wiretapping will do the same. - * @param data - * @param len - */ - //void sendTmPacket(const uint8_t *data,uint32_t len); - - /*AcceptsTelemetryIF* funnel = nullptr; - MessageQueueIF* tmQueue = nullptr; - size_t replyMaxLen = 0; - using ReplyBuffer = std::vector; - std::map replyMap; - uint8_t dummyReplyCounter = 0; - uint16_t packetSubCounter = 0;*/ }; diff --git a/mission/DeviceHandler/ArduinoCookie.cpp b/mission/DeviceHandler/ArduinoCookie.cpp index 0d99a61..73ee303 100644 --- a/mission/DeviceHandler/ArduinoCookie.cpp +++ b/mission/DeviceHandler/ArduinoCookie.cpp @@ -1,5 +1,5 @@ /* - * Cookie.cpp + * ArduinoCookie.cpp * * Created on: 02/06/2021 * Author: Marco Modè @@ -14,17 +14,3 @@ ArduinoCookie::ArduinoCookie() {} ArduinoCookie::~ArduinoCookie() {} - -/* -address_t ArduinoCookie::getAddress() const { - return address; -} - -size_t ArduinoCookie::getReplyMaxLen() const { - return replyMaxLen; -} - -int ArduinoCookie::getSerialPort() const { - return Serial_port_number; -} -*/ diff --git a/mission/DeviceHandler/ArduinoCookie.h b/mission/DeviceHandler/ArduinoCookie.h index 5c8bb3c..fdbc64e 100644 --- a/mission/DeviceHandler/ArduinoCookie.h +++ b/mission/DeviceHandler/ArduinoCookie.h @@ -14,7 +14,7 @@ #include /** - * @brief Simple cookie which initialie the variables + * @brief Simple cookie which initialize the variables * for the Linux serial port. */ class ArduinoCookie: public CookieIF { @@ -22,14 +22,7 @@ public: ArduinoCookie(); virtual ~ArduinoCookie(); - address_t getAddress() const; - size_t getReplyMaxLen() const; - int getSerialPort() const; int Serial_port_number; - -private: - address_t address = 0; - size_t replyMaxLen = 0; }; diff --git a/mission/DeviceHandler/ArduinoDeviceHandler.cpp b/mission/DeviceHandler/ArduinoDeviceHandler.cpp index 3583f18..24cbfb3 100644 --- a/mission/DeviceHandler/ArduinoDeviceHandler.cpp +++ b/mission/DeviceHandler/ArduinoDeviceHandler.cpp @@ -11,23 +11,14 @@ #include #include #include - - -//#include - #include ArduinoDH::ArduinoDH(object_id_t objectId, object_id_t comIF, CookieIF *cookie) : - DeviceHandlerBase(objectId, comIF, cookie)/*, foundId(&bufferId), foundLen(&bufferLen)*/ { + DeviceHandlerBase(objectId, comIF, cookie) { mode = _MODE_START_UP; } - -ArduinoDH::~ArduinoDH() { -} - -/*void ArduinoDH::performOperationHook() { -}*/ +ArduinoDH::~ArduinoDH() {} void ArduinoDH::doStartUp() { std::cout<<"Arduino device -> Switching-ON"<fullInfoPrintout = enable; -}*/ - -/*ReturnValue_t ArduinoDH::initializeLocalDataPool( - localpool::DataPool &localDataPoolMap, - LocalDataPoolManager &poolManager) { - return RETURN_OK; -}*/ - -/*ReturnValue_t ArduinoDH::getParameter(uint8_t domainId, uint8_t uniqueId, - ParameterWrapper *parameterWrapper, const ParameterWrapper *newValues, - uint16_t startAtIndex) { - return RETURN_OK; -}*/ - -/*LocalPoolObjectBase* ArduinoDH::getPoolObjectHandle(lp_id_t localPoolId) { - return RETURN_OK; -}*/ - +void ArduinoDH::setNormalDatapoolEntriesInvalid() {} diff --git a/mission/DeviceHandler/ArduinoDeviceHandler.h b/mission/DeviceHandler/ArduinoDeviceHandler.h index b5dc76d..25b79df 100644 --- a/mission/DeviceHandler/ArduinoDeviceHandler.h +++ b/mission/DeviceHandler/ArduinoDeviceHandler.h @@ -42,27 +42,12 @@ public: * in development to reduce need of commanding while debugging. */ ArduinoDH(object_id_t objectId, object_id_t comIF, CookieIF *cookie); - - /** - * This can be used to enable and disable a lot of demo print output. - * @param enable - */ - void enableFullDebugOutput(bool enable); - virtual ~ ArduinoDH(); - //! Size of internal buffer used for communication. - static constexpr uint8_t MAX_BUFFER_SIZE = 255; - - //! Unique index if the device handler is created multiple times. - /*testdevice::DeviceIndex deviceIdx = testdevice::DeviceIndex::DEVICE_0;*/ - - // Definiton of data structure for SPC communication. Three different structures are defined for measurements of: // - Temperature, // - Environmental data, // - Accelerometer data. - struct Temperature { char start_string[8]; uint8_t Typ; @@ -121,7 +106,6 @@ public: // Three vectors are defined to store the three type of classes sequentially // during the phase of reading copying data from the buffers - std::vector vecTemp; std::vector vecEnv; std::vector vecAcc; @@ -132,7 +116,6 @@ public: // Then, they are overwritten by the data of next iteration and the process is // repeated ,until all the data from the buffer are copied to the three vectors // using the three different structures. - Temperature Temp_ch; Environmental Env_ch; Accelerometer Acc_ch; @@ -140,30 +123,13 @@ public: protected: - /*DeviceCommandId_t bufferId = 0x01; - size_t bufferLen = 2034; - DeviceCommandId_t *foundId; - size_t *foundLen;*/ - - //testdevice::TestDataSet dataset; - //! This is used to reset the dataset after a commanded change has been made. - bool resetAfterChange = false; - bool commandSent = false; - - /** DeviceHandlerBase overrides (see DHB documentation) */ - - /** - * Hook into the DHB #performOperation call which is executed - * periodically. - */ - /*void buildNormalModeCommands() override;*/ - virtual void doStartUp() override; virtual void doShutDown() override; virtual ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t *id) override; virtual ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t *id) override; + virtual void doTransition(Mode_t modeFrom, Submode_t subModeFrom) override; virtual ReturnValue_t buildCommandFromCommand( DeviceCommandId_t deviceCommand, const uint8_t *commandData, size_t commandDataLen) override; @@ -172,63 +138,8 @@ protected: DeviceCommandId_t *foundId, size_t *foundLen) override; virtual ReturnValue_t interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) override; - virtual uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) - override; - virtual void doTransition(Mode_t modeFrom, Submode_t subModeFrom) override; virtual void setNormalDatapoolEntriesInvalid() override; - /*virtual ReturnValue_t initializeLocalDataPool( - localpool::DataPool &localDataPoolMap, - LocalDataPoolManager &poolManager) override;*/ - /*virtual LocalPoolObjectBase* getPoolObjectHandle(lp_id_t localPoolId) - override;*/ - - /* HasParametersIF overrides */ - /*virtual ReturnValue_t getParameter(uint8_t domainId, uint8_t uniqueId, - ParameterWrapper *parameterWrapper, - const ParameterWrapper *newValues, uint16_t startAtIndex) override;*/ - - uint8_t commandBuffer[MAX_BUFFER_SIZE]; - - // ****************************************************************** - // delete this stuff - - bool oneShot = true; - - /* Variables for parameter service */ - uint32_t testParameter0 = 0; - int32_t testParameter1 = -2; - float vectorFloatParams2[3] = { }; - - /* Change device handler functionality, changeable via parameter service */ - uint8_t periodicPrintout = false; - - /*ReturnValue_t buildNormalModeCommand(DeviceCommandId_t deviceCommand, - const uint8_t *commandData, size_t commandDataLen);*/ - /*ReturnValue_t buildTestCommand0(DeviceCommandId_t deviceCommand, - const uint8_t *commandData, size_t commandDataLen);*/ - /*ReturnValue_t buildTestCommand1(DeviceCommandId_t deviceCommand, - const uint8_t *commandData, size_t commandDataLen);*/ - void passOnCommand(DeviceCommandId_t command, const uint8_t *commandData, - size_t commandDataLen); - - ReturnValue_t interpretingNormalModeReply(); - /*ReturnValue_t interpretingTestReply0(DeviceCommandId_t id, - const uint8_t *packet);*/ - /*ReturnValue_t interpretingTestReply1(DeviceCommandId_t id, - const uint8_t *packet);*/ - /*ReturnValue_t interpretingTestReply2(DeviceCommandId_t id, - const uint8_t *packet);*/ - - /* Some timer utilities */ - static constexpr uint8_t divider1 = 2; - PeriodicOperationDivider opDivider1 = PeriodicOperationDivider(divider1); - static constexpr uint8_t divider2 = 10; - PeriodicOperationDivider opDivider2 = PeriodicOperationDivider(divider2); - static constexpr uint32_t initTimeout = 2000; - Countdown countdown1 = Countdown(initTimeout); - - // ******************************************************************************* }; #endif /* MISSION_DEVICEHANDLER_ARDUINODEVICEHANDLER_H_ */