private string GetCommand(CommandsToMTR.CommandName command, byte[] binary = null) { if (command == CommandsToMTR.CommandName.SpoolBinary || command == CommandsToMTR.CommandName.GetMessageBinary || command == CommandsToMTR.CommandName.SetClock && binary == null) { throw new Exception("Binary content missing."); } switch (command) { case CommandsToMTR.CommandName.Status: return("/ST"); case CommandsToMTR.CommandName.Spool: return("/SA"); case CommandsToMTR.CommandName.SpoolBinary: return("/SB" + binary); case CommandsToMTR.CommandName.NewSession: return("/NS"); case CommandsToMTR.CommandName.GetMessageBinary: return("/GB" + binary); case CommandsToMTR.CommandName.SetClock: return("/SC" + binary); case CommandsToMTR.CommandName.ClearRingbuffer: return("/CL"); default: return(string.Empty); } }
/// <summary> /// Send command to the MTR /// </summary> /// <param name="command">Command to send</param> /// <param name="binary">Some commands needs extra binarydata. If it is needed and no binary data given an exception will throw</param> public void AskFromMTR(CommandsToMTR.CommandName command, byte[] binary = null) { var cmd = GetCommand(command, binary); SendData(cmd); }