1
//! Flags parsed from fields
2

            
3
/// A flag used by the bus controller to manage remote terminals on the bus.
4
///
5
/// Mode Codes are flags defined by the 1553 standard to provide the Bus
6
/// Controller (BC) with bus management and error handling/recovery capability.
7
/// They are divided into two groups- those with and those without an associated
8
/// data word.
9
///
10
/// The data word (of which there can only be one) contains information pertinent
11
/// to the control of the bus and which is not generally required by the subsystem.
12
///
13
/// Mode Codes are defined by bit times 15-19 (index 11-15) of the command word,
14
/// the most significant bit of which (bit 15/index 11) of which can be used to
15
/// differentiate between the two mode-code groups. When a data word is associated
16
/// with the mode code, the T/R bit determines if the data word is transmitted or
17
/// received by the remote terminal.
18
///
19
/// Mode Codes are listed on page 40, in table 5, of the MIL-STD-1553 Tutorial[^1].
20
///
21
/// [^1]: [MIL-STD-1553 Tutorial](http://www.horntech.cn/techDocuments/MIL-STD-1553Tutorial.pdf)
22
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug)]
23
#[repr(u8)]
24
pub enum ModeCode {
25
    /// Dynamic Bus Control Mode Code is used to pass control of the data
26
    /// bus between terminals, thus supplying a “round robin” type of control.
27
    DynamicBusControl = 0b00000,
28

            
29
    /// Synchronize Mode Code is transmitted to an RT as a request that
30
    /// some predefined synchronization event occur.
31
    Synchronize = 0b00001,
32

            
33
    /// Transmit Status Word Mode Code requests that the RT transmit the
34
    /// status word associated with the previous message.
35
    TransmitStatusWord = 0b00010,
36

            
37
    /// Initiate Self Test Mode Code is used to take the receiving RT offline
38
    /// in order to perform internal testing.
39
    InitiateSelfTest = 0b00011,
40

            
41
    /// Transmitter Shutdown Mode Code is used by the BC to kill an RT
42
    /// which is continuously transmitting on the bus.
43
    TransmitterShutdown = 0b00100,
44

            
45
    /// Override Transmitter Shutdown Mode Code is used by the BC to restart
46
    /// an RT previously shutdown with the Transmitter Shutdown Mode Code.
47
    OverrideTransmitterShutdown = 0b00101,
48

            
49
    /// Inhibit Terminal Flag Bit Mode Code is used by the BC to request an RT
50
    /// set the Terminal Flag Bit in messages to 0, regardless of the true state.
51
    InhibitTerminalFlagBit = 0b00110,
52

            
53
    /// Override Inhibit Terminal Flag Bit is used by the BC to request an RT set
54
    /// the Terminal Flag Bit in messages based on the true state of the RT.
55
    OverrideInhibitTerminalFlagBit = 0b00111,
56

            
57
    /// Reset Remote Terminal Mode Code is used by the BC to request an RT set
58
    /// itself back to it's original state, as if it has just powered on.
59
    ResetRemoteTerminal = 0b01000,
60

            
61
    /// Transmit Vector Word Mode Code is used by the BC to request an RT transmit
62
    /// its current needs as a data word. Data word parsing is platform specific.
63
    TransmitVectorWord = 0b10000,
64

            
65
    /// Synchronize With Data Word Mode Code is the same as Synchronize, but with
66
    /// additional information included in a data word.
67
    SynchronizeWithDataWord = 0b10001,
68

            
69
    /// Transmit Last Command Word Mode Code is used by the BC to request that an RT
70
    /// transmit it's last received command word.
71
    TransmitLastCommandWord = 0b10010,
72

            
73
    /// Transmit Built-In-Test (BIT) Word Mode Code is used by the BC to request
74
    /// details of the BIT status of the RT.
75
    TransmitBITWord = 0b10011,
76

            
77
    /// Selected Transmitter Shutdown Mode Code is the same as TransmitterShutdown,
78
    /// but includes a specific bus (transmitter) in the data word.
79
    SelectedTransmitterShutdown = 0b10100,
80

            
81
    /// Override Selected Transmitter Shutdown Mode Code is the same as
82
    /// OverrideTransmitterShutdown but includes a specific bus (transmitter) in the data word.
83
    OverrideSelectedTransmitterShutdown = 0b10101,
84

            
85
    /// Unknown Mode Code is a catch-all for parsed mode codes that we don't
86
    /// recognize. This doesn't mean they are invalid, but they may be system-specific.
87
    UnknownModeCode(u8),
88
}
89

            
90
impl ModeCode {
91
    /// Get the actual u8 value of the mode code
92
32
    pub fn value(&self) -> u8 {
93
32
        (*self).into()
94
32
    }
95

            
96
    /// Check if mode code is associated with transmit messages
97
    ///
98
    /// If the TR bit is cleared, but this function returns true,
99
    /// then the message is illegal.
100
    #[must_use = "Returned value is not used"]
101
32
    pub const fn is_transmit(&self) -> bool {
102
8
        matches!(
103
32
            self,
104
            Self::DynamicBusControl
105
                | Self::SynchronizeWithDataWord
106
                | Self::TransmitStatusWord
107
                | Self::InitiateSelfTest
108
                | Self::TransmitterShutdown
109
                | Self::OverrideTransmitterShutdown
110
                | Self::InhibitTerminalFlagBit
111
                | Self::OverrideInhibitTerminalFlagBit
112
                | Self::ResetRemoteTerminal
113
                | Self::TransmitVectorWord
114
                | Self::TransmitLastCommandWord
115
                | Self::TransmitBITWord
116
        )
117
32
    }
118

            
119
    /// Check if mode code is associated with receive messages
120
    ///
121
    /// If the TR bit is set, but this function returns true,
122
    /// then the message is illegal.
123
    #[must_use = "Returned value is not used"]
124
32
    pub const fn is_receive(&self) -> bool {
125
26
        matches!(
126
32
            self,
127
            Self::Synchronize
128
                | Self::SelectedTransmitterShutdown
129
                | Self::OverrideSelectedTransmitterShutdown
130
        )
131
32
    }
132

            
133
    /// Check if data is associated with the mode code
134
    ///
135
    /// This property is true if the MSB of the mode
136
    /// code value is 1. TransmitBITWord, for example,
137
    /// has an actual value of 0b00010011, but the field
138
    /// in the word is five bits wide, making the value
139
    /// 0b10011. The MSB in this case is 1.
140
    ///
141
    /// For clarity, the enum variants are explicitly
142
    /// listed here rather than converted to a u8 and
143
    /// masked to get the bool value.
144
    #[must_use = "Returned value is not used"]
145
32
    pub const fn has_data(&self) -> bool {
146
20
        matches!(
147
32
            self,
148
            Self::TransmitVectorWord
149
                | Self::Synchronize
150
                | Self::TransmitLastCommandWord
151
                | Self::TransmitBITWord
152
                | Self::SelectedTransmitterShutdown
153
                | Self::OverrideSelectedTransmitterShutdown
154
        )
155
32
    }
156

            
157
    /// Check if mode code can be broadcast to all terminals
158
    ///
159
    /// Some mode codes can be sent to all receiving terminals
160
    /// (RTs) while for other codes, this would be nonsensical.
161
    /// Even if a mode code *can* be sent to all RTs, it may
162
    /// have disasterous consequences if done while in flight.
163
    #[must_use = "Returned value is not used"]
164
32
    pub const fn is_broadcast(&self) -> bool {
165
12
        matches!(
166
32
            self,
167
            Self::SynchronizeWithDataWord
168
                | Self::InitiateSelfTest
169
                | Self::TransmitterShutdown
170
                | Self::OverrideTransmitterShutdown
171
                | Self::InhibitTerminalFlagBit
172
                | Self::OverrideInhibitTerminalFlagBit
173
                | Self::ResetRemoteTerminal
174
                | Self::Synchronize
175
                | Self::SelectedTransmitterShutdown
176
                | Self::OverrideSelectedTransmitterShutdown
177
        )
178
32
    }
179

            
180
    /// Check if the mode code is unrecognized
181
    #[must_use = "Returned value is not used"]
182
32
    pub const fn is_unknown(&self) -> bool {
183
32
        matches!(self, Self::UnknownModeCode(_))
184
32
    }
185
}
186

            
187
impl From<u8> for ModeCode {
188
68
    fn from(value: u8) -> Self {
189
68
        use ModeCode::*;
190
68
        match value {
191
4
            0b00000 => DynamicBusControl,
192
4
            0b00001 => Synchronize,
193
4
            0b00010 => TransmitStatusWord,
194
6
            0b00011 => InitiateSelfTest,
195
4
            0b00100 => TransmitterShutdown,
196
4
            0b00101 => OverrideTransmitterShutdown,
197
4
            0b00110 => InhibitTerminalFlagBit,
198
4
            0b00111 => OverrideInhibitTerminalFlagBit,
199
4
            0b01000 => ResetRemoteTerminal,
200
6
            0b10000 => TransmitVectorWord,
201
4
            0b10001 => SynchronizeWithDataWord,
202
4
            0b10010 => TransmitLastCommandWord,
203
4
            0b10011 => TransmitBITWord,
204
4
            0b10100 => SelectedTransmitterShutdown,
205
4
            0b10101 => OverrideSelectedTransmitterShutdown,
206
4
            v => UnknownModeCode(v),
207
        }
208
68
    }
209
}
210

            
211
impl From<ModeCode> for u8 {
212
100
    fn from(value: ModeCode) -> Self {
213
100
        use ModeCode::*;
214
100
        match value {
215
6
            DynamicBusControl => 0b00000,
216
6
            Synchronize => 0b00001,
217
6
            TransmitStatusWord => 0b00010,
218
8
            InitiateSelfTest => 0b00011,
219
6
            TransmitterShutdown => 0b00100,
220
6
            OverrideTransmitterShutdown => 0b00101,
221
6
            InhibitTerminalFlagBit => 0b00110,
222
6
            OverrideInhibitTerminalFlagBit => 0b00111,
223
6
            ResetRemoteTerminal => 0b01000,
224
8
            TransmitVectorWord => 0b10000,
225
6
            SynchronizeWithDataWord => 0b10001,
226
6
            TransmitLastCommandWord => 0b10010,
227
6
            TransmitBITWord => 0b10011,
228
6
            SelectedTransmitterShutdown => 0b10100,
229
6
            OverrideSelectedTransmitterShutdown => 0b10101,
230
6
            UnknownModeCode(v) => v,
231
        }
232
100
    }
233
}
234

            
235
impl From<u16> for ModeCode {
236
36
    fn from(value: u16) -> Self {
237
36
        Self::from(value as u8)
238
36
    }
239
}
240

            
241
impl From<ModeCode> for u16 {
242
32
    fn from(value: ModeCode) -> Self {
243
32
        u8::from(value) as u16
244
32
    }
245
}
246

            
247
/// The direction of message transmission from the point of view of the remote terminal.
248
///
249
/// This flag is available in bit 9 (index 5). A transmit bit (logic 1)
250
/// indicates that the remote terminal is to transmit data, while a receive
251
/// command (logic 0) indicates that the remote terminal is going to receive
252
/// data. The only exceptions to this rule are associated with mode commands.
253
///
254
/// This flag is called T/R or Transmit/Receive on page 28 of the MIL-STD-1553 Tutorial[^1].
255
///
256
/// [^1]: [MIL-STD-1553 Tutorial](http://www.horntech.cn/techDocuments/MIL-STD-1553Tutorial.pdf)
257
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug)]
258
#[repr(u8)]
259
pub enum TransmitReceive {
260
    /// The remote terminal is receiving data
261
    Receive = 0,
262

            
263
    /// The remote terminal is to transmit data
264
    Transmit = 1,
265
}
266

            
267
impl TransmitReceive {
268
    /// Check if this enum is the receive variant
269
    #[must_use = "Returned value is not used"]
270
10
    pub const fn is_receive(&self) -> bool {
271
10
        matches!(self, Self::Receive)
272
10
    }
273

            
274
    /// Check if this enum is the transmit variant
275
    #[must_use = "Returned value is not used"]
276
10
    pub const fn is_transmit(&self) -> bool {
277
10
        matches!(self, Self::Transmit)
278
10
    }
279
}
280

            
281
impl From<u8> for TransmitReceive {
282
24
    fn from(value: u8) -> Self {
283
24
        match value {
284
10
            0 => Self::Receive,
285
14
            _ => Self::Transmit,
286
        }
287
24
    }
288
}
289

            
290
impl From<TransmitReceive> for u8 {
291
20
    fn from(value: TransmitReceive) -> Self {
292
20
        match value {
293
10
            TransmitReceive::Receive => 0,
294
10
            TransmitReceive::Transmit => 1,
295
        }
296
20
    }
297
}
298

            
299
impl From<u16> for TransmitReceive {
300
18
    fn from(value: u16) -> Self {
301
18
        Self::from(value as u8)
302
18
    }
303
}
304

            
305
impl From<TransmitReceive> for u16 {
306
4
    fn from(value: TransmitReceive) -> Self {
307
4
        u8::from(value) as u16
308
4
    }
309
}
310

            
311
/// The address of a remote terminal
312
///
313
/// This 5-bit address is found in the Terminal Address (TA) field located at bit times 4-8
314
/// (index 0-4). A value of 0b11111 is reserved in the TA field as a broadcast address. If
315
/// a value larger than 0b11111 is parsed, it will be truncated to 0b11111.
316
///
317
/// This field is described on page 28 of the MIL-STD-1553 Tutorial[^1].
318
///
319
/// [^1]: [MIL-STD-1553 Tutorial](http://www.horntech.cn/techDocuments/MIL-STD-1553Tutorial.pdf)
320
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
321
#[repr(u8)]
322
pub enum Address {
323
    /// The address references a terminal
324
    Value(u8),
325

            
326
    /// The address is a reserved broadcast value
327
    Broadcast(u8),
328
}
329

            
330
impl Address {
331
    /// The maximum real value that can be addressed
332
    const MAX: u8 = 0b11111;
333

            
334
    /// Check if this enum contains an address
335
    #[must_use = "Returned value is not used"]
336
4
    pub const fn is_value(&self) -> bool {
337
4
        matches!(self, Self::Value(_))
338
4
    }
339

            
340
    /// Check if this address is a reserved broadcast value
341
    #[must_use = "Returned value is not used"]
342
4
    pub const fn is_broadcast(&self) -> bool {
343
4
        matches!(self, Self::Broadcast(_))
344
4
    }
345
}
346

            
347
impl From<u8> for Address {
348
20
    fn from(v: u8) -> Address {
349
20
        match v {
350
20
            k if k < Self::MAX => Address::Value(k),
351
12
            k => Address::Broadcast(k & Self::MAX),
352
        }
353
20
    }
354
}
355

            
356
impl From<Address> for u8 {
357
16
    fn from(v: Address) -> u8 {
358
16
        match v {
359
8
            Address::Value(k) => k,
360
8
            Address::Broadcast(k) => k,
361
        }
362
16
    }
363
}
364

            
365
impl From<u16> for Address {
366
14
    fn from(value: u16) -> Self {
367
14
        Self::from(value as u8)
368
14
    }
369
}
370

            
371
impl From<Address> for u16 {
372
4
    fn from(value: Address) -> Self {
373
4
        u8::from(value) as u16
374
4
    }
375
}
376

            
377
/// The address of a subsystem within a remote terminal.
378
///
379
/// This 5-bit address is found in the Subaddress (SA) field located at bit times
380
/// 10-14 (index 6-10). If the SA value is 0b00000 or 0b11111, then the field is
381
/// decoded as a Mode Code command.
382
///
383
/// This field is described on page 28 of the MIL-STD-1553 Tutorial[^1].
384
///
385
/// [^1]: [MIL-STD-1553 Tutorial](http://www.horntech.cn/techDocuments/MIL-STD-1553Tutorial.pdf)
386
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
387
#[repr(u8)]
388
pub enum SubAddress {
389
    /// The address references a subsystem
390
    Value(u8),
391

            
392
    /// The address is a reserved mode code flag
393
    ModeCode(u8),
394
}
395

            
396
impl SubAddress {
397
    /// The maximum real value that can be addressed
398
    const MAX: u8 = 0b11111;
399

            
400
    /// Check if this enum contains an address
401
    #[must_use = "Returned value is not used"]
402
6
    pub const fn is_value(&self) -> bool {
403
6
        matches!(self, Self::Value(_))
404
6
    }
405

            
406
    /// Check if this address is a reserved mode code value
407
    #[must_use = "Returned value is not used"]
408
12
    pub const fn is_mode_code(&self) -> bool {
409
12
        matches!(self, Self::ModeCode(_))
410
12
    }
411
}
412

            
413
impl From<u8> for SubAddress {
414
24
    fn from(v: u8) -> SubAddress {
415
24
        match v {
416
24
            k if k < Self::MAX && k > 0 => SubAddress::Value(k),
417
16
            k => SubAddress::ModeCode(k & Self::MAX),
418
        }
419
24
    }
420
}
421

            
422
impl From<SubAddress> for u8 {
423
22
    fn from(v: SubAddress) -> u8 {
424
22
        match v {
425
8
            SubAddress::Value(k) => k,
426
14
            SubAddress::ModeCode(k) => k,
427
        }
428
22
    }
429
}
430

            
431
impl From<u16> for SubAddress {
432
16
    fn from(value: u16) -> Self {
433
16
        Self::from(value as u8)
434
16
    }
435
}
436

            
437
impl From<SubAddress> for u16 {
438
6
    fn from(value: SubAddress) -> Self {
439
6
        u8::from(value) as u16
440
6
    }
441
}
442

            
443
/// Used to differentiate between a command and status word.
444
///
445
/// The instrumentation bit in the status word is always set to a logic 0,
446
/// and if used, the same bit in a command word is set to logic 1. This bit
447
/// is the MSB of the Subaddress field, and if used will limit the subaddresses
448
/// used to 10000-11110, reducing the number of addressable terminals from 30
449
/// to 15. It is also the reason there are two mode code identifiers
450
/// (see [SubAddress]).
451
///
452
/// **Most systems no longer use this flag, as the cost in reduced subaddress
453
/// range is too high**.
454
///
455
/// This field is described in the status word diagram on page 28 of the
456
/// MIL-STD-1553 Tutorial[^1].
457
///
458
/// [^1]: [MIL-STD-1553 Tutorial](http://www.horntech.cn/techDocuments/MIL-STD-1553Tutorial.pdf)
459
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug)]
460
#[repr(u8)]
461
pub enum Instrumentation {
462
    /// The containing word is a status word
463
    Status = 0,
464

            
465
    /// The containing word is a command word
466
    Command = 1,
467
}
468

            
469
impl Instrumentation {
470
    /// Check if this enum is the Status variant
471
    #[must_use = "Returned value is not used"]
472
4
    pub const fn is_status(&self) -> bool {
473
4
        matches!(self, Self::Status)
474
4
    }
475

            
476
    /// Check if this enum is the Command variant
477
    #[must_use = "Returned value is not used"]
478
4
    pub const fn is_command(&self) -> bool {
479
4
        matches!(self, Self::Command)
480
4
    }
481
}
482

            
483
impl From<u8> for Instrumentation {
484
16
    fn from(value: u8) -> Self {
485
16
        match value {
486
6
            0 => Self::Status,
487
10
            _ => Self::Command,
488
        }
489
16
    }
490
}
491

            
492
impl From<Instrumentation> for u8 {
493
12
    fn from(value: Instrumentation) -> Self {
494
12
        match value {
495
6
            Instrumentation::Status => 0,
496
6
            Instrumentation::Command => 1,
497
        }
498
12
    }
499
}
500

            
501
impl From<u16> for Instrumentation {
502
10
    fn from(value: u16) -> Self {
503
10
        Self::from(value as u8)
504
10
    }
505
}
506

            
507
impl From<Instrumentation> for u16 {
508
4
    fn from(value: Instrumentation) -> Self {
509
4
        u8::from(value) as u16
510
4
    }
511
}
512

            
513
/// Used by a remote terminal to tell the bus controller that it needs to be serviced.
514
///
515
/// This flag is located at bit time 11 (index 7) and is typically used when
516
/// the bus controller is polling terminals to determine if they require
517
/// processing. The bus controller, on receiving this flag, takes a predetermined
518
/// action such as issuing a series of messages or requests for further data
519
/// to the remote terminal.
520
///
521
/// This field is described in the status word diagram on page 28 of the
522
/// MIL-STD-1553 Tutorial[^1].
523
///
524
/// [^1]: [MIL-STD-1553 Tutorial](http://www.horntech.cn/techDocuments/MIL-STD-1553Tutorial.pdf)
525
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug)]
526
#[repr(u8)]
527
pub enum ServiceRequest {
528
    /// This terminal does not require servicing
529
    NoService = 0,
530

            
531
    /// This terminal requires servicing
532
    Service = 1,
533
}
534

            
535
impl ServiceRequest {
536
    /// Check if enum is the NoService variant
537
    #[must_use = "Returned value is not used"]
538
4
    pub const fn is_noservice(&self) -> bool {
539
4
        matches!(self, Self::NoService)
540
4
    }
541

            
542
    /// Check if the enum is the Service variant
543
    #[must_use = "Returned value is not used"]
544
4
    pub const fn is_service(&self) -> bool {
545
4
        matches!(self, Self::Service)
546
4
    }
547
}
548

            
549
impl From<u8> for ServiceRequest {
550
16
    fn from(value: u8) -> Self {
551
16
        match value {
552
6
            0 => Self::NoService,
553
10
            _ => Self::Service,
554
        }
555
16
    }
556
}
557

            
558
impl From<ServiceRequest> for u8 {
559
12
    fn from(value: ServiceRequest) -> Self {
560
12
        match value {
561
6
            ServiceRequest::NoService => 0,
562
6
            ServiceRequest::Service => 1,
563
        }
564
12
    }
565
}
566

            
567
impl From<u16> for ServiceRequest {
568
10
    fn from(value: u16) -> Self {
569
10
        Self::from(value as u8)
570
10
    }
571
}
572

            
573
impl From<ServiceRequest> for u16 {
574
4
    fn from(value: ServiceRequest) -> Self {
575
4
        u8::from(value) as u16
576
4
    }
577
}
578

            
579
/// Reserved bits that should always be zero
580
///
581
/// Bit times 12-14 (index 8-10) are reserved for future growth of the standard
582
/// and must be set to a logic “0”. The bus controller should declare a message
583
/// in error if the remote terminal responds with any of these bits set in its
584
/// status word.
585
///
586
/// This field is described in the status word diagram on page 28 of the
587
/// MIL-STD-1553 Tutorial[^1].
588
///
589
/// [^1]: [MIL-STD-1553 Tutorial](http://www.horntech.cn/techDocuments/MIL-STD-1553Tutorial.pdf)
590
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug)]
591
#[repr(u8)]
592
pub enum Reserved {
593
    /// The reserved bits are empty
594
    None = 0b000,
595

            
596
    /// The reserved bits are not empty
597
    Value(u8),
598
}
599

            
600
impl Reserved {
601
    /// Check if this enum is the None variant
602
    #[must_use = "Returned value is not used"]
603
4
    pub const fn is_none(&self) -> bool {
604
4
        matches!(self, Self::None)
605
4
    }
606

            
607
    /// Check if this enum is the Value variant
608
    #[must_use = "Returned value is not used"]
609
4
    pub const fn is_value(&self) -> bool {
610
4
        matches!(self, Self::Value(_))
611
4
    }
612
}
613

            
614
impl From<u8> for Reserved {
615
12
    fn from(value: u8) -> Self {
616
12
        match value {
617
6
            0 => Self::None,
618
6
            v => Self::Value(v),
619
        }
620
12
    }
621
}
622

            
623
impl From<Reserved> for u8 {
624
12
    fn from(value: Reserved) -> Self {
625
12
        match value {
626
6
            Reserved::None => 0,
627
6
            Reserved::Value(v) => v,
628
        }
629
12
    }
630
}
631

            
632
impl From<u16> for Reserved {
633
8
    fn from(value: u16) -> Self {
634
8
        Self::from(value as u8)
635
8
    }
636
}
637

            
638
impl From<Reserved> for u16 {
639
4
    fn from(value: Reserved) -> Self {
640
4
        u8::from(value) as u16
641
4
    }
642
}
643

            
644
/// Indicates that the remote terminal has received a valid broadcast command.
645
///
646
/// On receiving such a command, the remote terminal sets this flag and
647
/// suppresses transmission of its status words. The bus controller may then
648
/// issue a Transmit Status word or Transmit Last Command mode code to
649
/// determine if the terminal received the message properly.
650
///
651
/// This field is described in the status word diagram on page 28 of the
652
/// MIL-STD-1553 Tutorial[^1].
653
///
654
/// [^1]: [MIL-STD-1553 Tutorial](http://www.horntech.cn/techDocuments/MIL-STD-1553Tutorial.pdf)
655
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug)]
656
#[repr(u8)]
657
pub enum BroadcastReceived {
658
    /// This terminal has not received a broadcast command
659
    NotReceived = 0,
660

            
661
    /// This termina received a broadcast command
662
    Received = 1,
663
}
664

            
665
impl BroadcastReceived {
666
    /// Check if enum is the NotReceived variant
667
    #[must_use = "Returned value is not used"]
668
4
    pub const fn is_notreceived(&self) -> bool {
669
4
        matches!(self, Self::NotReceived)
670
4
    }
671

            
672
    /// Check if the enum is the Received variant
673
    #[must_use = "Returned value is not used"]
674
4
    pub const fn is_received(&self) -> bool {
675
4
        matches!(self, Self::Received)
676
4
    }
677
}
678

            
679
impl From<u8> for BroadcastReceived {
680
16
    fn from(value: u8) -> Self {
681
16
        match value {
682
6
            0 => Self::NotReceived,
683
10
            _ => Self::Received,
684
        }
685
16
    }
686
}
687

            
688
impl From<BroadcastReceived> for u8 {
689
12
    fn from(value: BroadcastReceived) -> Self {
690
12
        match value {
691
6
            BroadcastReceived::NotReceived => 0,
692
6
            BroadcastReceived::Received => 1,
693
        }
694
12
    }
695
}
696

            
697
impl From<u16> for BroadcastReceived {
698
10
    fn from(value: u16) -> Self {
699
10
        Self::from(value as u8)
700
10
    }
701
}
702

            
703
impl From<BroadcastReceived> for u16 {
704
4
    fn from(value: BroadcastReceived) -> Self {
705
4
        u8::from(value) as u16
706
4
    }
707
}
708

            
709
/// Indicates that the remote terminal is busy
710
///
711
/// The Busy bit, located at bit time 16 (index 12) is provided as
712
/// feedback to the bus controller when the remote terminal is unable to move
713
/// data between the remote terminal electronics and the subsystem in compliance
714
/// to a command from the bus controller.
715
///
716
/// This field is called "Busy" in the status word diagram on page 28 of the
717
/// MIL-STD-1553 Tutorial[^1].
718
///
719
/// [^1]: [MIL-STD-1553 Tutorial](http://www.horntech.cn/techDocuments/MIL-STD-1553Tutorial.pdf)
720
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug)]
721
#[repr(u8)]
722
pub enum TerminalBusy {
723
    /// This terminal is not busy
724
    NotBusy = 0,
725

            
726
    /// This terminal is busy
727
    Busy = 1,
728
}
729

            
730
impl TerminalBusy {
731
    /// Check if enum is the NotBusy variant
732
    #[must_use = "Returned value is not used"]
733
4
    pub const fn is_notbusy(&self) -> bool {
734
4
        matches!(self, Self::NotBusy)
735
4
    }
736

            
737
    /// Check if the enum is the Busy variant
738
    #[must_use = "Returned value is not used"]
739
8
    pub const fn is_busy(&self) -> bool {
740
8
        matches!(self, Self::Busy)
741
8
    }
742
}
743

            
744
impl From<u8> for TerminalBusy {
745
20
    fn from(value: u8) -> Self {
746
20
        match value {
747
8
            0 => Self::NotBusy,
748
12
            _ => Self::Busy,
749
        }
750
20
    }
751
}
752

            
753
impl From<TerminalBusy> for u8 {
754
12
    fn from(value: TerminalBusy) -> Self {
755
12
        match value {
756
6
            TerminalBusy::NotBusy => 0,
757
6
            TerminalBusy::Busy => 1,
758
        }
759
12
    }
760
}
761

            
762
impl From<u16> for TerminalBusy {
763
14
    fn from(value: u16) -> Self {
764
14
        Self::from(value as u8)
765
14
    }
766
}
767

            
768
impl From<TerminalBusy> for u16 {
769
4
    fn from(value: TerminalBusy) -> Self {
770
4
        u8::from(value) as u16
771
4
    }
772
}
773

            
774
/// Informs the bus controller that the terminal has accepted bus control.
775
///
776
/// This flag is set by remote terminals that have received the Dynamic Bus
777
/// Control Mode Code and have accepted control of the bus. The remote terminal,
778
/// on transmitting its status word, becomes the bus controller, and the bus
779
/// controller, on receiving the status word with this flag, ceases to
780
/// control the bus.
781
///
782
/// This field is called "Dynamic Bus Acceptance" in the status word diagram on
783
/// page 28 of the MIL-STD-1553 Tutorial[^1].
784
///
785
/// [^1]: [MIL-STD-1553 Tutorial](http://www.horntech.cn/techDocuments/MIL-STD-1553Tutorial.pdf)
786
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug)]
787
#[repr(u8)]
788
pub enum DynamicBusAcceptance {
789
    /// This terminal has refused control of the bus
790
    NotAccepted = 0,
791

            
792
    /// This terminal has accepted control of the bus
793
    Accepted = 1,
794
}
795

            
796
impl DynamicBusAcceptance {
797
    /// Check if the enum is the NotAccepted variant
798
    #[must_use = "Returned value is not used"]
799
4
    pub const fn is_notaccepted(&self) -> bool {
800
4
        matches!(self, Self::NotAccepted)
801
4
    }
802

            
803
    /// Check if the enum is the Accepted variant
804
    #[must_use = "Returned value is not used"]
805
4
    pub const fn is_accepted(&self) -> bool {
806
4
        matches!(self, Self::Accepted)
807
4
    }
808
}
809

            
810
impl From<u8> for DynamicBusAcceptance {
811
16
    fn from(value: u8) -> Self {
812
16
        match value {
813
6
            0 => Self::NotAccepted,
814
10
            _ => Self::Accepted,
815
        }
816
16
    }
817
}
818

            
819
impl From<DynamicBusAcceptance> for u8 {
820
12
    fn from(value: DynamicBusAcceptance) -> Self {
821
12
        match value {
822
6
            DynamicBusAcceptance::NotAccepted => 0,
823
6
            DynamicBusAcceptance::Accepted => 1,
824
        }
825
12
    }
826
}
827

            
828
impl From<u16> for DynamicBusAcceptance {
829
10
    fn from(value: u16) -> Self {
830
10
        Self::from(value as u8)
831
10
    }
832
}
833

            
834
impl From<DynamicBusAcceptance> for u16 {
835
4
    fn from(value: DynamicBusAcceptance) -> Self {
836
4
        u8::from(value) as u16
837
4
    }
838
}
839

            
840
#[cfg(test)]
841
mod tests {
842
    use super::*;
843

            
844
    #[test]
845
2
    fn test_mode_code_clone() {
846
2
        let item1 = ModeCode::InhibitTerminalFlagBit;
847
2
        let item2 = item1.clone();
848
2
        assert_eq!(item1, item2);
849
2
    }
850

            
851
    #[test]
852
2
    fn test_mode_code_value_0() {
853
2
        assert_eq!(ModeCode::DynamicBusControl.value(), 0b00000u8);
854
2
    }
855

            
856
    #[test]
857
2
    fn test_mode_code_value_1() {
858
2
        assert_eq!(ModeCode::Synchronize.value(), 0b00001u8);
859
2
    }
860

            
861
    #[test]
862
2
    fn test_mode_code_value_2() {
863
2
        assert_eq!(ModeCode::TransmitStatusWord.value(), 0b00010u8);
864
2
    }
865

            
866
    #[test]
867
2
    fn test_mode_code_value_3() {
868
2
        assert_eq!(ModeCode::InitiateSelfTest.value(), 0b00011u8);
869
2
    }
870

            
871
    #[test]
872
2
    fn test_mode_code_value_4() {
873
2
        assert_eq!(ModeCode::TransmitterShutdown.value(), 0b00100u8);
874
2
    }
875

            
876
    #[test]
877
2
    fn test_mode_code_value_5() {
878
2
        assert_eq!(ModeCode::OverrideTransmitterShutdown.value(), 0b00101u8);
879
2
    }
880

            
881
    #[test]
882
2
    fn test_mode_code_value_6() {
883
2
        assert_eq!(ModeCode::InhibitTerminalFlagBit.value(), 0b00110u8);
884
2
    }
885

            
886
    #[test]
887
2
    fn test_mode_code_value_7() {
888
2
        assert_eq!(ModeCode::OverrideInhibitTerminalFlagBit.value(), 0b00111u8);
889
2
    }
890

            
891
    #[test]
892
2
    fn test_mode_code_value_8() {
893
2
        assert_eq!(ModeCode::ResetRemoteTerminal.value(), 0b01000u8);
894
2
    }
895

            
896
    #[test]
897
2
    fn test_mode_code_value_9() {
898
2
        assert_eq!(ModeCode::TransmitVectorWord.value(), 0b10000u8);
899
2
    }
900

            
901
    #[test]
902
2
    fn test_mode_code_value_10() {
903
2
        assert_eq!(ModeCode::SynchronizeWithDataWord.value(), 0b10001u8);
904
2
    }
905

            
906
    #[test]
907
2
    fn test_mode_code_value_11() {
908
2
        assert_eq!(ModeCode::TransmitLastCommandWord.value(), 0b10010u8);
909
2
    }
910

            
911
    #[test]
912
2
    fn test_mode_code_value_12() {
913
2
        assert_eq!(ModeCode::TransmitBITWord.value(), 0b10011u8);
914
2
    }
915

            
916
    #[test]
917
2
    fn test_mode_code_value_13() {
918
2
        assert_eq!(ModeCode::SelectedTransmitterShutdown.value(), 0b10100u8);
919
2
    }
920

            
921
    #[test]
922
2
    fn test_mode_code_value_14() {
923
2
        assert_eq!(
924
2
            ModeCode::OverrideSelectedTransmitterShutdown.value(),
925
2
            0b10101u8
926
2
        );
927
2
    }
928

            
929
    #[test]
930
2
    fn test_mode_code_value_15() {
931
2
        assert_eq!(ModeCode::UnknownModeCode(0b11111u8).value(), 0b11111u8);
932
2
    }
933

            
934
    #[test]
935
2
    fn test_mode_code_is_transmit_0() {
936
2
        assert_eq!(ModeCode::DynamicBusControl.is_transmit(), true);
937
2
    }
938

            
939
    #[test]
940
2
    fn test_mode_code_is_transmit_1() {
941
2
        assert_eq!(ModeCode::Synchronize.is_transmit(), false);
942
2
    }
943

            
944
    #[test]
945
2
    fn test_mode_code_is_transmit_2() {
946
2
        assert_eq!(ModeCode::TransmitStatusWord.is_transmit(), true);
947
2
    }
948

            
949
    #[test]
950
2
    fn test_mode_code_is_transmit_3() {
951
2
        assert_eq!(ModeCode::InitiateSelfTest.is_transmit(), true);
952
2
    }
953

            
954
    #[test]
955
2
    fn test_mode_code_is_transmit_4() {
956
2
        assert_eq!(ModeCode::TransmitterShutdown.is_transmit(), true);
957
2
    }
958

            
959
    #[test]
960
2
    fn test_mode_code_is_transmit_5() {
961
2
        assert_eq!(ModeCode::OverrideTransmitterShutdown.is_transmit(), true);
962
2
    }
963

            
964
    #[test]
965
2
    fn test_mode_code_is_transmit_6() {
966
2
        assert_eq!(ModeCode::InhibitTerminalFlagBit.is_transmit(), true);
967
2
    }
968

            
969
    #[test]
970
2
    fn test_mode_code_is_transmit_7() {
971
2
        assert_eq!(ModeCode::OverrideInhibitTerminalFlagBit.is_transmit(), true);
972
2
    }
973

            
974
    #[test]
975
2
    fn test_mode_code_is_transmit_8() {
976
2
        assert_eq!(ModeCode::ResetRemoteTerminal.is_transmit(), true);
977
2
    }
978

            
979
    #[test]
980
2
    fn test_mode_code_is_transmit_9() {
981
2
        assert_eq!(ModeCode::TransmitVectorWord.is_transmit(), true);
982
2
    }
983

            
984
    #[test]
985
2
    fn test_mode_code_is_transmit_10() {
986
2
        assert_eq!(ModeCode::SynchronizeWithDataWord.is_transmit(), true);
987
2
    }
988

            
989
    #[test]
990
2
    fn test_mode_code_is_transmit_11() {
991
2
        assert_eq!(ModeCode::TransmitLastCommandWord.is_transmit(), true);
992
2
    }
993

            
994
    #[test]
995
2
    fn test_mode_code_is_transmit_12() {
996
2
        assert_eq!(ModeCode::TransmitBITWord.is_transmit(), true);
997
2
    }
998

            
999
    #[test]
2
    fn test_mode_code_is_transmit_13() {
2
        assert_eq!(ModeCode::SelectedTransmitterShutdown.is_transmit(), false);
2
    }
    #[test]
2
    fn test_mode_code_is_transmit_14() {
2
        assert_eq!(
2
            ModeCode::OverrideSelectedTransmitterShutdown.is_transmit(),
2
            false
2
        );
2
    }
    #[test]
2
    fn test_mode_code_is_transmit_15() {
2
        assert_eq!(ModeCode::UnknownModeCode(0b11111u8).is_transmit(), false);
2
    }
    #[test]
2
    fn test_mode_code_is_receive_0() {
2
        assert_eq!(ModeCode::DynamicBusControl.is_receive(), false);
2
    }
    #[test]
2
    fn test_mode_code_is_receive_1() {
2
        assert_eq!(ModeCode::Synchronize.is_receive(), true);
2
    }
    #[test]
2
    fn test_mode_code_is_receive_2() {
2
        assert_eq!(ModeCode::TransmitStatusWord.is_receive(), false);
2
    }
    #[test]
2
    fn test_mode_code_is_receive_3() {
2
        assert_eq!(ModeCode::InitiateSelfTest.is_receive(), false);
2
    }
    #[test]
2
    fn test_mode_code_is_receive_4() {
2
        assert_eq!(ModeCode::TransmitterShutdown.is_receive(), false);
2
    }
    #[test]
2
    fn test_mode_code_is_receive_5() {
2
        assert_eq!(ModeCode::OverrideTransmitterShutdown.is_receive(), false);
2
    }
    #[test]
2
    fn test_mode_code_is_receive_6() {
2
        assert_eq!(ModeCode::InhibitTerminalFlagBit.is_receive(), false);
2
    }
    #[test]
2
    fn test_mode_code_is_receive_7() {
2
        assert_eq!(ModeCode::OverrideInhibitTerminalFlagBit.is_receive(), false);
2
    }
    #[test]
2
    fn test_mode_code_is_receive_8() {
2
        assert_eq!(ModeCode::ResetRemoteTerminal.is_receive(), false);
2
    }
    #[test]
2
    fn test_mode_code_is_receive_9() {
2
        assert_eq!(ModeCode::TransmitVectorWord.is_receive(), false);
2
    }
    #[test]
2
    fn test_mode_code_is_receive_10() {
2
        assert_eq!(ModeCode::SynchronizeWithDataWord.is_receive(), false);
2
    }
    #[test]
2
    fn test_mode_code_is_receive_11() {
2
        assert_eq!(ModeCode::TransmitLastCommandWord.is_receive(), false);
2
    }
    #[test]
2
    fn test_mode_code_is_receive_12() {
2
        assert_eq!(ModeCode::TransmitBITWord.is_receive(), false);
2
    }
    #[test]
2
    fn test_mode_code_is_receive_13() {
2
        assert_eq!(ModeCode::SelectedTransmitterShutdown.is_receive(), true);
2
    }
    #[test]
2
    fn test_mode_code_is_receive_14() {
2
        assert_eq!(
2
            ModeCode::OverrideSelectedTransmitterShutdown.is_receive(),
2
            true
2
        );
2
    }
    #[test]
2
    fn test_mode_code_is_receive_15() {
2
        assert_eq!(ModeCode::UnknownModeCode(0b11111u8).is_receive(), false);
2
    }
    #[test]
2
    fn test_mode_code_has_data_0() {
2
        assert_eq!(ModeCode::DynamicBusControl.has_data(), false);
2
    }
    #[test]
2
    fn test_mode_code_has_data_1() {
2
        assert_eq!(ModeCode::Synchronize.has_data(), true);
2
    }
    #[test]
2
    fn test_mode_code_has_data_2() {
2
        assert_eq!(ModeCode::TransmitStatusWord.has_data(), false);
2
    }
    #[test]
2
    fn test_mode_code_has_data_3() {
2
        assert_eq!(ModeCode::InitiateSelfTest.has_data(), false);
2
    }
    #[test]
2
    fn test_mode_code_has_data_4() {
2
        assert_eq!(ModeCode::TransmitterShutdown.has_data(), false);
2
    }
    #[test]
2
    fn test_mode_code_has_data_5() {
2
        assert_eq!(ModeCode::OverrideTransmitterShutdown.has_data(), false);
2
    }
    #[test]
2
    fn test_mode_code_has_data_6() {
2
        assert_eq!(ModeCode::InhibitTerminalFlagBit.has_data(), false);
2
    }
    #[test]
2
    fn test_mode_code_has_data_7() {
2
        assert_eq!(ModeCode::OverrideInhibitTerminalFlagBit.has_data(), false);
2
    }
    #[test]
2
    fn test_mode_code_has_data_8() {
2
        assert_eq!(ModeCode::ResetRemoteTerminal.has_data(), false);
2
    }
    #[test]
2
    fn test_mode_code_has_data_9() {
2
        assert_eq!(ModeCode::TransmitVectorWord.has_data(), true);
2
    }
    #[test]
2
    fn test_mode_code_has_data_10() {
2
        assert_eq!(ModeCode::SynchronizeWithDataWord.has_data(), false);
2
    }
    #[test]
2
    fn test_mode_code_has_data_11() {
2
        assert_eq!(ModeCode::TransmitLastCommandWord.has_data(), true);
2
    }
    #[test]
2
    fn test_mode_code_has_data_12() {
2
        assert_eq!(ModeCode::TransmitBITWord.has_data(), true);
2
    }
    #[test]
2
    fn test_mode_code_has_data_13() {
2
        assert_eq!(ModeCode::SelectedTransmitterShutdown.has_data(), true);
2
    }
    #[test]
2
    fn test_mode_code_has_data_14() {
2
        assert_eq!(
2
            ModeCode::OverrideSelectedTransmitterShutdown.has_data(),
2
            true
2
        );
2
    }
    #[test]
2
    fn test_mode_code_has_data_15() {
2
        assert_eq!(ModeCode::UnknownModeCode(0b11111u8).has_data(), false);
2
    }
    #[test]
2
    fn test_mode_code_is_broadcast_0() {
2
        assert_eq!(ModeCode::DynamicBusControl.is_broadcast(), false);
2
    }
    #[test]
2
    fn test_mode_code_is_broadcast_1() {
2
        assert_eq!(ModeCode::Synchronize.is_broadcast(), true);
2
    }
    #[test]
2
    fn test_mode_code_is_broadcast_2() {
2
        assert_eq!(ModeCode::TransmitStatusWord.is_broadcast(), false);
2
    }
    #[test]
2
    fn test_mode_code_is_broadcast_3() {
2
        assert_eq!(ModeCode::InitiateSelfTest.is_broadcast(), true);
2
    }
    #[test]
2
    fn test_mode_code_is_broadcast_4() {
2
        assert_eq!(ModeCode::TransmitterShutdown.is_broadcast(), true);
2
    }
    #[test]
2
    fn test_mode_code_is_broadcast_5() {
2
        assert_eq!(ModeCode::OverrideTransmitterShutdown.is_broadcast(), true);
2
    }
    #[test]
2
    fn test_mode_code_is_broadcast_6() {
2
        assert_eq!(ModeCode::InhibitTerminalFlagBit.is_broadcast(), true);
2
    }
    #[test]
2
    fn test_mode_code_is_broadcast_7() {
2
        assert_eq!(
2
            ModeCode::OverrideInhibitTerminalFlagBit.is_broadcast(),
2
            true
2
        );
2
    }
    #[test]
2
    fn test_mode_code_is_broadcast_8() {
2
        assert_eq!(ModeCode::ResetRemoteTerminal.is_broadcast(), true);
2
    }
    #[test]
2
    fn test_mode_code_is_broadcast_9() {
2
        assert_eq!(ModeCode::TransmitVectorWord.is_broadcast(), false);
2
    }
    #[test]
2
    fn test_mode_code_is_broadcast_10() {
2
        assert_eq!(ModeCode::SynchronizeWithDataWord.is_broadcast(), true);
2
    }
    #[test]
2
    fn test_mode_code_is_broadcast_11() {
2
        assert_eq!(ModeCode::TransmitLastCommandWord.is_broadcast(), false);
2
    }
    #[test]
2
    fn test_mode_code_is_broadcast_12() {
2
        assert_eq!(ModeCode::TransmitBITWord.is_broadcast(), false);
2
    }
    #[test]
2
    fn test_mode_code_is_broadcast_13() {
2
        assert_eq!(ModeCode::SelectedTransmitterShutdown.is_broadcast(), true);
2
    }
    #[test]
2
    fn test_mode_code_is_broadcast_14() {
2
        assert_eq!(
2
            ModeCode::OverrideSelectedTransmitterShutdown.is_broadcast(),
2
            true
2
        );
2
    }
    #[test]
2
    fn test_mode_code_is_broadcast_15() {
2
        assert_eq!(ModeCode::UnknownModeCode(0b11111u8).is_broadcast(), false);
2
    }
    #[test]
2
    fn test_mode_code_is_unknown_0() {
2
        assert_eq!(ModeCode::DynamicBusControl.is_unknown(), false);
2
    }
    #[test]
2
    fn test_mode_code_is_unknown_1() {
2
        assert_eq!(ModeCode::Synchronize.is_unknown(), false);
2
    }
    #[test]
2
    fn test_mode_code_is_unknown_2() {
2
        assert_eq!(ModeCode::TransmitStatusWord.is_unknown(), false);
2
    }
    #[test]
2
    fn test_mode_code_is_unknown_3() {
2
        assert_eq!(ModeCode::InitiateSelfTest.is_unknown(), false);
2
    }
    #[test]
2
    fn test_mode_code_is_unknown_4() {
2
        assert_eq!(ModeCode::TransmitterShutdown.is_unknown(), false);
2
    }
    #[test]
2
    fn test_mode_code_is_unknown_5() {
2
        assert_eq!(ModeCode::OverrideTransmitterShutdown.is_unknown(), false);
2
    }
    #[test]
2
    fn test_mode_code_is_unknown_6() {
2
        assert_eq!(ModeCode::InhibitTerminalFlagBit.is_unknown(), false);
2
    }
    #[test]
2
    fn test_mode_code_is_unknown_7() {
2
        assert_eq!(ModeCode::OverrideInhibitTerminalFlagBit.is_unknown(), false);
2
    }
    #[test]
2
    fn test_mode_code_is_unknown_8() {
2
        assert_eq!(ModeCode::ResetRemoteTerminal.is_unknown(), false);
2
    }
    #[test]
2
    fn test_mode_code_is_unknown_9() {
2
        assert_eq!(ModeCode::TransmitVectorWord.is_unknown(), false);
2
    }
    #[test]
2
    fn test_mode_code_is_unknown_10() {
2
        assert_eq!(ModeCode::SynchronizeWithDataWord.is_unknown(), false);
2
    }
    #[test]
2
    fn test_mode_code_is_unknown_11() {
2
        assert_eq!(ModeCode::TransmitLastCommandWord.is_unknown(), false);
2
    }
    #[test]
2
    fn test_mode_code_is_unknown_12() {
2
        assert_eq!(ModeCode::TransmitBITWord.is_unknown(), false);
2
    }
    #[test]
2
    fn test_mode_code_is_unknown_13() {
2
        assert_eq!(ModeCode::SelectedTransmitterShutdown.is_unknown(), false);
2
    }
    #[test]
2
    fn test_mode_code_is_unknown_14() {
2
        assert_eq!(
2
            ModeCode::OverrideSelectedTransmitterShutdown.is_unknown(),
2
            false
2
        );
2
    }
    #[test]
2
    fn test_mode_code_is_unknown_15() {
2
        assert_eq!(ModeCode::UnknownModeCode(0b11111u8).is_unknown(), true);
2
    }
    #[test]
2
    fn test_mode_code_from_u8_0() {
2
        assert_eq!(ModeCode::from(0b00000u8), ModeCode::DynamicBusControl);
2
    }
    #[test]
2
    fn test_mode_code_from_u8_1() {
2
        assert_eq!(ModeCode::from(0b00001u8), ModeCode::Synchronize);
2
    }
    #[test]
2
    fn test_mode_code_from_u8_2() {
2
        assert_eq!(ModeCode::from(0b00010u8), ModeCode::TransmitStatusWord);
2
    }
    #[test]
2
    fn test_mode_code_from_u8_3() {
2
        assert_eq!(ModeCode::from(0b00011u8), ModeCode::InitiateSelfTest);
2
    }
    #[test]
2
    fn test_mode_code_from_u8_4() {
2
        assert_eq!(ModeCode::from(0b00100u8), ModeCode::TransmitterShutdown);
2
    }
    #[test]
2
    fn test_mode_code_from_u8_5() {
2
        assert_eq!(
2
            ModeCode::from(0b00101u8),
2
            ModeCode::OverrideTransmitterShutdown
2
        );
2
    }
    #[test]
2
    fn test_mode_code_from_u8_6() {
2
        assert_eq!(ModeCode::from(0b00110u8), ModeCode::InhibitTerminalFlagBit);
2
    }
    #[test]
2
    fn test_mode_code_from_u8_7() {
2
        assert_eq!(
2
            ModeCode::from(0b00111u8),
2
            ModeCode::OverrideInhibitTerminalFlagBit
2
        );
2
    }
    #[test]
2
    fn test_mode_code_from_u8_8() {
2
        assert_eq!(ModeCode::from(0b01000u8), ModeCode::ResetRemoteTerminal);
2
    }
    #[test]
2
    fn test_mode_code_from_u8_9() {
2
        assert_eq!(ModeCode::from(0b10000u8), ModeCode::TransmitVectorWord);
2
    }
    #[test]
2
    fn test_mode_code_from_u8_10() {
2
        assert_eq!(ModeCode::from(0b10001u8), ModeCode::SynchronizeWithDataWord);
2
    }
    #[test]
2
    fn test_mode_code_from_u8_11() {
2
        assert_eq!(ModeCode::from(0b10010u8), ModeCode::TransmitLastCommandWord);
2
    }
    #[test]
2
    fn test_mode_code_from_u8_12() {
2
        assert_eq!(ModeCode::from(0b10011u8), ModeCode::TransmitBITWord);
2
    }
    #[test]
2
    fn test_mode_code_from_u8_13() {
2
        assert_eq!(
2
            ModeCode::from(0b10100u8),
2
            ModeCode::SelectedTransmitterShutdown
2
        );
2
    }
    #[test]
2
    fn test_mode_code_from_u8_14() {
2
        assert_eq!(
2
            ModeCode::from(0b10101u8),
2
            ModeCode::OverrideSelectedTransmitterShutdown
2
        );
2
    }
    #[test]
2
    fn test_mode_code_from_u8_15() {
2
        assert_eq!(
2
            ModeCode::from(0b11111u8),
2
            ModeCode::UnknownModeCode(0b11111u8)
2
        );
2
    }
    #[test]
2
    fn test_mode_code_from_u16_0() {
2
        assert_eq!(ModeCode::from(0b00000u16), ModeCode::DynamicBusControl);
2
    }
    #[test]
2
    fn test_mode_code_from_u16_1() {
2
        assert_eq!(ModeCode::from(0b00001u16), ModeCode::Synchronize);
2
    }
    #[test]
2
    fn test_mode_code_from_u16_2() {
2
        assert_eq!(ModeCode::from(0b00010u16), ModeCode::TransmitStatusWord);
2
    }
    #[test]
2
    fn test_mode_code_from_u16_3() {
2
        assert_eq!(ModeCode::from(0b00011u16), ModeCode::InitiateSelfTest);
2
    }
    #[test]
2
    fn test_mode_code_from_u16_4() {
2
        assert_eq!(ModeCode::from(0b00100u16), ModeCode::TransmitterShutdown);
2
    }
    #[test]
2
    fn test_mode_code_from_u16_5() {
2
        assert_eq!(
2
            ModeCode::from(0b00101u16),
2
            ModeCode::OverrideTransmitterShutdown
2
        );
2
    }
    #[test]
2
    fn test_mode_code_from_u16_6() {
2
        assert_eq!(ModeCode::from(0b00110u16), ModeCode::InhibitTerminalFlagBit);
2
    }
    #[test]
2
    fn test_mode_code_from_u16_7() {
2
        assert_eq!(
2
            ModeCode::from(0b00111u16),
2
            ModeCode::OverrideInhibitTerminalFlagBit
2
        );
2
    }
    #[test]
2
    fn test_mode_code_from_u16_8() {
2
        assert_eq!(ModeCode::from(0b01000u16), ModeCode::ResetRemoteTerminal);
2
    }
    #[test]
2
    fn test_mode_code_from_u16_9() {
2
        assert_eq!(ModeCode::from(0b10000u16), ModeCode::TransmitVectorWord);
2
    }
    #[test]
2
    fn test_mode_code_from_u16_10() {
2
        assert_eq!(
2
            ModeCode::from(0b10001u16),
2
            ModeCode::SynchronizeWithDataWord
2
        );
2
    }
    #[test]
2
    fn test_mode_code_from_u16_11() {
2
        assert_eq!(
2
            ModeCode::from(0b10010u16),
2
            ModeCode::TransmitLastCommandWord
2
        );
2
    }
    #[test]
2
    fn test_mode_code_from_u16_12() {
2
        assert_eq!(ModeCode::from(0b10011u16), ModeCode::TransmitBITWord);
2
    }
    #[test]
2
    fn test_mode_code_from_u16_13() {
2
        assert_eq!(
2
            ModeCode::from(0b10100u16),
2
            ModeCode::SelectedTransmitterShutdown
2
        );
2
    }
    #[test]
2
    fn test_mode_code_from_u16_14() {
2
        assert_eq!(
2
            ModeCode::from(0b10101u16),
2
            ModeCode::OverrideSelectedTransmitterShutdown
2
        );
2
    }
    #[test]
2
    fn test_mode_code_from_u16_15() {
2
        assert_eq!(
2
            ModeCode::from(0b101000_11111u16),
2
            ModeCode::UnknownModeCode(0b11111u8)
2
        );
2
    }
    #[test]
2
    fn test_mode_code_to_u8_0() {
2
        assert_eq!(u8::from(ModeCode::DynamicBusControl), 0b00000u8);
2
    }
    #[test]
2
    fn test_mode_code_to_u8_1() {
2
        assert_eq!(u8::from(ModeCode::Synchronize), 0b00001u8);
2
    }
    #[test]
2
    fn test_mode_code_to_u8_2() {
2
        assert_eq!(u8::from(ModeCode::TransmitStatusWord), 0b00010u8);
2
    }
    #[test]
2
    fn test_mode_code_to_u8_3() {
2
        assert_eq!(u8::from(ModeCode::InitiateSelfTest), 0b00011u8);
2
    }
    #[test]
2
    fn test_mode_code_to_u8_4() {
2
        assert_eq!(u8::from(ModeCode::TransmitterShutdown), 0b00100u8);
2
    }
    #[test]
2
    fn test_mode_code_to_u8_5() {
2
        assert_eq!(u8::from(ModeCode::OverrideTransmitterShutdown), 0b00101u8);
2
    }
    #[test]
2
    fn test_mode_code_to_u8_6() {
2
        assert_eq!(u8::from(ModeCode::InhibitTerminalFlagBit), 0b00110u8);
2
    }
    #[test]
2
    fn test_mode_code_to_u8_7() {
2
        assert_eq!(
2
            u8::from(ModeCode::OverrideInhibitTerminalFlagBit),
2
            0b00111u8
2
        );
2
    }
    #[test]
2
    fn test_mode_code_to_u8_8() {
2
        assert_eq!(u8::from(ModeCode::ResetRemoteTerminal), 0b01000u8);
2
    }
    #[test]
2
    fn test_mode_code_to_u8_9() {
2
        assert_eq!(u8::from(ModeCode::TransmitVectorWord), 0b10000u8);
2
    }
    #[test]
2
    fn test_mode_code_to_u8_10() {
2
        assert_eq!(u8::from(ModeCode::SynchronizeWithDataWord), 0b10001u8);
2
    }
    #[test]
2
    fn test_mode_code_to_u8_11() {
2
        assert_eq!(u8::from(ModeCode::TransmitLastCommandWord), 0b10010u8);
2
    }
    #[test]
2
    fn test_mode_code_to_u8_12() {
2
        assert_eq!(u8::from(ModeCode::TransmitBITWord), 0b10011u8);
2
    }
    #[test]
2
    fn test_mode_code_to_u8_13() {
2
        assert_eq!(u8::from(ModeCode::SelectedTransmitterShutdown), 0b10100u8);
2
    }
    #[test]
2
    fn test_mode_code_to_u8_14() {
2
        assert_eq!(
2
            u8::from(ModeCode::OverrideSelectedTransmitterShutdown),
2
            0b10101u8
2
        );
2
    }
    #[test]
2
    fn test_mode_code_to_u8_15() {
2
        assert_eq!(u8::from(ModeCode::UnknownModeCode(0b11111u8)), 0b11111u8);
2
    }
    #[test]
2
    fn test_mode_code_to_u16_0() {
2
        assert_eq!(u16::from(ModeCode::DynamicBusControl), 0b00000u16);
2
    }
    #[test]
2
    fn test_mode_code_to_u16_1() {
2
        assert_eq!(u16::from(ModeCode::Synchronize), 0b00001u16);
2
    }
    #[test]
2
    fn test_mode_code_to_u16_2() {
2
        assert_eq!(u16::from(ModeCode::TransmitStatusWord), 0b00010u16);
2
    }
    #[test]
2
    fn test_mode_code_to_u16_3() {
2
        assert_eq!(u16::from(ModeCode::InitiateSelfTest), 0b00011u16);
2
    }
    #[test]
2
    fn test_mode_code_to_u16_4() {
2
        assert_eq!(u16::from(ModeCode::TransmitterShutdown), 0b00100u16);
2
    }
    #[test]
2
    fn test_mode_code_to_u16_5() {
2
        assert_eq!(u16::from(ModeCode::OverrideTransmitterShutdown), 0b00101u16);
2
    }
    #[test]
2
    fn test_mode_code_to_u16_6() {
2
        assert_eq!(u16::from(ModeCode::InhibitTerminalFlagBit), 0b00110u16);
2
    }
    #[test]
2
    fn test_mode_code_to_u16_7() {
2
        assert_eq!(
2
            u16::from(ModeCode::OverrideInhibitTerminalFlagBit),
2
            0b00111u16
2
        );
2
    }
    #[test]
2
    fn test_mode_code_to_u16_8() {
2
        assert_eq!(u16::from(ModeCode::ResetRemoteTerminal), 0b01000u16);
2
    }
    #[test]
2
    fn test_mode_code_to_u16_9() {
2
        assert_eq!(u16::from(ModeCode::TransmitVectorWord), 0b10000u16);
2
    }
    #[test]
2
    fn test_mode_code_to_u16_10() {
2
        assert_eq!(u16::from(ModeCode::SynchronizeWithDataWord), 0b10001u16);
2
    }
    #[test]
2
    fn test_mode_code_to_u16_11() {
2
        assert_eq!(u16::from(ModeCode::TransmitLastCommandWord), 0b10010u16);
2
    }
    #[test]
2
    fn test_mode_code_to_u16_12() {
2
        assert_eq!(u16::from(ModeCode::TransmitBITWord), 0b10011u16);
2
    }
    #[test]
2
    fn test_mode_code_to_u16_13() {
2
        assert_eq!(u16::from(ModeCode::SelectedTransmitterShutdown), 0b10100u16);
2
    }
    #[test]
2
    fn test_mode_code_to_u16_14() {
2
        assert_eq!(
2
            u16::from(ModeCode::OverrideSelectedTransmitterShutdown),
2
            0b10101u16
2
        );
2
    }
    #[test]
2
    fn test_mode_code_to_u16_15() {
2
        assert_eq!(u16::from(ModeCode::UnknownModeCode(0b11111u8)), 0b11111u16);
2
    }
    #[test]
2
    fn test_transmit_receive_clone() {
2
        let item1 = TransmitReceive::Transmit;
2
        let item2 = item1.clone();
2
        assert_eq!(item1, item2);
2
    }
    #[test]
2
    fn test_transmit_receive_is_transmit_0() {
2
        assert_eq!(TransmitReceive::Receive.is_transmit(), false);
2
    }
    #[test]
2
    fn test_transmit_receive_is_transmit_1() {
2
        assert_eq!(TransmitReceive::Transmit.is_transmit(), true);
2
    }
    #[test]
2
    fn test_transmit_receive_is_receive_0() {
2
        assert_eq!(TransmitReceive::Receive.is_receive(), true);
2
    }
    #[test]
2
    fn test_transmit_receive_is_receive_1() {
2
        assert_eq!(TransmitReceive::Transmit.is_receive(), false);
2
    }
    #[test]
2
    fn test_transmit_receive_from_u8_0() {
2
        assert_eq!(TransmitReceive::from(0u8), TransmitReceive::Receive);
2
    }
    #[test]
2
    fn test_transmit_receive_from_u8_1() {
2
        assert_eq!(TransmitReceive::from(1u8), TransmitReceive::Transmit);
2
    }
    #[test]
2
    fn test_transmit_receive_from_u8_2() {
2
        assert_eq!(TransmitReceive::from(2u8), TransmitReceive::Transmit);
2
    }
    #[test]
2
    fn test_transmit_receive_from_u16_0() {
2
        assert_eq!(TransmitReceive::from(0u16), TransmitReceive::Receive);
2
    }
    #[test]
2
    fn test_transmit_receive_from_u16_1() {
2
        assert_eq!(TransmitReceive::from(1u16), TransmitReceive::Transmit);
2
    }
    #[test]
2
    fn test_transmit_receive_from_u16_2() {
2
        assert_eq!(TransmitReceive::from(2u16), TransmitReceive::Transmit);
2
    }
    #[test]
2
    fn test_transmit_receive_to_u8_0() {
2
        assert_eq!(u8::from(TransmitReceive::Receive), 0);
2
    }
    #[test]
2
    fn test_transmit_receive_to_u8_1() {
2
        assert_eq!(u8::from(TransmitReceive::Transmit), 1);
2
    }
    #[test]
2
    fn test_transmit_receive_to_u16_0() {
2
        assert_eq!(u16::from(TransmitReceive::Receive), 0);
2
    }
    #[test]
2
    fn test_transmit_receive_to_u16_1() {
2
        assert_eq!(u16::from(TransmitReceive::Transmit), 1);
2
    }
    #[test]
2
    fn test_address_clone() {
2
        let item1 = Address::Broadcast(0b11111u8);
2
        let item2 = item1.clone();
2
        assert_eq!(item1, item2);
2
    }
    #[test]
2
    fn test_address_is_value_0() {
2
        assert_eq!(Address::Value(0b10101u8).is_value(), true);
2
    }
    #[test]
2
    fn test_address_is_value_2() {
2
        assert_eq!(Address::Broadcast(0b11111u8).is_value(), false);
2
    }
    #[test]
2
    fn test_address_is_broadcast_0() {
2
        assert_eq!(Address::Value(0b10101u8).is_broadcast(), false);
2
    }
    #[test]
2
    fn test_address_is_broadcast_2() {
2
        assert_eq!(Address::Broadcast(0b11111u8).is_broadcast(), true);
2
    }
    #[test]
2
    fn test_address_from_u8_0() {
2
        assert_eq!(Address::from(0b10101u8), Address::Value(0b10101u8));
2
    }
    #[test]
2
    fn test_address_from_u8_2() {
2
        assert_eq!(Address::from(0b11111u8), Address::Broadcast(0b11111u8));
2
    }
    #[test]
2
    fn test_address_from_u8_3() {
2
        assert_eq!(Address::from(0b11111111u8), Address::Broadcast(0b11111u8));
2
    }
    #[test]
2
    fn test_address_from_u16_0() {
2
        assert_eq!(Address::from(0b10101u16), Address::Value(0b10101u8));
2
    }
    #[test]
2
    fn test_address_from_u16_2() {
2
        assert_eq!(Address::from(0b11111u16), Address::Broadcast(0b11111u8));
2
    }
    #[test]
2
    fn test_address_from_u16_3() {
2
        assert_eq!(Address::from(0b11111111u16), Address::Broadcast(0b11111u8));
2
    }
    #[test]
2
    fn test_address_to_u8_0() {
2
        assert_eq!(u8::from(Address::Value(0b10101u8)), 0b10101u8);
2
    }
    #[test]
2
    fn test_address_to_u8_2() {
2
        assert_eq!(u8::from(Address::Broadcast(0b11111u8)), 0b11111u8);
2
    }
    #[test]
2
    fn test_address_to_u16_0() {
2
        assert_eq!(u16::from(Address::Value(0b10101u8)), 0b10101u16);
2
    }
    #[test]
2
    fn test_address_to_u16_2() {
2
        assert_eq!(u16::from(Address::Broadcast(0b11111u8)), 0b11111u16);
2
    }
    #[test]
2
    fn test_subaddress_clone() {
2
        let item1 = SubAddress::ModeCode(0b11111u8);
2
        let item2 = item1.clone();
2
        assert_eq!(item1, item2);
2
    }
    #[test]
2
    fn test_subaddress_is_value_0() {
2
        assert_eq!(SubAddress::Value(0b10101u8).is_value(), true);
2
    }
    #[test]
2
    fn test_subaddress_is_value_2() {
2
        assert_eq!(SubAddress::ModeCode(0b11111u8).is_value(), false);
2
    }
    #[test]
2
    fn test_subaddress_is_value_3() {
2
        assert_eq!(SubAddress::ModeCode(0b00000u8).is_value(), false);
2
    }
    #[test]
2
    fn test_subaddress_is_mode_code_0() {
2
        assert_eq!(SubAddress::Value(0b10101u8).is_mode_code(), false);
2
    }
    #[test]
2
    fn test_subaddress_is_mode_code_2() {
2
        assert_eq!(SubAddress::ModeCode(0b11111u8).is_mode_code(), true);
2
    }
    #[test]
2
    fn test_subaddress_is_mode_code_3() {
2
        assert_eq!(SubAddress::ModeCode(0b00000u8).is_mode_code(), true);
2
    }
    #[test]
2
    fn test_subaddress_to_u8_0() {
2
        assert_eq!(u8::from(SubAddress::Value(0b10101u8)), 0b10101u8);
2
    }
    #[test]
2
    fn test_subaddress_to_u8_2() {
2
        assert_eq!(u8::from(SubAddress::ModeCode(0b11111u8)), 0b11111u8);
2
    }
    #[test]
2
    fn test_subaddress_to_u8_3() {
2
        assert_eq!(u8::from(SubAddress::ModeCode(0b00000u8)), 0b00000u8);
2
    }
    #[test]
2
    fn test_subaddress_to_u16_0() {
2
        assert_eq!(u16::from(SubAddress::Value(0b10101u8)), 0b10101u16);
2
    }
    #[test]
2
    fn test_subaddress_to_u16_2() {
2
        assert_eq!(u16::from(SubAddress::ModeCode(0b11111u8)), 0b11111u16);
2
    }
    #[test]
2
    fn test_subaddress_to_u16_3() {
2
        assert_eq!(u16::from(SubAddress::ModeCode(0b00000u8)), 0b00000u16);
2
    }
    #[test]
2
    fn test_subaddress_from_u8_0() {
2
        assert_eq!(SubAddress::from(0b10101u8), SubAddress::Value(0b10101u8));
2
    }
    #[test]
2
    fn test_subaddress_from_u8_2() {
2
        assert_eq!(SubAddress::from(0b00000u8), SubAddress::ModeCode(0b00000u8));
2
    }
    #[test]
2
    fn test_subaddress_from_u8_3() {
2
        assert_eq!(SubAddress::from(0b11111u8), SubAddress::ModeCode(0b11111u8));
2
    }
    #[test]
2
    fn test_subaddress_from_u16_0() {
2
        assert_eq!(SubAddress::from(0b10101u16), SubAddress::Value(0b10101u8));
2
    }
    #[test]
2
    fn test_subaddress_from_u16_2() {
2
        assert_eq!(
2
            SubAddress::from(0b00000u16),
2
            SubAddress::ModeCode(0b00000u8)
2
        );
2
    }
    #[test]
2
    fn test_subaddress_from_u16_3() {
2
        assert_eq!(
2
            SubAddress::from(0b11111u16),
2
            SubAddress::ModeCode(0b11111u8)
2
        );
2
    }
    #[test]
2
    fn test_subaddress_from_u8_4() {
2
        assert_eq!(
2
            SubAddress::from(0b11111111u8),
2
            SubAddress::ModeCode(0b11111u8)
2
        );
2
    }
    #[test]
2
    fn test_instrumentation_clone() {
2
        let item1 = Instrumentation::Command;
2
        let item2 = item1.clone();
2
        assert_eq!(item1, item2);
2
    }
    #[test]
2
    fn test_instrumentation_is_status_0() {
2
        assert_eq!(Instrumentation::Status.is_status(), true);
2
    }
    #[test]
2
    fn test_instrumentation_is_status_1() {
2
        assert_eq!(Instrumentation::Command.is_status(), false);
2
    }
    #[test]
2
    fn test_instrumentation_is_command_0() {
2
        assert_eq!(Instrumentation::Status.is_command(), false);
2
    }
    #[test]
2
    fn test_instrumentation_is_command_1() {
2
        assert_eq!(Instrumentation::Command.is_command(), true);
2
    }
    #[test]
2
    fn test_instrumentation_from_u8_0() {
2
        assert_eq!(Instrumentation::from(0u8), Instrumentation::Status);
2
    }
    #[test]
2
    fn test_instrumentation_from_u8_1() {
2
        assert_eq!(Instrumentation::from(1u8), Instrumentation::Command);
2
    }
    #[test]
2
    fn test_instrumentation_from_u8_2() {
2
        assert_eq!(Instrumentation::from(2u8), Instrumentation::Command);
2
    }
    #[test]
2
    fn test_instrumentation_to_u8_0() {
2
        assert_eq!(u8::from(Instrumentation::Status), 0);
2
    }
    #[test]
2
    fn test_instrumentation_to_u8_1() {
2
        assert_eq!(u8::from(Instrumentation::Command), 1);
2
    }
    #[test]
2
    fn test_instrumentation_from_u16_0() {
2
        assert_eq!(Instrumentation::from(0u16), Instrumentation::Status);
2
    }
    #[test]
2
    fn test_instrumentation_from_u16_1() {
2
        assert_eq!(Instrumentation::from(1u16), Instrumentation::Command);
2
    }
    #[test]
2
    fn test_instrumentation_from_u16_2() {
2
        assert_eq!(Instrumentation::from(2u16), Instrumentation::Command);
2
    }
    #[test]
2
    fn test_instrumentation_to_u16_0() {
2
        assert_eq!(u16::from(Instrumentation::Status), 0);
2
    }
    #[test]
2
    fn test_instrumentation_to_u16_1() {
2
        assert_eq!(u16::from(Instrumentation::Command), 1);
2
    }
    #[test]
2
    fn test_service_request_clone() {
2
        let item1 = ServiceRequest::Service;
2
        let item2 = item1.clone();
2
        assert_eq!(item1, item2);
2
    }
    #[test]
2
    fn test_service_request_is_noservice_0() {
2
        assert_eq!(ServiceRequest::NoService.is_noservice(), true);
2
    }
    #[test]
2
    fn test_service_request_is_noservice_1() {
2
        assert_eq!(ServiceRequest::Service.is_noservice(), false);
2
    }
    #[test]
2
    fn test_service_request_is_service_0() {
2
        assert_eq!(ServiceRequest::NoService.is_service(), false);
2
    }
    #[test]
2
    fn test_service_request_is_service_1() {
2
        assert_eq!(ServiceRequest::Service.is_service(), true);
2
    }
    #[test]
2
    fn test_service_request_from_u8_0() {
2
        assert_eq!(ServiceRequest::from(0u8), ServiceRequest::NoService);
2
    }
    #[test]
2
    fn test_service_request_from_u8_1() {
2
        assert_eq!(ServiceRequest::from(1u8), ServiceRequest::Service);
2
    }
    #[test]
2
    fn test_service_request_from_u8_2() {
2
        assert_eq!(ServiceRequest::from(2u8), ServiceRequest::Service);
2
    }
    #[test]
2
    fn test_service_request_to_u8_0() {
2
        assert_eq!(u8::from(ServiceRequest::NoService), 0);
2
    }
    #[test]
2
    fn test_service_request_to_u8_1() {
2
        assert_eq!(u8::from(ServiceRequest::Service), 1);
2
    }
    #[test]
2
    fn test_service_request_from_u16_0() {
2
        assert_eq!(ServiceRequest::from(0u16), ServiceRequest::NoService);
2
    }
    #[test]
2
    fn test_service_request_from_u16_1() {
2
        assert_eq!(ServiceRequest::from(1u16), ServiceRequest::Service);
2
    }
    #[test]
2
    fn test_service_request_from_u16_2() {
2
        assert_eq!(ServiceRequest::from(2u16), ServiceRequest::Service);
2
    }
    #[test]
2
    fn test_service_request_to_u16_0() {
2
        assert_eq!(u16::from(ServiceRequest::NoService), 0);
2
    }
    #[test]
2
    fn test_service_request_to_u16_1() {
2
        assert_eq!(u16::from(ServiceRequest::Service), 1);
2
    }
    #[test]
2
    fn test_reserved_clone() {
2
        let item1 = Reserved::Value(0b111u8);
2
        let item2 = item1.clone();
2
        assert_eq!(item1, item2);
2
    }
    #[test]
2
    fn test_reserved_is_none_0() {
2
        assert_eq!(Reserved::None.is_none(), true);
2
    }
    #[test]
2
    fn test_reserved_is_none_1() {
2
        assert_eq!(Reserved::Value(0b111u8).is_none(), false);
2
    }
    #[test]
2
    fn test_reserved_is_value_0() {
2
        assert_eq!(Reserved::None.is_value(), false);
2
    }
    #[test]
2
    fn test_reserved_is_value_1() {
2
        assert_eq!(Reserved::Value(0b111u8).is_value(), true);
2
    }
    #[test]
2
    fn test_reserved_from_u8_0() {
2
        assert_eq!(Reserved::from(0u8), Reserved::None);
2
    }
    #[test]
2
    fn test_reserved_from_u8_1() {
2
        assert_eq!(Reserved::from(0b111u8), Reserved::Value(0b111u8));
2
    }
    #[test]
2
    fn test_reserved_to_u8_0() {
2
        assert_eq!(u8::from(Reserved::None), 0);
2
    }
    #[test]
2
    fn test_reserved_to_u8_1() {
2
        assert_eq!(u8::from(Reserved::Value(0b111u8)), 0b111u8);
2
    }
    #[test]
2
    fn test_reserved_from_u16_0() {
2
        assert_eq!(Reserved::from(0u16), Reserved::None);
2
    }
    #[test]
2
    fn test_reserved_from_u16_1() {
2
        assert_eq!(Reserved::from(0b111u16), Reserved::Value(0b111u8));
2
    }
    #[test]
2
    fn test_reserved_to_u16_0() {
2
        assert_eq!(u16::from(Reserved::None), 0);
2
    }
    #[test]
2
    fn test_reserved_to_u16_1() {
2
        assert_eq!(u16::from(Reserved::Value(0b111u8)), 0b111u16);
2
    }
    #[test]
2
    fn test_broadcast_received_clone() {
2
        let item1 = BroadcastReceived::Received;
2
        let item2 = item1.clone();
2
        assert_eq!(item1, item2);
2
    }
    #[test]
2
    fn test_broadcast_received_is_notreceived_0() {
2
        assert_eq!(BroadcastReceived::NotReceived.is_notreceived(), true);
2
    }
    #[test]
2
    fn test_broadcast_received_is_notreceived_1() {
2
        assert_eq!(BroadcastReceived::Received.is_notreceived(), false);
2
    }
    #[test]
2
    fn test_broadcast_received_is_received_0() {
2
        assert_eq!(BroadcastReceived::NotReceived.is_received(), false);
2
    }
    #[test]
2
    fn test_broadcast_received_is_received_1() {
2
        assert_eq!(BroadcastReceived::Received.is_received(), true);
2
    }
    #[test]
2
    fn test_broadcast_received_from_u8_0() {
2
        assert_eq!(BroadcastReceived::from(0u8), BroadcastReceived::NotReceived);
2
    }
    #[test]
2
    fn test_broadcast_received_from_u8_1() {
2
        assert_eq!(BroadcastReceived::from(1u8), BroadcastReceived::Received);
2
    }
    #[test]
2
    fn test_broadcast_received_from_u8_2() {
2
        assert_eq!(BroadcastReceived::from(2u8), BroadcastReceived::Received);
2
    }
    #[test]
2
    fn test_broadcast_received_to_u8_0() {
2
        assert_eq!(u8::from(BroadcastReceived::NotReceived), 0);
2
    }
    #[test]
2
    fn test_broadcast_received_to_u8_1() {
2
        assert_eq!(u8::from(BroadcastReceived::Received), 1);
2
    }
    #[test]
2
    fn test_broadcast_received_from_u16_0() {
2
        assert_eq!(
2
            BroadcastReceived::from(0u16),
2
            BroadcastReceived::NotReceived
2
        );
2
    }
    #[test]
2
    fn test_broadcast_received_from_u16_1() {
2
        assert_eq!(BroadcastReceived::from(1u16), BroadcastReceived::Received);
2
    }
    #[test]
2
    fn test_broadcast_received_from_u16_2() {
2
        assert_eq!(BroadcastReceived::from(2u16), BroadcastReceived::Received);
2
    }
    #[test]
2
    fn test_broadcast_received_to_u16_0() {
2
        assert_eq!(u16::from(BroadcastReceived::NotReceived), 0);
2
    }
    #[test]
2
    fn test_broadcast_received_to_u16_1() {
2
        assert_eq!(u16::from(BroadcastReceived::Received), 1);
2
    }
    #[test]
2
    fn test_terminal_busy_clone() {
2
        let item1 = TerminalBusy::Busy;
2
        let item2 = item1.clone();
2
        assert_eq!(item1, item2);
2
    }
    #[test]
2
    fn test_terminal_busy_is_notbusy_0() {
2
        assert_eq!(TerminalBusy::NotBusy.is_notbusy(), true);
2
    }
    #[test]
2
    fn test_terminal_busy_is_notbusy_1() {
2
        assert_eq!(TerminalBusy::Busy.is_notbusy(), false);
2
    }
    #[test]
2
    fn test_terminal_busy_is_busy_0() {
2
        assert_eq!(TerminalBusy::NotBusy.is_busy(), false);
2
    }
    #[test]
2
    fn test_terminal_busy_is_busy_1() {
2
        assert_eq!(TerminalBusy::Busy.is_busy(), true);
2
    }
    #[test]
2
    fn test_terminal_busy_from_u8_0() {
2
        assert_eq!(TerminalBusy::from(0u8), TerminalBusy::NotBusy);
2
    }
    #[test]
2
    fn test_terminal_busy_from_u8_1() {
2
        assert_eq!(TerminalBusy::from(1u8), TerminalBusy::Busy);
2
    }
    #[test]
2
    fn test_terminal_busy_from_u8_2() {
2
        assert_eq!(TerminalBusy::from(2u8), TerminalBusy::Busy);
2
    }
    #[test]
2
    fn test_terminal_busy_to_u8_0() {
2
        assert_eq!(u8::from(TerminalBusy::NotBusy), 0);
2
    }
    #[test]
2
    fn test_terminal_busy_to_u8_1() {
2
        assert_eq!(u8::from(TerminalBusy::Busy), 1);
2
    }
    #[test]
2
    fn test_terminal_busy_from_u16_0() {
2
        assert_eq!(TerminalBusy::from(0u16), TerminalBusy::NotBusy);
2
    }
    #[test]
2
    fn test_terminal_busy_from_u16_1() {
2
        assert_eq!(TerminalBusy::from(1u16), TerminalBusy::Busy);
2
    }
    #[test]
2
    fn test_terminal_busy_from_u16_2() {
2
        assert_eq!(TerminalBusy::from(2u16), TerminalBusy::Busy);
2
    }
    #[test]
2
    fn test_terminal_busy_to_u16_0() {
2
        assert_eq!(u16::from(TerminalBusy::NotBusy), 0);
2
    }
    #[test]
2
    fn test_terminal_busy_to_u16_1() {
2
        assert_eq!(u16::from(TerminalBusy::Busy), 1);
2
    }
    #[test]
2
    fn test_dynamic_bus_acceptance_clone() {
2
        let item1 = DynamicBusAcceptance::Accepted;
2
        let item2 = item1.clone();
2
        assert_eq!(item1, item2);
2
    }
    #[test]
2
    fn test_dynamic_bus_acceptance_is_notaccepted_0() {
2
        assert_eq!(DynamicBusAcceptance::NotAccepted.is_notaccepted(), true);
2
    }
    #[test]
2
    fn test_dynamic_bus_acceptance_is_notaccepted_1() {
2
        assert_eq!(DynamicBusAcceptance::Accepted.is_notaccepted(), false);
2
    }
    #[test]
2
    fn test_dynamic_bus_acceptance_is_accepted_0() {
2
        assert_eq!(DynamicBusAcceptance::NotAccepted.is_accepted(), false);
2
    }
    #[test]
2
    fn test_dynamic_bus_acceptance_is_accepted_1() {
2
        assert_eq!(DynamicBusAcceptance::Accepted.is_accepted(), true);
2
    }
    #[test]
2
    fn test_dynamic_bus_acceptance_from_u8_0() {
2
        assert_eq!(
2
            DynamicBusAcceptance::from(0u8),
2
            DynamicBusAcceptance::NotAccepted
2
        );
2
    }
    #[test]
2
    fn test_dynamic_bus_acceptance_from_u8_1() {
2
        assert_eq!(
2
            DynamicBusAcceptance::from(1u8),
2
            DynamicBusAcceptance::Accepted
2
        );
2
    }
    #[test]
2
    fn test_dynamic_bus_acceptance_from_u8_2() {
2
        assert_eq!(
2
            DynamicBusAcceptance::from(2u8),
2
            DynamicBusAcceptance::Accepted
2
        );
2
    }
    #[test]
2
    fn test_dynamic_bus_acceptance_to_u8_0() {
2
        assert_eq!(u8::from(DynamicBusAcceptance::NotAccepted), 0);
2
    }
    #[test]
2
    fn test_dynamic_bus_acceptance_to_u8_1() {
2
        assert_eq!(u8::from(DynamicBusAcceptance::Accepted), 1);
2
    }
    #[test]
2
    fn test_dynamic_bus_acceptance_from_u16_0() {
2
        assert_eq!(
2
            DynamicBusAcceptance::from(0u16),
2
            DynamicBusAcceptance::NotAccepted
2
        );
2
    }
    #[test]
2
    fn test_dynamic_bus_acceptance_from_u16_1() {
2
        assert_eq!(
2
            DynamicBusAcceptance::from(1u16),
2
            DynamicBusAcceptance::Accepted
2
        );
2
    }
    #[test]
2
    fn test_dynamic_bus_acceptance_from_u16_2() {
2
        assert_eq!(
2
            DynamicBusAcceptance::from(2u16),
2
            DynamicBusAcceptance::Accepted
2
        );
2
    }
    #[test]
2
    fn test_dynamic_bus_acceptance_to_u16_0() {
2
        assert_eq!(u16::from(DynamicBusAcceptance::NotAccepted), 0);
2
    }
    #[test]
2
    fn test_dynamic_bus_acceptance_to_u16_1() {
2
        assert_eq!(u16::from(DynamicBusAcceptance::Accepted), 1);
2
    }
}