Skip to content

Conversation

SeppoTakalo
Copy link
Contributor

Implement Modem Status Command(MSC) and a per DLC flow control by using it.

Send flow control signals when our input buffer don't fit full frame anymore.
Stop TX if we have received from controls on MSC.

Implement Modem Status Command(MSC) and a per DLC flow
control by using it.

Send flow control signals when our input buffer don't fit
full frame anymore.
Stop TX if we have received from controls on MSC.

Signed-off-by: Seppo Takalo <[email protected]>
Copy link

Comment on lines +86 to +94
struct modem_cmux_msc_signals {
uint8_t ea: 1; /**< Last octet, always 1 */
uint8_t fc: 1; /**< Flow Control */
uint8_t rtc: 1; /**< Ready to Communicate */
uint8_t rtr: 1; /**< Ready to Transmit */
uint8_t res_0: 2; /**< Reserved, set to zero */
uint8_t ic: 1; /**< Incoming call indicator */
uint8_t dv: 1; /**< Data Valid */
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can not serialize data using bitfields, the order of bitfields is compiler specific, so one compiler may put ea at bit 0, another at bit 7. We can store the bits in a struct like this, but when serializing them, we need explicit bitshifting

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see.
I had to check from C11 standard section 6.7.2.1

11 An implementation may allocate any addressable storage unit large enough to hold a bitfield.
If enough space remains, a bit-field that immediately follows another bit-field in a
structure shall be packed into adjacent bits of the same unit. If insufficient space remains,
whether a bit-field that does not fit is put into the next unit or overlaps adjacent units is
implementation-defined. The order of allocation of bit-fields within a unit (high-order to
low-order or low-order to high-order) is implementation-defined. The alignment of the
addressable storage unit is unspecified.

So you are right, this "implementation defined" might change between CPU targets even within the same compiler, so I'll rework this PR.

@tomi-font tomi-font removed their request for review October 16, 2025 08:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: Modem area: Tests Issues related to a particular existing or missing test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants