-
Notifications
You must be signed in to change notification settings - Fork 22
Description
Using APIs like Avtp_Can_SetAcfMsgLength(...) is error prone since the length is encoded in quadlets. @nayakned We discussed that quite a while ago.
I'd propose to keep only Avtp_AcfCommon_SetAcfMsgLength(...) and remove Avtp_<Type>_SetAcfMsgLength(...) for all ACF types and instead provide a function Avtp_<Type>_SetPayloadLen(...) which uses bytes instead of quadlets and also implicietly sets the correct padding. An implementation could look like this:
void Avtp_Gbb_SetPayloadLen(Avtp_Gbb_t* gbb, uint16_t bytes)
{
uint8_t pad = (4 - (bytes % 4)) % 4;
uint16_t quadlets = bytes / 4;
SET_FIELD(AVTP_GBB_FIELD_ACF_MSG_LENGTH, quadlets);
SET_FIELD(AVTP_GBB_FIELD_PAD, pad);
}
Analog to removing Avtp_<Type>_SetAcfMsgLength(...), it would then also possible to remove Avtp_<Type>_SetPad(...) because the padding would then implicitely be set by calling Avtp_<Type>_SetPayloadLen(...).
To summarize, I propose to:
- Remove
Avtp_<Type>_SetAcfMsgLength(...)for all ACF types (except AcfCommon) - Remove
Avtp_<Type>_GetAcfMsgLength(...)for all ACF types (except AcfCommon) - Remove
Avtp_<Type>_SetPad(...)for all ACF types (except AcfCommon) - Remove
Avtp_<Type>_GetPad(...)for all ACF types (except AcfCommon) - Add
Avtp_<Type>_SetPayloadLen(...)to all ACF types (except AcfCommon) - Add
Avtp_<Type>_GetPayloadLen(...)to all ACF types (except AcfCommon)
This might cause some breaking changes, so the earlier we follow through with this, the better. In case we want to follow through with this, I'd say we should also add a new version tag to the main branch.
@nayakned and @SebastianSchildt what are your thoughts?