You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
However there is no (it seems) way to define a constant value for reserved bits.
I found two approaches to define it.
use constructor
#[derive(PackedStruct, Debug, Clone, PartialEq)]
#[packed_struct(bit_numbering = "msb0", endian = "msb")]
pub struct Status {
#[packed_field(bits = "0..=3")] // bit numbering is MSB
_start_flag: Integer<u8, packed_bits::Bits<4>>, // MUST be 0b1100
....
pub const STATUS_FLAG: u8 = 0xA0;
impl Status {
pub fn new() -> Status {
Status {
_start_flag: STATUS_FLAG.into(),
}
}
}
define dummy fields for each bit (which makes constructor bigger)
pub struct Status {
// next four bits represent a constant 0b1100
_start_flag3: ReservedOne<packed_bits::Bits::<1>>,
_start_flag2: ReservedOne<packed_bits::Bits::<1>>,
_start_flag1: ReservedZero<packed_bits::Bits::<1>>,
_start_flag0: ReservedZero<packed_bits::Bits::<1>>,
It would be amazing if I could pass a constant somehow (ReservedBits<0b1100, packet_bits::Bits<4>>?)
The text was updated successfully, but these errors were encountered:
Currently there is support for reserved bits sets to zero or one.
However there is no (it seems) way to define a constant value for reserved bits.
I found two approaches to define it.
It would be amazing if I could pass a constant somehow (
ReservedBits<0b1100, packet_bits::Bits<4>>
?)The text was updated successfully, but these errors were encountered: