Testing UART output

Signed-off-by: Bernardo Carvalho <bernardo.carvalho@tecnico.ulisboa.pt>
This commit is contained in:
2025-10-18 00:35:57 +01:00
parent ba6c07987e
commit 39176574a5
2 changed files with 497 additions and 483 deletions

View File

@@ -30,8 +30,8 @@
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
#include <fcntl.h> #include <fcntl.h>
#include <unistd.h> // for close()
#include <math.h> #include <math.h>
#include <unistd.h> // for close()
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/* Project header includes */ /* Project header includes */
@@ -49,10 +49,8 @@
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
namespace MARTe { namespace MARTe {
const float32 DAC_RANGE = 20.0; const float32 DAC_RANGE = 20.0;
const float32 ATCA_IOP_MAX_DAC_RANGE = 20.0; // const float32 ATCA_IOP_MAX_DAC_RANGE = 20.0;
UARTOutput::UARTOutput() : UARTOutput::UARTOutput() : DataSourceI(), MessageI() {
DataSourceI(),
MessageI() {
// boardFileDescriptor = -1; // boardFileDescriptor = -1;
// numberOfDACsEnabled = 0u; // numberOfDACsEnabled = 0u;
// isMaster = 0u; // isMaster = 0u;
@@ -62,28 +60,30 @@ namespace MARTe {
uint32 n; uint32 n;
// for (n = 0u; n < ATCA_IOP_MAX_DAC_CHANNELS; n++) { // for (n = 0u; n < ATCA_IOP_MAX_DAC_CHANNELS; n++) {
// dacEnabled[n] = false; // dacEnabled[n] = false;
outputRange = ATCA_IOP_MAX_DAC_RANGE; outputRange = DAC_RANGE;
//} //}
// channelsMemory = NULL_PTR(float32 *); // channelsMemory = NULL_PTR(float32 *);
channelMemory = 0.0;//NULL_PTR(float32 *); channelValue = 0.0; // NULL_PTR(float32 *);
filter = ReferenceT<RegisteredMethodsMessageFilter>(GlobalObjectsDatabase::Instance()->GetStandardHeap()); filter = ReferenceT<RegisteredMethodsMessageFilter>(
GlobalObjectsDatabase::Instance()->GetStandardHeap());
filter->SetDestination(this); filter->SetDestination(this);
ErrorManagement::ErrorType ret = MessageI::InstallMessageFilter(filter); ErrorManagement::ErrorType ret = MessageI::InstallMessageFilter(filter);
if (!ret.ErrorsCleared()) { if (!ret.ErrorsCleared()) {
REPORT_ERROR(ErrorManagement::FatalError, "Failed to install message filters"); REPORT_ERROR(ErrorManagement::FatalError,
"Failed to install message filters");
} }
} }
/*lint -e{1551} the destructor must guarantee that the Timer SingleThreadService is stopped.*/ /*lint -e{1551} the destructor must guarantee that the Timer SingleThreadService
* is stopped.*/
UARTOutput::~UARTOutput() { UARTOutput::~UARTOutput() {
if (boardFileDescriptor != -1) { // REPORT_ERROR(ErrorManagement::Information, " Close Device Status Reg %d,
uint32 statusReg = 0; // 0x%x", rc, statusReg); close(boardFileDescriptor);
//REPORT_ERROR(ErrorManagement::Information, " Close Device Status Reg %d, 0x%x", rc, statusReg); serial.Close();
close(boardFileDescriptor); REPORT_ERROR_PARAMETERS(ErrorManagement::Information, "Close %s OK.",
REPORT_ERROR(ErrorManagement::Information, "Close device %d OK. Status Reg 0x%x,", boardFileDescriptor, statusReg); portName);
}
/* /*
if (channelsMemory != NULL_PTR(float32 *)) { if (channelsMemory != NULL_PTR(float32 *)) {
delete[] channelsMemory; delete[] channelsMemory;
@@ -91,26 +91,26 @@ namespace MARTe {
*/ */
} }
bool UARTOutput::AllocateMemory() { bool UARTOutput::AllocateMemory() { return true; }
return true;
}
uint32 UARTOutput::GetNumberOfMemoryBuffers() { uint32 UARTOutput::GetNumberOfMemoryBuffers() { return 1u; }
return 1u;
}
/*lint -e{715} [MISRA C++ Rule 0-1-11], [MISRA C++ Rule 0-1-12]. Justification: The memory buffer is independent of the bufferIdx.*/ /*lint -e{715} [MISRA C++ Rule 0-1-11], [MISRA C++ Rule 0-1-12]. Justification:
bool UARTOutput::GetSignalMemoryBuffer(const uint32 signalIdx, const uint32 bufferIdx, void*& signalAddress) { * The memory buffer is independent of the bufferIdx.*/
bool UARTOutput::GetSignalMemoryBuffer(const uint32 signalIdx,
const uint32 bufferIdx,
void *&signalAddress) {
bool ok = (signalIdx < (UART_MAX_CHANNELS)); bool ok = (signalIdx < (UART_MAX_CHANNELS));
if (ok) { if (ok) {
// if (channelsMemory != NULL_PTR(float32 *)) { // if (channelsMemory != NULL_PTR(float32 *)) {
signalAddress = &channelMemory; signalAddress = &channelValue;
//} //}
} }
return ok; return ok;
} }
const char8* UARTOutput::GetBrokerName(StructuredDataI& data, const SignalDirection direction) { const char8 *UARTOutput::GetBrokerName(StructuredDataI &data,
const SignalDirection direction) {
const char8 *brokerName = NULL_PTR(const char8 *); const char8 *brokerName = NULL_PTR(const char8 *);
if (direction == OutputSignals) { if (direction == OutputSignals) {
uint32 trigger = 0u; uint32 trigger = 0u;
@@ -121,21 +121,24 @@ namespace MARTe {
if (trigger == 1u) { if (trigger == 1u) {
brokerName = "MemoryMapSynchronisedOutputBroker"; brokerName = "MemoryMapSynchronisedOutputBroker";
triggerSet = true; triggerSet = true;
} } else {
else {
brokerName = "MemoryMapOutputBroker"; brokerName = "MemoryMapOutputBroker";
} }
} } else {
else { REPORT_ERROR(ErrorManagement::ParametersError,
REPORT_ERROR(ErrorManagement::ParametersError, "DataSource not compatible with InputSignals"); "DataSource not compatible with InputSignals");
} }
return brokerName; return brokerName;
} }
bool UARTOutput::GetInputBrokers(ReferenceContainer& inputBrokers, const char8* const functionName, void* const gamMemPtr) { bool UARTOutput::GetInputBrokers(ReferenceContainer &inputBrokers,
const char8 *const functionName,
void *const gamMemPtr) {
return false; return false;
} }
bool UARTOutput::GetOutputBrokers(ReferenceContainer& outputBrokers, const char8* const functionName, void* const gamMemPtr) { bool UARTOutput::GetOutputBrokers(ReferenceContainer &outputBrokers,
const char8 *const functionName,
void *const gamMemPtr) {
// Check if there is a Trigger signal for this function. // Check if there is a Trigger signal for this function.
uint32 functionIdx = 0u; uint32 functionIdx = 0u;
uint32 nOfFunctionSignals = 0u; uint32 nOfFunctionSignals = 0u;
@@ -144,7 +147,8 @@ namespace MARTe {
bool ok = GetFunctionIndex(functionIdx, functionName); bool ok = GetFunctionIndex(functionIdx, functionName);
if (ok) { if (ok) {
ok = GetFunctionNumberOfSignals(OutputSignals, functionIdx, nOfFunctionSignals); ok = GetFunctionNumberOfSignals(OutputSignals, functionIdx,
nOfFunctionSignals);
} }
uint32 trigger = 0u; uint32 trigger = 0u;
for (i = 0u; (i < nOfFunctionSignals) && (ok) && (!triggerGAM); i++) { for (i = 0u; (i < nOfFunctionSignals) && (ok) && (!triggerGAM); i++) {
@@ -152,7 +156,8 @@ namespace MARTe {
triggerGAM = (trigger == 1u); triggerGAM = (trigger == 1u);
} }
if ((ok) && (triggerGAM)) { if ((ok) && (triggerGAM)) {
ReferenceT<MemoryMapSynchronisedOutputBroker> broker("MemoryMapSynchronisedOutputBroker"); ReferenceT<MemoryMapSynchronisedOutputBroker> broker(
"MemoryMapSynchronisedOutputBroker");
ok = broker.IsValid(); ok = broker.IsValid();
if (ok) { if (ok) {
@@ -161,21 +166,23 @@ namespace MARTe {
if (ok) { if (ok) {
ok = outputBrokers.Insert(broker); ok = outputBrokers.Insert(broker);
} }
//Must also add the signals which are not triggering but that belong to the same GAM... // Must also add the signals which are not triggering but that belong to the
// same GAM...
if (ok) { if (ok) {
if (nOfFunctionSignals > 1u) { if (nOfFunctionSignals > 1u) {
ReferenceT<MemoryMapOutputBroker> brokerNotSync("MemoryMapOutputBroker"); ReferenceT<MemoryMapOutputBroker> brokerNotSync(
"MemoryMapOutputBroker");
ok = brokerNotSync.IsValid(); ok = brokerNotSync.IsValid();
if (ok) { if (ok) {
ok = brokerNotSync->Init(OutputSignals, *this, functionName, gamMemPtr); ok = brokerNotSync->Init(OutputSignals, *this, functionName,
gamMemPtr);
} }
if (ok) { if (ok) {
ok = outputBrokers.Insert(brokerNotSync); ok = outputBrokers.Insert(brokerNotSync);
} }
} }
} }
} } else {
else {
ReferenceT<MemoryMapOutputBroker> brokerNotSync("MemoryMapOutputBroker"); ReferenceT<MemoryMapOutputBroker> brokerNotSync("MemoryMapOutputBroker");
ok = brokerNotSync.IsValid(); ok = brokerNotSync.IsValid();
if (ok) { if (ok) {
@@ -188,31 +195,36 @@ namespace MARTe {
return ok; return ok;
} }
/*lint -e{715} [MISRA C++ Rule 0-1-11], [MISRA C++ Rule 0-1-12]. Justification: the counter and the timer are always reset irrespectively of the states being changed.*/ /*lint -e{715} [MISRA C++ Rule 0-1-11], [MISRA C++ Rule 0-1-12]. Justification:
bool UARTOutput::PrepareNextState(const char8* const currentStateName, const char8* const nextStateName) { * the counter and the timer are always reset irrespectively of the states being
* changed.*/
bool UARTOutput::PrepareNextState(const char8 *const currentStateName,
const char8 *const nextStateName) {
return true; return true;
} }
bool UARTOutput::Initialise(StructuredDataI &data) { bool UARTOutput::Initialise(StructuredDataI &data) {
bool ok = DataSourceI::Initialise(data); bool ok = DataSourceI::Initialise(data);
StreamString portName; // StreamString portName;
if (ok) { if (ok) {
ok = data.Read("PortName", portName); ok = data.Read("PortName", portName);
if (ok) { if (ok) {
REPORT_ERROR(ErrorManagement::Information, "The port name is set to %s", portName.Buffer()); REPORT_ERROR_PARAMETERS(ErrorManagement::Information,
} "The port name is set to %s", portName.Buffer());
else { } else {
REPORT_ERROR(ErrorManagement::ParametersError, "The port name property shall be set"); REPORT_ERROR(ErrorManagement::ParametersError,
"The port name property shall be set");
} }
} }
uint32 baudRate = 0u; uint32 baudRate = 0u;
if (ok) { if (ok) {
ok = data.Read("BaudRate", baudRate); ok = data.Read("BaudRate", baudRate);
if (ok) { if (ok) {
REPORT_ERROR(ErrorManagement::Information, "The baud rate is set to %d", baudRate); REPORT_ERROR_PARAMETERS(ErrorManagement::Information,
} "The baud rate is set to %d", baudRate);
else { } else {
REPORT_ERROR(ErrorManagement::ParametersError, "The baud rate property shall be set"); REPORT_ERROR(ErrorManagement::ParametersError,
"The baud rate property shall be set");
} }
} }
if (ok) { if (ok) {
@@ -220,28 +232,37 @@ namespace MARTe {
timeout = 1000u; timeout = 1000u;
} }
} }
/*
if (ok) { if (ok) {
ok = data.Read("SerialTimeout", serialTimeout); ok = data.Read("SerialTimeout", serialTimeout);
if (ok) { if (ok) {
REPORT_ERROR(ErrorManagement::Information, "The serial timeout is set to %d", serialTimeout); REPORT_ERROR(ErrorManagement::Information, "The serial timeout is set to
%d", serialTimeout);
} }
else { else {
REPORT_ERROR(ErrorManagement::ParametersError, "The serial timeout property shall be set"); REPORT_ERROR(ErrorManagement::ParametersError, "The serial timeout
property shall be set");
} }
} }
*/
if (ok) { if (ok) {
ok = serial.SetSpeed(baudRate); ok = serial.SetSpeed(baudRate);
} }
if (ok) { if (ok) {
ok = serial.Open(portName.Buffer()); ok = serial.Open(portName.Buffer());
} }
if (!ok) {
REPORT_ERROR_PARAMETERS(ErrorManagement::ParametersError,
"The port %s Not opened.", portName);
}
// Get individual signal parameters // Get individual signal parameters
uint32 i = 0u; uint32 i = 0u;
if (ok) { if (ok) {
ok = data.MoveRelative("Signals"); ok = data.MoveRelative("Signals");
if (!ok) { if (!ok) {
REPORT_ERROR(ErrorManagement::ParametersError, "Could not move to the Signals section"); REPORT_ERROR(ErrorManagement::ParametersError,
"Could not move to the Signals section");
} }
// Do not allow to add signals in run-time // Do not allow to add signals in run-time
if (ok) { if (ok) {
@@ -256,23 +277,25 @@ namespace MARTe {
// while ((i < ATCA_IOP_MAX_DAC_CHANNELS) && (ok)) { // while ((i < ATCA_IOP_MAX_DAC_CHANNELS) && (ok)) {
if (data.MoveRelative(data.GetChildName(0))) { if (data.MoveRelative(data.GetChildName(0))) {
// uint32 channelId; // uint32 channelId;
float32 range; float64 range;
ok = data.Read("OutputRange", range); ok = data.Read("OutputRange", range);
if (ok) { if (ok) {
// if (data.Read("OutputRange", range)) { // if (data.Read("OutputRange", range)) {
ok = (range > 0.0) && (range <= ATCA_IOP_MAX_DAC_RANGE); ok = (range > 0.0) && (range <= DAC_RANGE);
if (!ok) { if (!ok) {
REPORT_ERROR(ErrorManagement::ParametersError, "Invalid OutputRange specified."); REPORT_ERROR(ErrorManagement::ParametersError,
"Invalid OutputRange specified.");
} }
if (ok) { if (ok) {
outputRange = range; outputRange = range;
REPORT_ERROR_PARAMETERS(ErrorManagement::Information, " Parameter DAC Output Range %f", range); REPORT_ERROR_PARAMETERS(ErrorManagement::Information,
" Parameter DAC Output Range %f", range);
// dacEnabled[i] = true; // dacEnabled[i] = true;
// numberOfDACsEnabled++; // numberOfDACsEnabled++;
} }
} } else {
else { REPORT_ERROR(ErrorManagement::ParametersError,
REPORT_ERROR(ErrorManagement::ParametersError, "The OutputRange shall be specified."); "The OutputRange shall be specified.");
} }
if (ok) { if (ok) {
ok = data.MoveToAncestor(1u); ok = data.MoveToAncestor(1u);
@@ -282,11 +305,13 @@ namespace MARTe {
if (ok) { if (ok) {
ok = data.MoveToAncestor(1u); ok = data.MoveToAncestor(1u);
if (!ok) { if (!ok) {
REPORT_ERROR(ErrorManagement::ParametersError, "Could not move to the parent section"); REPORT_ERROR(ErrorManagement::ParametersError,
"Could not move to the parent section");
} }
} }
//REPORT_ERROR_PARAMETERS(ErrorManagement::Information, "numberOfDACsEnabled %d", numberOfDACsEnabled); // REPORT_ERROR_PARAMETERS(ErrorManagement::Information, "numberOfDACsEnabled
// %d", numberOfDACsEnabled);
return ok; return ok;
} }
@@ -298,14 +323,16 @@ namespace MARTe {
ok = triggerSet; ok = triggerSet;
} }
if (!ok) { if (!ok) {
REPORT_ERROR(ErrorManagement::ParametersError, "At least one Trigger signal shall be set."); REPORT_ERROR(ErrorManagement::ParametersError,
"At least one Trigger signal shall be set.");
} }
if (ok) { if (ok) {
// for (i = 0u; (i < numberOfDACsEnabled) && (ok); i++) { // for (i = 0u; (i < numberOfDACsEnabled) && (ok); i++) {
ok = (GetSignalType(0u) == Float32Bit); ok = (GetSignalType(0u) == Float32Bit);
//} //}
if (!ok) { if (!ok) {
REPORT_ERROR(ErrorManagement::ParametersError, "All the DAC signals shall be of type Float32Bit"); REPORT_ERROR(ErrorManagement::ParametersError,
"All the DAC signals shall be of type Float32Bit");
} }
} }
@@ -323,50 +350,33 @@ namespace MARTe {
ok = (nSamples == 1u); ok = (nSamples == 1u);
} }
if (!ok) { if (!ok) {
REPORT_ERROR(ErrorManagement::ParametersError, "The number of samples shall be exactly one"); REPORT_ERROR(ErrorManagement::ParametersError,
"The number of samples shall be exactly one");
} }
} }
} }
StreamString fullDeviceName;
//Configure the board
if (ok) {
ok = fullDeviceName.Printf("%s_dac_%d", deviceName.Buffer(), boardId);
//ok = fullDeviceName.Printf("%s", deviceName.Buffer());
}
if (ok) {
ok = fullDeviceName.Seek(0LLU);
}
if (ok) {
boardFileDescriptor = open(fullDeviceName.Buffer(), O_RDWR);
ok = (boardFileDescriptor > -1);
if (!ok) {
REPORT_ERROR_PARAMETERS(ErrorManagement::ParametersError, "Could not open device %s", fullDeviceName);
}
else
REPORT_ERROR_PARAMETERS(ErrorManagement::Information, "Open device %s OK", fullDeviceName);
}
if (ok) {
//Allocate memory
//channelsMemory = new float32[ATCA_IOP_MAX_DAC_CHANNELS];
}
return ok; return ok;
} }
bool UARTOutput::Synchronise() { bool UARTOutput::Synchronise() {
uint32 i; uint32 i;
int32 w = 24; int32 w = 24;
bool ok = true; bool ok = true;
char8 text[] = "ola";
// if (channelsMemory != NULL_PTR(float32 *)) { // if (channelsMemory != NULL_PTR(float32 *)) {
// value = channelsMemory[0] / DAC_RANGE; // value = channelsMemory[0] / DAC_RANGE;
//for (i = 0u; (i < 2u) && (ok); i++) {
// for (i = 0u; (i < numberOfDACsEnabled ) && (ok); i++) { // for (i = 0u; (i < numberOfDACsEnabled ) && (ok); i++) {
float32 value = channelMemory / outputRange; int32 ser_value = channelValue / outputRange * 1000000.0;
REPORT_ERROR_PARAMETERS(ErrorManagement::Information,
"Synchronise called. value: %f, %d", channelValue,
ser_value);
// w = SetDacReg(i, value); // w = SetDacReg(i, value);
write(boardFileDescriptor, &w, 4); char8 *data = reinterpret_cast<char8 *>(&ser_value);
serial.Write(data, sizeof(int32));
// serial.Write(text, 4);
// write(boardFileDescriptor, &w, 4);
// value = channelsMemory[1] / DAC_RANGE; // value = channelsMemory[1] / DAC_RANGE;
// value = channelsMemory[1] / DAC_RANGE * pow(2,17); // value = channelsMemory[1] / DAC_RANGE * pow(2,17);
// w = SetDacReg(1, value); // w = SetDacReg(1, value);
@@ -398,5 +408,5 @@ namespace MARTe {
} }
*/ */
CLASS_REGISTER(UARTOutput, "1.0") CLASS_REGISTER(UARTOutput, "1.0")
} } // namespace MARTe
// vim: syntax=cpp ts=2 sw=2 sts=2 sr et // vim: syntax=cpp ts=2 sw=2 sts=2 sr et

View File

@@ -37,11 +37,11 @@
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
#include "BasicUART.h" #include "BasicUART.h"
#include "DataSourceI.h" #include "DataSourceI.h"
#include "EventSem.h"
#include "EmbeddedServiceMethodBinderI.h" #include "EmbeddedServiceMethodBinderI.h"
#include "SingleThreadService.h" #include "EventSem.h"
#include "MessageI.h" #include "MessageI.h"
#include "RegisteredMethodsMessageFilter.h" #include "RegisteredMethodsMessageFilter.h"
#include "SingleThreadService.h"
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/* Class declaration */ /* Class declaration */
@@ -52,27 +52,29 @@ namespace MARTe {
* The number of signals * The number of signals
*/ */
const uint32 ATCA_IOP_N_DACs = 2u; // const uint32 ATCA_IOP_N_DACs = 2u;
const uint32 UART_MAX_CHANNELS = 1u; const uint32 UART_MAX_CHANNELS = 1u;
/** /**
* @brief A DataSource which provides an analogue output interface to the ATCA IOP boards. * @brief A DataSource which provides an analogue output interface to the ATCA
IOP boards.
* @details The configuration syntax is (names are only given as an example): * @details The configuration syntax is (names are only given as an example):
* *
* <pre> * <pre>
* +AtcaIop_0_DAC = { * +AtcaIop_UartOut = {
* Class = AtcaIop::UARTOutput * Class = AtcaIop::UARTOutput
* DeviceName = "/dev/atca_v6_dac_2" //Mandatory * PortName = "/dev/ttyUSB0" //Name of the UART port, Mandatory
* PortName = "/dev/ttyUSB0" //Name of the UART port
* BaudRate = 115200 //BAUD UART rate * BaudRate = 115200 //BAUD UART rate
* Timeout = 200000 //Maximum time to wait for data * //Timeout = 200000 //Maximum time to wait for data
* CPUMask = 8 //Affinity of the CPU of where to read data from * CPUMask = 8 //Affinity of the CPU of where to read data from
* Signals = { * Signals = {
* DAC0_0 = { * SerialOut = {
* Type = float32//Mandatory. Only type that is supported. * Type = float32//Mandatory. Only type that is supported.
* OutputRange = 10.0 //Mandatory. The channel Module Output Range in volt. * OutputRange = 10.0 //Mandatory. The channel Module Output Range
* //OutputPolarity = Bipolar //Optional. Possible values: Bipolar, Unipolar. Default value Unipolar. in volt.
* //OutputPolarity = Bipolar //Optional. Possible values: Bipolar,
Unipolar. Default value Unipolar.
* } * }
* Packet = { //Actual data to write * Packet = { //Actual data to write
* Type = uint8 * Type = uint8
@@ -82,7 +84,9 @@ namespace MARTe {
* } * }
* } * }
* </pre> * </pre>
* Note that at least one of the GAMs writing to this DataSource must have set one of the signals with Trigger=1 (which forces the writing of all the signals to the DAC). * Note that at least one of the GAMs writing to this DataSource must have set
one of the signals with Trigger=1 (which forces the writing of all the signals
to the DAC).
*/ */
class UARTOutput : public DataSourceI, public MessageI { class UARTOutput : public DataSourceI, public MessageI {
public: public:
@@ -119,13 +123,14 @@ namespace MARTe {
const uint32 bufferIdx, const uint32 bufferIdx,
void *&signalAddress); void *&signalAddress);
/** /**
* @brief See DataSourceI::GetNumberOfMemoryBuffers. * @brief See DataSourceI::GetNumberOfMemoryBuffers.
* @details Only OutputSignals are supported. * @details Only OutputSignals are supported.
* @return MemoryMapSynchronisedOutputBroker if Trigger == 1 for any of the signals, MemoryMapOutputBroker otherwise. * @return MemoryMapSynchronisedOutputBroker if Trigger == 1 for any of the
* signals, MemoryMapOutputBroker otherwise.
*/ */
virtual const char8 *GetBrokerName(StructuredDataI &data, const SignalDirection direction); virtual const char8 *GetBrokerName(StructuredDataI &data,
const SignalDirection direction);
/** /**
* @brief See DataSourceI::GetInputBrokers. * @brief See DataSourceI::GetInputBrokers.
@@ -137,9 +142,10 @@ namespace MARTe {
/** /**
* @brief See DataSourceI::GetOutputBrokers. * @brief See DataSourceI::GetOutputBrokers.
* @details If the functionName is one of the functions which requested a Trigger, * @details If the functionName is one of the functions which requested a
* it adds a MemoryMapSynchronisedOutputBroker instance to the outputBrokers, * Trigger, it adds a MemoryMapSynchronisedOutputBroker instance to the
* otherwise it adds a MemoryMapOutputBroker instance to the outputBrokers. * outputBrokers, otherwise it adds a MemoryMapOutputBroker instance to the
* outputBrokers.
* @param[out] outputBrokers where the BrokerI instances have to be added to. * @param[out] outputBrokers where the BrokerI instances have to be added to.
* @param[in] functionName name of the function being queried. * @param[in] functionName name of the function being queried.
* @param[in] gamMemPtr the GAM memory where the signals will be read from. * @param[in] gamMemPtr the GAM memory where the signals will be read from.
@@ -149,7 +155,6 @@ namespace MARTe {
const char8 *const functionName, const char8 *const functionName,
void *const gamMemPtr); void *const gamMemPtr);
/** /**
* @brief See StatefulI::PrepareNextState. * @brief See StatefulI::PrepareNextState.
* @details NOOP. * @details NOOP.
@@ -158,41 +163,43 @@ namespace MARTe {
virtual bool PrepareNextState(const char8 *const currentStateName, virtual bool PrepareNextState(const char8 *const currentStateName,
const char8 *const nextStateName); const char8 *const nextStateName);
/** /**
* @brief Loads and verifies the configuration parameters detailed in the class description. * @brief Loads and verifies the configuration parameters detailed in the
* @return true if all the mandatory parameters are correctly specified and if the specified optional parameters have valid values. * class description.
* @return true if all the mandatory parameters are correctly specified and if
* the specified optional parameters have valid values.
*/ */
virtual bool Initialise(StructuredDataI &data); virtual bool Initialise(StructuredDataI &data);
/** /**
* @brief Final verification of all the parameters and setup of the board configuration. * @brief Final verification of all the parameters and setup of the board
* @details This method verifies that all the parameters (e.g. number of samples) requested by the GAMs interacting with this DataSource * configuration.
* are valid and consistent with the board parameters set during the initialisation phase. * @details This method verifies that all the parameters (e.g. number of
* In particular the following conditions shall be met: * samples) requested by the GAMs interacting with this DataSource are valid
* - At least one triggering signal was requested by a GAM (with the property Trigger = 1) * and consistent with the board parameters set during the initialisation
* phase. In particular the following conditions shall be met:
* - At least one triggering signal was requested by a GAM (with the property
* Trigger = 1)
* - All the DAC channels have type float32. * - All the DAC channels have type float32.
* - The number of samples of all the DAC channels is exactly one. * - The number of samples of all the DAC channels is exactly one.
* @return true if all the parameters are valid and consistent with the board parameters and if the board can be successfully configured with * @return true if all the parameters are valid and consistent with the board
* these parameters. * parameters and if the board can be successfully configured with these
* parameters.
*/ */
virtual bool SetConfiguredDatabase(StructuredDataI &data); virtual bool SetConfiguredDatabase(StructuredDataI &data);
/** /**
* @details Writes the value of all the DAC channels to the board. * @details Writes the value of all the DAC channels to the board.
* @return true if the writing of all the channels is successful. * @return true if the writing of all the channels is successful.
*/ */
virtual bool Synchronise(); virtual bool Synchronise();
private: private:
/** /**
* The board device name * The board device name
*/ */
StreamString deviceName; StreamString portName;
/** /**
* The board identifier * The board identifier
*/ */
@@ -200,7 +207,7 @@ namespace MARTe {
/** /**
* The board file descriptor * The board file descriptor
*/ */
int32 boardFileDescriptor; // int32 boardFileDescriptor;
/** /**
* The UART interface. * The UART interface.
*/ */
@@ -209,23 +216,21 @@ namespace MARTe {
/** /**
* Timeout to wait for data to be available. * Timeout to wait for data to be available.
*/ */
uint32 serialTimeout; // uint32 serialTimeout;
/** /**
*/ */
uint32 timeout; uint32 timeout;
/** /**
* DAC values * DAC values
*/ */
int32 dacValues[ATCA_IOP_N_DACs]; // int32 dacValues[ATCA_IOP_N_DACs];
/** /**
* The signal memory * The signal memory
*/ */
float32 channelMemory; float32 channelValue;
/** /**
* The DACs that are enabled * The DACs that are enabled
@@ -253,9 +258,8 @@ namespace MARTe {
bool triggerSet; bool triggerSet;
// int32 SetDacReg(uint32 channel, float32 val) const; // int32 SetDacReg(uint32 channel, float32 val) const;
}; };
} } // namespace MARTe
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/* Inline method definitions */ /* Inline method definitions */