skullandbones / uTmax

uTmax Linux GUI program for the uTracer3 Thermionic Valve Tester
4 stars 3 forks source link

Implement new serial protocol state machine #33

Closed skullandbones closed 6 years ago

skullandbones commented 6 years ago

Add SendCommand() to implement a state machine to handle the Data Protocol of the uTracer.

The state machine manages the following:

1. Manages TX and RX states transitions.

2. Transmits single characters of the command message and checks that
   the character is echoed. Therefore, a communications failure can
   be detected such as the uTracer not being present.

3. Handles switches between sending a command message and, if expected,
   receiving a message. This is half-duplex; a command and response
   cannot occur at the same time.

4. Uses a structure to hold the messages and states. This allows for
   potential flexibility such as dynamic allocation of the structures.

This solution is an improvement on the original design because this
design is more concise. Also, the design follows the design of the protocol
more closely such as enforcing half-duplex transmission / reception.

Abstract the uTracer protocol messages into specific functions which create the command messages and read the resulting response (if any). This simplifies the main state machine by moving that code into specific functions.

Note that CommandResponse_t CmdRsp was made temporarily global during the integration of the changes but is now private.

Modify RxPkt() to use the output from the new state machine. However, retain the original protocol timeout mechanism.

Remove the following variables which are now redundant: cmd RxString rxlen timer_on