google / pdl

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add support for variant constraint values to PDL packet declarations

hchataing opened this issue · comments

Example use case taken from the UWB's UCI specification:

enum MessageType: 3 {
    DATA = 0x00,
    COMMAND = 0x01,
    RESPONSE = 0x02,
    NOTIFICATION = 0x03,
}

packet UciPacket {
    message_type: MessageType,
    _body_
}

packet UciControlPacket: UciPacket (message_type = COMMAND | RESPONSE | NOTIFICATION) {
    opcode: 8,
    _size_(_payload_): 8,
    _payload_,
}

packet UciDataPacket: UciPacket (message_type = DATA) {
    _size_(_payload_): 16,
    _payload_,
}

In this example UciControlPacket covers multiple message types. It is not possible to describe this constraint using the exisiting syntax.