public void HandleByte(byte[] aByte) { if (iCurrentCommand == null) { // Don't know where this is intended for return; } iCurrentCommand.HandleReceived(aByte); while ((iCurrentCommand != null) && iCurrentCommand.Done) { if (iCommandQueue.Count != 0) { iCurrentCommand = iCommandQueue.Dequeue(); iCurrentCommand.SendCommand(this); if (iCurrentCommand.RequiredReturnBytes != 0) { iForm.backgroundSerial.RunWorkerAsync(iCurrentCommand.RequiredReturnBytes); } else { iCurrentCommand = null; } } else { iCurrentCommand = null; } } }
/** * @brief * Add a Boxdorfer command * * @param aCommand * The command to add * * This executes the command if the serial port is not in use or queues it * to be executed when the port is free. */ public void AddCommand(IBoxdorferCommand aCommand) { if (iCurrentCommand != null) { iCommandQueue.Enqueue(aCommand); return; } iCurrentCommand = aCommand; iCurrentCommand.SendCommand(this); if (iCurrentCommand.RequiredReturnBytes != 0) { iForm.backgroundSerial.RunWorkerAsync(iCurrentCommand.RequiredReturnBytes); } else { iCurrentCommand = null; } }
public void Flush() { iCommandQueue.Clear(); iCurrentCommand = null; }