Implementation of the coin acceptor

Here the PC plays the role of a coin acceptor, connected to a vending machine controller (VMC).

As the VMC expects data as response to a STATUS, TUBE STATUS e.t.c.

we implemented a special mechanism to communicate with the VMC.

If a command is received from the VMC where the VMC expects immediate data in response,

the interface will not response to the VMC, this is forcing a NAK and the VMC is expected to

resend the command at later time.

But the MDB/USB interface will pass the command to the PC application, so the expected data can

prepared and send to the MDB/USB interface.

On the next command of the VMC, the data is send as response, if available.

If the requested data is not yet available on the next command, the MDB/USB interface will not

respond again, forcing a second NAK, but the command is not send to the PC application,

because the last request is still pending.

Commands with this behavior:

- STATUS

- TUBE STATUS

- EXPANSION sub command 0, 3, 4, 5

Commands with automated ACK:

- RESET

- POLL

- COIN TYPE

- DISPENSE

- EXPANSION sub command 1,2