Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Fw::ObjectName #385

Merged
merged 3 commits into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -967,21 +967,13 @@ object ComponentCppWriter extends CppWriterUtils {
},
Line.blank :: lines(
s"""|#if FW_OBJECT_NAMES == 1
|// The port name consists of this->m_objName and some extra info.
|// We expect all of this to fit in FW_OBJ_NAME_MAX_SIZE bytes.
|// However, the compiler may assume that this->m_objName fills
|// the entire array, whose size is FW_OBJ_NAME_MAX_SIZE. So to
|// avoid a compiler warning, we provide an extra FW_OBJ_NAME_MAX_SIZE
|// bytes to cover the extra info.
|char portName[2*FW_OBJ_NAME_MAX_SIZE];
|(void) snprintf(
| portName,
| sizeof(portName),
|Fw::ObjectName portName;
|portName.format(
| "%s_${printName(port)}[%" PRI_PlatformIntType "]",
| this->m_objName,
| this->m_objName.toChar(),
| port
|);
|this->${variableName(port)}[port].setObjName(portName);
|this->${variableName(port)}[port].setObjName(portName.toChar());
|#endif
|"""
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ case class ComponentEvents (
| FW_LOG_TEXT_BUFFER_SIZE,
| _formatString,
|#if FW_OBJECT_NAMES == 1
| this->m_objName,
| this->m_objName.toChar(),
|#endif
|"""
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,21 +86,13 @@ void ActiveAsyncProductPortsOnlyComponentBase ::
this->m_productRecvIn_InputPort[port].setPortNum(port);

#if FW_OBJECT_NAMES == 1
// The port name consists of this->m_objName and some extra info.
// We expect all of this to fit in FW_OBJ_NAME_MAX_SIZE bytes.
// However, the compiler may assume that this->m_objName fills
// the entire array, whose size is FW_OBJ_NAME_MAX_SIZE. So to
// avoid a compiler warning, we provide an extra FW_OBJ_NAME_MAX_SIZE
// bytes to cover the extra info.
char portName[2*FW_OBJ_NAME_MAX_SIZE];
(void) snprintf(
portName,
sizeof(portName),
Fw::ObjectName portName;
portName.format(
"%s_productRecvIn_InputPort[%" PRI_PlatformIntType "]",
this->m_objName,
this->m_objName.toChar(),
port
);
this->m_productRecvIn_InputPort[port].setObjName(portName);
this->m_productRecvIn_InputPort[port].setObjName(portName.toChar());
#endif
}

Expand All @@ -113,21 +105,13 @@ void ActiveAsyncProductPortsOnlyComponentBase ::
this->m_productRequestOut_OutputPort[port].init();

#if FW_OBJECT_NAMES == 1
// The port name consists of this->m_objName and some extra info.
// We expect all of this to fit in FW_OBJ_NAME_MAX_SIZE bytes.
// However, the compiler may assume that this->m_objName fills
// the entire array, whose size is FW_OBJ_NAME_MAX_SIZE. So to
// avoid a compiler warning, we provide an extra FW_OBJ_NAME_MAX_SIZE
// bytes to cover the extra info.
char portName[2*FW_OBJ_NAME_MAX_SIZE];
(void) snprintf(
portName,
sizeof(portName),
Fw::ObjectName portName;
portName.format(
"%s_productRequestOut_OutputPort[%" PRI_PlatformIntType "]",
this->m_objName,
this->m_objName.toChar(),
port
);
this->m_productRequestOut_OutputPort[port].setObjName(portName);
this->m_productRequestOut_OutputPort[port].setObjName(portName.toChar());
#endif
}

Expand All @@ -140,21 +124,13 @@ void ActiveAsyncProductPortsOnlyComponentBase ::
this->m_productSendOut_OutputPort[port].init();

#if FW_OBJECT_NAMES == 1
// The port name consists of this->m_objName and some extra info.
// We expect all of this to fit in FW_OBJ_NAME_MAX_SIZE bytes.
// However, the compiler may assume that this->m_objName fills
// the entire array, whose size is FW_OBJ_NAME_MAX_SIZE. So to
// avoid a compiler warning, we provide an extra FW_OBJ_NAME_MAX_SIZE
// bytes to cover the extra info.
char portName[2*FW_OBJ_NAME_MAX_SIZE];
(void) snprintf(
portName,
sizeof(portName),
Fw::ObjectName portName;
portName.format(
"%s_productSendOut_OutputPort[%" PRI_PlatformIntType "]",
this->m_objName,
this->m_objName.toChar(),
port
);
this->m_productSendOut_OutputPort[port].setObjName(portName);
this->m_productSendOut_OutputPort[port].setObjName(portName.toChar());
#endif
}

Expand Down
Loading
Loading