1little_endian_packets 2 3custom_field Boolean: 8 "Boolean" 4enum Enum : 8 { 5 // Keep 0x0 as invalid value 6 ONE = 1, 7 TWO = 2, 8} 9 10struct Struct { 11 v: Enum, 12 u: 8, 13} 14 15packet TestEnum { 16 v: Enum, 17} 18 19packet TestCustomField { 20 v: Boolean, 21} 22 23packet TestArraySize { 24 _size_(array) : 8, 25 array : Struct[], 26} 27 28packet TestArrayCount { 29 _count_(array) : 8, 30 array : Struct[], 31} 32 33packet TestPayloadSize { 34 _size_(_payload_) : 8, 35 _payload_, 36} 37 38packet TestBodySize { 39 _size_(_body_) : 8, 40 _body_, 41} 42 43// Test Packets #1 44enum OpCode: 8 { 45 ADD_ERR = 0, 46 SUB_ERR = 1, 47 ADD_RES = 2, 48 SUB_RES = 3, 49 ADD = 4, 50 SUB = 5, 51} 52 53packet Command { 54 op_code : OpCode, 55 _size_(_payload_) : 8, 56 _payload_, 57} 58 59// Packets for interfaces 60 61packet ComputeCommand : Command { _payload_, } 62packet ResCommand: Command { _payload_, } 63packet ErrCommand: Command { _payload_, } 64 65 66packet AddRes: ResCommand (op_code = ADD_RES) { 67} 68 69packet SubRes: ResCommand (op_code = SUB_RES) { 70} 71 72packet AddCommand: ComputeCommand (op_code = ADD) { 73} 74 75packet SubCommand: ComputeCommand (op_code = SUB) { 76} 77 78packet AddErr: ErrCommand(op_code = ADD_ERR) { 79} 80 81packet SubErr: ErrCommand(op_code = SUB_ERR) { 82} 83 84test AddRes { 85 "\x02\x00", 86} 87 88test SubRes { 89 "\x03\x00", 90} 91 92test AddCommand { 93 "\x04\x00", 94} 95 96test SubCommand { 97 "\x05\x00", 98} 99 100test AddErr { 101 "\x00\x00", 102} 103 104test SubErr { 105 "\x01\x00", 106} 107 108 109// Test Packets #2 110enum Number : 8 { 111 ZERO = 0, 112 ONE = 1, 113 TWO = 2, 114 THREE = 3, 115 FOUR = 4, 116} 117 118packet GrandParent { 119 field_one : Number, 120 field_two : Number, 121 field_three: Number, 122 field_x: Number, 123 _payload_, 124} 125 126packet Parent : GrandParent { 127 field_four: Number, 128 field_five: Number, 129 field_y: Number, 130 _payload_, 131} 132 133 134packet ChildOneTwo: Parent (field_one = ONE, field_two = TWO) { 135} 136 137packet ChildThreeFour : Parent (field_one = THREE, field_two = FOUR) { 138} 139 140packet ChildThree: Parent(field_three = THREE) { 141 _fixed_ = 5 : 8, 142} 143 144packet GrandChildThreeFive: ChildThree(field_five = ZERO) { 145} 146 147packet GrandChildThreeY: ChildThree(field_y = FOUR) { 148} 149 150test ChildOneTwo { 151 "\x01\x02\x03\x01\x01\x02\x03", 152} 153 154test ChildThreeFour { 155 "\x03\x04\x03\x01\x03\x04\x03", 156} 157 158test ChildThree { 159 "\x01\x04\x03\x04\x03\x00\x02\x05", 160} 161 162test GrandChildThreeFive { 163 "\x01\x04\x03\x04\x03\x00\x02\x05", 164} 165