Skip to content

Commit

Permalink
refactor(pubsub): Use C-style comments in ua_pubsub_networkmessage_bi…
Browse files Browse the repository at this point in the history
…nary.c
  • Loading branch information
jpfr committed Nov 8, 2024
1 parent 90f3edb commit 360d38c
Showing 1 changed file with 22 additions and 20 deletions.
42 changes: 22 additions & 20 deletions src/pubsub/ua_pubsub_networkmessage_binary.c
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ UA_NetworkMessageHeader_encodeBinary(EncodeCtx *ctx,

UA_StatusCode rv = UA_Byte_encodeBinary(&v, &ctx->pos, ctx->end);
UA_CHECK_STATUS(rv, return rv);
// ExtendedFlags1
/* ExtendedFlags1 */
if(UA_NetworkMessage_ExtendedFlags1Enabled(src)) {
v = (UA_Byte)src->publisherId.idType;

Expand All @@ -231,10 +231,10 @@ UA_NetworkMessageHeader_encodeBinary(EncodeCtx *ctx,
rv = UA_Byte_encodeBinary(&v, &ctx->pos, ctx->end);
UA_CHECK_STATUS(rv, return rv);

// ExtendedFlags2
/* ExtendedFlags2 */
if(UA_NetworkMessage_ExtendedFlags2Enabled(src)) {
v = (UA_Byte)src->networkMessageType;
// shift left 2 bit
/* Shift left 2 bit */
v = (UA_Byte) (v << NM_SHIFT_LEN);

if(src->chunkMessage)
Expand All @@ -248,7 +248,7 @@ UA_NetworkMessageHeader_encodeBinary(EncodeCtx *ctx,
}
}

// PublisherId
/* PublisherId */
if(src->publisherIdEnabled) {
switch (src->publisherId.idType) {
case UA_PUBLISHERIDTYPE_BYTE:
Expand Down Expand Up @@ -278,7 +278,7 @@ UA_NetworkMessageHeader_encodeBinary(EncodeCtx *ctx,
UA_CHECK_STATUS(rv, return rv);
}

// DataSetClassId
/* DataSetClassId */
if(src->dataSetClassIdEnabled) {
rv = UA_Guid_encodeBinary(&src->dataSetClassId, &ctx->pos, ctx->end);
UA_CHECK_STATUS(rv, return rv);
Expand Down Expand Up @@ -437,7 +437,7 @@ UA_NetworkMessage_encodeHeaders(const UA_NetworkMessage* src, UA_Byte **bufPos,
UA_StatusCode
UA_NetworkMessage_encodePayload(const UA_NetworkMessage* src, UA_Byte **bufPos,
const UA_Byte *bufEnd) {
// Payload
/* Payload */
if(src->networkMessageType != UA_NETWORKMESSAGE_DATASET)
return UA_STATUSCODE_BADNOTIMPLEMENTED;

Expand Down Expand Up @@ -978,7 +978,7 @@ UA_NetworkMessage_calcSizeBinaryWithOffsetBuffer(
if(p->dataSetClassIdEnabled)
size += 16; /* guid */

// Group Header
/* Group Header */
if(p->groupHeaderEnabled) {
size += 1; /* byte */

Expand Down Expand Up @@ -1016,7 +1016,7 @@ UA_NetworkMessage_calcSizeBinaryWithOffsetBuffer(
}
}

// Payload Header
/* Payload Header */
if(p->payloadHeaderEnabled) {
if(p->networkMessageType != UA_NETWORKMESSAGE_DATASET)
return 0; /* not implemented */
Expand Down Expand Up @@ -1155,9 +1155,9 @@ UA_StatusCode
UA_DataSetMessageHeader_encodeBinary(const UA_DataSetMessageHeader* src, UA_Byte **bufPos,
const UA_Byte *bufEnd) {
UA_Byte v;
// DataSetFlags1
/* DataSetFlags1 */
v = (UA_Byte)src->fieldEncoding;
// shift left 1 bit
/* shift left 1 bit */
v = (UA_Byte)(v << DS_MH_SHIFT_LEN);

if(src->dataSetMessageValid)
Expand All @@ -1181,7 +1181,7 @@ UA_DataSetMessageHeader_encodeBinary(const UA_DataSetMessageHeader* src, UA_Byte
UA_StatusCode rv = UA_Byte_encodeBinary(&v, bufPos, bufEnd);
UA_CHECK_STATUS(rv, return rv);

// DataSetFlags2
/* DataSetFlags2 */
if(UA_DataSetMessageHeader_DataSetFlags2Enabled(src)) {
v = (UA_Byte)src->dataSetMessageType;

Expand All @@ -1195,37 +1195,37 @@ UA_DataSetMessageHeader_encodeBinary(const UA_DataSetMessageHeader* src, UA_Byte
UA_CHECK_STATUS(rv, return rv);
}

// DataSetMessageSequenceNr
/* DataSetMessageSequenceNr */
if(src->dataSetMessageSequenceNrEnabled) {
rv = UA_UInt16_encodeBinary(&src->dataSetMessageSequenceNr, bufPos, bufEnd);
UA_CHECK_STATUS(rv, return rv);
}

// Timestamp
/* Timestamp */
if(src->timestampEnabled) {
rv = UA_DateTime_encodeBinary(&src->timestamp, bufPos, bufEnd); /* UtcTime */
UA_CHECK_STATUS(rv, return rv);
}

// PicoSeconds
/* PicoSeconds */
if(src->picoSecondsIncluded) {
rv = UA_UInt16_encodeBinary(&src->picoSeconds, bufPos, bufEnd);
UA_CHECK_STATUS(rv, return rv);
}

// Status
/* Status */
if(src->statusEnabled) {
rv = UA_UInt16_encodeBinary(&src->status, bufPos, bufEnd);
UA_CHECK_STATUS(rv, return rv);
}

// ConfigVersionMajorVersion
/* ConfigVersionMajorVersion */
if(src->configVersionMajorVersionEnabled) {
rv = UA_UInt32_encodeBinary(&src->configVersionMajorVersion, bufPos, bufEnd);
UA_CHECK_STATUS(rv, return rv);
}

// ConfigVersionMinorVersion
/* ConfigVersionMinorVersion */
if(src->configVersionMinorVersionEnabled) {
rv = UA_UInt32_encodeBinary(&src->configVersionMinorVersion, bufPos, bufEnd);
UA_CHECK_STATUS(rv, return rv);
Expand Down Expand Up @@ -1429,7 +1429,7 @@ UA_DataSetMessage_deltaFrame_encodeBinary(const UA_DataSetMessage* src, UA_Byte
if(src->header.fieldEncoding == UA_FIELDENCODING_RAWDATA)
return UA_STATUSCODE_BADNOTIMPLEMENTED;

// Here the FieldCount is always present
/* Here the FieldCount is always present */
const UA_DataSetMessage_DataDeltaFrameData *dfd = &src->data.deltaFrameData;
UA_StatusCode rv = UA_UInt16_encodeBinary(&dfd->fieldCount, bufPos, bufEnd);
if(src->header.fieldEncoding == UA_FIELDENCODING_VARIANT) {
Expand Down Expand Up @@ -1696,9 +1696,11 @@ UA_DataSetMessage_calcSizeBinary(UA_DataSetMessage* p,
}
UA_FieldMetaData *fmd =
&p->data.keyFrameData.dataSetMetaDataType->fields[i];
// For arrays add encoded array length (4 bytes for each dimension)

/* For arrays add encoded array length (4 bytes for each dimension) */
size += fmd->arrayDimensionsSize * sizeof(UA_UInt32);
// We need to know how many elements there are

/* We need to know how many elements there are */
size_t elemCnt = 1;
for(size_t cnt = 0; cnt < fmd->arrayDimensionsSize; cnt++) {
elemCnt *= fmd->arrayDimensions[cnt];
Expand Down

0 comments on commit 360d38c

Please sign in to comment.