A device register uses the codes 1, 2 and 4 for three operating modes, so I declared type Mode is (Idle, Run, Fault); with for Mode use (Idle => 1, Run => 2, Fault => 4);. When I send Mode'Pos (Fault) to the device I get 2, not 4.
How do I obtain the actual code for a value, and how do I safely convert a byte received from the device back into a Mode when the byte might be something invalid such as 3?




