Skip to content

Commit

Permalink
Fix boolean convenience setters for ACF-CAN
Browse files Browse the repository at this point in the history
Signed-off-by: Sebastian Schildt <[email protected]>
  • Loading branch information
SebastianSchildt committed Jan 2, 2025
1 parent 7fe06a3 commit 80a012d
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 12 deletions.
6 changes: 3 additions & 3 deletions include/avtp/acf/Can.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,9 @@ void Avtp_Can_SetField(Avtp_Can_t* can_pdu, Avtp_CanFields_t field, uint64_t val
void Avtp_Can_SetAcfMsgType(Avtp_Can_t* pdu, uint8_t value);
void Avtp_Can_SetAcfMsgLength(Avtp_Can_t* pdu, uint16_t value);
void Avtp_Can_SetPad(Avtp_Can_t* pdu, uint8_t value);
void Avtp_Can_SetMtv(Avtp_Can_t* pdu, uint8_t value);
void Avtp_Can_SetRtr(Avtp_Can_t* pdu, uint8_t value);
void Avtp_Can_SetEff(Avtp_Can_t* pdu, uint8_t value);
void Avtp_Can_SetMtv(Avtp_Can_t* pdu, uint64_t value);
void Avtp_Can_SetRtr(Avtp_Can_t* pdu, uint32_t value);
void Avtp_Can_SetEff(Avtp_Can_t* pdu, uint32_t value);
void Avtp_Can_SetBrs(Avtp_Can_t* pdu, uint8_t value);
void Avtp_Can_SetFdf(Avtp_Can_t* pdu, uint8_t value);
void Avtp_Can_SetEsi(Avtp_Can_t* pdu, uint8_t value);
Expand Down
42 changes: 33 additions & 9 deletions src/avtp/acf/Can.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,34 +153,58 @@ void Avtp_Can_SetPad(Avtp_Can_t* pdu, uint8_t value)
SET_FIELD(AVTP_CAN_FIELD_PAD, value);
}

void Avtp_Can_SetMtv(Avtp_Can_t* pdu, uint8_t value)
void Avtp_Can_SetMtv(Avtp_Can_t* pdu, uint64_t value)
{
SET_FIELD(AVTP_CAN_FIELD_MTV, value);
if (value) {
SET_FIELD(AVTP_CAN_FIELD_MTV, 1);
} else {
SET_FIELD(AVTP_CAN_FIELD_MTV, 0);
}
}

void Avtp_Can_SetRtr(Avtp_Can_t* pdu, uint8_t value)
void Avtp_Can_SetRtr(Avtp_Can_t* pdu, uint32_t value)
{
SET_FIELD(AVTP_CAN_FIELD_RTR, value);
if (value) {
SET_FIELD(AVTP_CAN_FIELD_RTR, 1);
} else {
SET_FIELD(AVTP_CAN_FIELD_RTR, 0);
}
}

void Avtp_Can_SetEff(Avtp_Can_t* pdu, uint8_t value)
void Avtp_Can_SetEff(Avtp_Can_t* pdu, uint32_t value)
{
SET_FIELD(AVTP_CAN_FIELD_EFF, value);
if (value) {
SET_FIELD(AVTP_CAN_FIELD_EFF, 1);
} else {
SET_FIELD(AVTP_CAN_FIELD_EFF, 0);
}
}

void Avtp_Can_SetBrs(Avtp_Can_t* pdu, uint8_t value)
{
SET_FIELD(AVTP_CAN_FIELD_BRS, value);
if (value) {
SET_FIELD(AVTP_CAN_FIELD_BRS, 1);
} else {
SET_FIELD(AVTP_CAN_FIELD_BRS, 0);
}
}

void Avtp_Can_SetFdf(Avtp_Can_t* pdu, uint8_t value)
{
SET_FIELD(AVTP_CAN_FIELD_FDF, value);
if (value) {
SET_FIELD(AVTP_CAN_FIELD_FDF, 1);
} else {
SET_FIELD(AVTP_CAN_FIELD_FDF, 0);
}
}

void Avtp_Can_SetEsi(Avtp_Can_t* pdu, uint8_t value)
{
SET_FIELD(AVTP_CAN_FIELD_ESI, value);
if (value) {
SET_FIELD(AVTP_CAN_FIELD_ESI, 1);
} else {
SET_FIELD(AVTP_CAN_FIELD_ESI, 0);
}
}

void Avtp_Can_SetCanBusId(Avtp_Can_t* pdu, uint8_t value)
Expand Down

0 comments on commit 80a012d

Please sign in to comment.