The printing of the sensor data has been commented out. Errors in the device handler and controller tasks.

This commit is contained in:
mmode 2021-09-13 17:43:07 +02:00
parent d857487d17
commit 2ce14d84f0
6 changed files with 33 additions and 40 deletions

View File

@ -103,13 +103,12 @@ void InitMission::createTasks(){
PeriodicTaskIF* pusLowPrio = TaskFactory::instance()->
createPeriodicTask("PUSB", 30, PeriodicTaskIF::MINIMUM_STACK_SIZE,
1.6, nullptr);
4, nullptr);
result = pusLowPrio->addComponent(objects::PUS_SERVICE_17_TEST);
if(result!=HasReturnvaluesIF::RETURN_OK){
sif::error << "Object add component failed" << std::endl;
}
sif::debug << "debug1: arduino tasks" << std::endl;
FixedTimeslotTaskIF* arduinoTask = TaskFactory::instance()->
createFixedTimeslotTask("ARDUINO_TASK",40,
PeriodicTaskIF::MINIMUM_STACK_SIZE, 2, nullptr);
@ -119,16 +118,15 @@ void InitMission::createTasks(){
<< std::endl;
}
sif::debug << "debug2: arduino tasks" << std::endl;
FixedTimeslotTaskIF* controllerTask = TaskFactory::instance()->
createFixedTimeslotTask("CONTROLLER_TASK",40,
PeriodicTaskIF::MINIMUM_STACK_SIZE, 3, nullptr);
result = pollingSequenceControllerFunction(controllerTask);
PeriodicTaskIF* controllerTask = TaskFactory::instance()->
createPeriodicTask("CONTROLLER_TASK",40,
PeriodicTaskIF::MINIMUM_STACK_SIZE, 1, nullptr);
//result = pollingSequenceControllerFunction(controllerTask);
result = controllerTask->addComponent(objects::THERMAL_CONTROLLER);
if(result != HasReturnvaluesIF::RETURN_OK) {
sif::error << "InitMission::createTasks:ArduinoController initialization failed!"
<< std::endl;
}
sif::debug << "debug3: arduino tasks" << std::endl;
#if OBSW_ADD_TEST_CODE == 1
FixedTimeslotTaskIF* testTimeslotTask = TaskFactory::instance()->
@ -158,10 +156,8 @@ void InitMission::createTasks(){
udpBridgeTask->startTask();
udpPollingTask->startTask();
//serializeTask->startTask();
arduinoTask->startTask();
sif::debug << "debug4: arduino tasks" << std::endl;
//arduinoTask->startTask();
controllerTask->startTask();
sif::debug << "debug5: arduino tasks" << std::endl;
//payloadTask->startTask();
eventTask->startTask();

View File

@ -39,11 +39,8 @@ int main() {
std::cout << "-- " << __DATE__ << " " << __TIME__ << " --" << std::endl;
objectManager = new ObjectManager(ObjectFactory::produce);
sif::debug << "debug_MAIN: object produced" << std::endl;
objectManager->initialize();
sif::debug << "debug_MAIN: object initialized" << std::endl;
InitMission::createTasks();
sif::debug << "debug_MAIN: tasks created" << std::endl;
//MutexExample::example();
PusPacketCreator::createPusPacketAndPrint();

View File

@ -32,7 +32,6 @@ void ArduinoTCSTemperatureSensor::doChildOperation() {
return;
}
outputTemperature = calculateOutputTemperature(*inputTemperature);
outputTemperature.setValid(PoolVariableIF::VALID);
if (outputTemperature<parameters.lowerLimit || outputTemperature>parameters.upperLimit){
outputTemperature.setValid(PoolVariableIF::INVALID);
outputTemperature = INVALID_TEMPERATURE;

View File

@ -40,8 +40,6 @@ ThermalController::~ThermalController() {
ReturnValue_t ThermalController::initialize() {
sif::debug<<"\nDEBUG_TCS: Controller starts initialization. "<<std::endl;
ReturnValue_t result = ControllerBase::initialize();
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
@ -65,7 +63,7 @@ ReturnValue_t ThermalController::initialize() {
}*/
/* ************************ */
sif::debug<<"\nDEBUG_TCS: Controller ends initialization. "<<std::endl;
sif::debug<<"\nDEBUG_TCS: Start initialization"<<std::endl;
return HasReturnvaluesIF::RETURN_OK;
}
@ -88,6 +86,7 @@ ReturnValue_t ThermalController::handleCommandMessage(CommandMessage *message) {
ReturnValue_t ThermalController::performOperation() {
sif::debug<<"\nDEBUG_TCS: Start of controller operations"<<std::endl;
std::cout << "\nDEBUG_TCS: Start of controller operations" << std::endl;
for (std::list<ArduinoTCSTemperatureSensor>::iterator iter = sensors.begin(); iter != sensors.end(); iter++) {
iter->performHealthOp();
@ -105,14 +104,15 @@ ReturnValue_t ThermalController::performOperation() {
}
TCSData.commit();
TCSData.read();
TCSData.read(); // ?check the read, separate dataset
//calculateStrategy(true, true);
ThermalComponentIF::HeaterRequest request;
for (std::list<TCS_ThermalComponent>::iterator iter = components.begin(); iter != components.end(); iter++) {
request = iter->performOperation(0, true, false);
request = iter->performOperation(0, true, false); // request returnvalue
//request = iter->performOperation(0, ThermalComponentIF::SAFE, true, false);
}
TCSData.commit();
std::cout << "\nDEBUG_TCS: End of controller operations" << std::endl;
return HasReturnvaluesIF::RETURN_OK;
}

View File

@ -101,25 +101,20 @@ ReturnValue_t ArduinoComIF::initializeInterface(CookieIF *cookie) {
Cookie->Serial_port_number = serial_port;
sif::debug<<"\nDEBUG_COMIF: debug0-IF"<<std::endl;
return RETURN_OK;
}
ReturnValue_t ArduinoComIF::sendMessage(CookieIF *cookie,
const uint8_t *sendData, size_t sendLen) {
sif::debug<<"\nDEBUG_COMIF: debug1-IF"<<std::endl;
return RETURN_OK;
}
ReturnValue_t ArduinoComIF::getSendSuccess(CookieIF *cookie) {
sif::debug<<"\nDEBUG_COMIF: debug2-IF"<<std::endl;
return RETURN_OK;
}
ReturnValue_t ArduinoComIF::requestReceiveMessage(CookieIF *cookie,
size_t requestLen) {
sif::debug<<"\nDEBUG_COMIF: debug3-IF"<<std::endl;
return RETURN_OK;
}
@ -135,8 +130,6 @@ ReturnValue_t ArduinoComIF::readReceivedMessage(CookieIF *cookie,
// At the end these 8 arrays are concatenated in
// the main buffer array read_buf.
sif::debug<<"\nDEBUG_COMIF: start of copy received data in the buffer"<<std::endl;
uint8_t read_buf[2034]; // 2034 bytes from SPC serial output
uint8_t read_buf1[255]; // 255 bytes
uint8_t read_buf2[255]; // 255 bytes

View File

@ -82,7 +82,7 @@ ReturnValue_t ArduinoDH::scanForReply(const uint8_t *start, size_t len,
/* Unless a command was sent explicitely, we don't expect any replies and ignore
the packet. On a real device, there might be replies which are sent without a previous
command. */
sif::debug<<"\nDEBUG_DH: scan for reply"<<std::endl;
//sif::debug<<"DEBUG_DH: scan for reply"<<std::endl;
/*if (not commandSent) {
sif::debug<<" DH: scan for reply2"<<std::endl;
return DeviceHandlerBase::IGNORE_FULL_PACKET;
@ -114,7 +114,7 @@ ReturnValue_t ArduinoDH::scanForReply(const uint8_t *start, size_t len,
ReturnValue_t ArduinoDH::interpretDeviceReply(DeviceCommandId_t id,
const uint8_t *packet) {
sif::debug<<"\nDEBUG_DH: interprete for reply"<<std::endl;
//sif::debug<<"DEBUG_DH: interprete for reply"<<std::endl;
// The data stored in the read buffer are here copied in the variables with the SPC format.
// After copying, the data of temperature, environment and accelerometer are stored in three separated vectors.
@ -157,7 +157,7 @@ ReturnValue_t ArduinoDH::interpretDeviceReply(DeviceCommandId_t id,
// All data are here printed to monitor from the three vectors of data measurements.
printf(
/*printf(
"\n***********************************************************************************************\n");
printf("TEMPERATURE parameters are: ");
@ -169,8 +169,8 @@ ReturnValue_t ArduinoDH::interpretDeviceReply(DeviceCommandId_t id,
printf("\nTemperature: %f", vecTemp[i].temperature);
printf("\nTimestamp: %u", vecTemp[i].Timestamp);
printf("\nEnd: %7s", vecTemp[i].end_string);
}
printf(
}*/
/*printf(
"\n\n***********************************************************************************************\n");
printf("ENVIRONMENTAL parameters are: ");
@ -262,7 +262,7 @@ ReturnValue_t ArduinoDH::interpretDeviceReply(DeviceCommandId_t id,
printf("\nEnd: %7s", vecAcc[3 * k + 2].end_string);
}
std::cout << "\n\nEnd reading data.\n" << std::endl;
std::cout << "\n\nEnd reading data.\n" << std::endl;*/
// The data are here written to the data pool where they would be available to be used for other objects
@ -270,41 +270,49 @@ ReturnValue_t ArduinoDH::interpretDeviceReply(DeviceCommandId_t id,
PoolVector <float, 36> TempValueVec(datapool::Temperature_value, &ArduinoDataSet, PoolVariableIF::VAR_WRITE);
for (int i = 0; i < 36; i++) {
memcpy(&TempValueVec, &vecTemp[27 * i + 11], 4);
memcpy(&TempValueVec[i], &vecTemp[27 * i + 11], 4);
}
ArduinoDataSet.commit(PoolVariableIF::VALID);
/*
PoolVector <unsigned int, 36> TempTimeVec(datapool::Temperature_Timestamp, &ArduinoDataSet, PoolVariableIF::VAR_WRITE);
for (int i = 0; i < 36; i++) {
memcpy(&TempTimeVec, &vecTemp[27 * i + 15], 4);
memcpy(&TempTimeVec[i], &vecTemp[27 * i + 15], 4);
}
ArduinoDataSet.commit(PoolVariableIF::VALID);
sif::debug<<"\nDEBUG_DHi: End of copy to datapool"<<std::endl;
PoolVector <float, 9> EnvValueVec(datapool::Environmental_value, &ArduinoDataSet, PoolVariableIF::VAR_WRITE);
for (int j = 0; j < 9; j++) {
memcpy(&EnvValueVec, &vecEnv[27 * (36 + j) + 11], 4);
memcpy(&EnvValueVec[j], &vecEnv[27 * (36 + j) + 11], 4);
}
ArduinoDataSet.commit(PoolVariableIF::VALID);
PoolVector <unsigned int, 9> EnvTimeVec(datapool::Environmental_Timestamp, &ArduinoDataSet, PoolVariableIF::VAR_WRITE);
for (int j = 0; j < 9; j++) {
memcpy(&EnvTimeVec, &vecEnv[27 * (36 + j) + 15], 4);
memcpy(&EnvTimeVec[j], &vecEnv[27 * (36 + j) + 15], 4);
}
ArduinoDataSet.commit(PoolVariableIF::VALID);
sif::debug<<"\nDEBUG_DHj: End of copy to datapool"<<std::endl;
PoolVector <float, 15> AccValueVec(datapool::Accelerometer_value, &ArduinoDataSet, PoolVariableIF::VAR_WRITE);
for (int k = 0; k < 15; k++) {
memcpy(&AccValueVec, &vecAcc[27 * (36 + 9) + 91 * k + 11], 36);
memcpy(&AccValueVec[k], &vecAcc[27 * (36 + 9) + 91 * k + 11], 36);
sif::debug<<"\nDEBUG_DHk1: End of copy to datapool"<<std::endl;
}
ArduinoDataSet.commit(PoolVariableIF::VALID);
PoolVector <unsigned int, 15> AccTimeVec(datapool::Accelerometer_Timestamp, &ArduinoDataSet, PoolVariableIF::VAR_WRITE);
for (int k = 0; k < 15; k++) {
memcpy(&AccTimeVec, &vecAcc[27 * (36 + 9) + 91 * k + 47], 36);
memcpy(&AccTimeVec[k], &vecAcc[27 * (36 + 9) + 91 * k + 47], 36);
sif::debug<<"\nDEBUG_DHk2: End of copy to datapool"<<std::endl;
}
ArduinoDataSet.commit(PoolVariableIF::VALID);
*/
sif::debug<<"\nDEBUG_DH: End of copy to datapool"<<std::endl;
//sif::debug<<"DEBUG_DH: End of copy to datapool"<<std::endl;
return RETURN_OK;
}