示例#1
0
 /// <summary>
 /// Send commands stored in a file. Wait until the commands are transferrd and we got a reply (no command pending)
 /// </summary>
 /// <param name="filename">used for a StreamReader</param>
 public static async Task <IEnumerable <SerialCommand> > QueueFileAsync(this ISerial serial, string filename)
 {
     using (var sr = new StreamReader(filename))
     {
         string line;
         var    lines = new List <string>();
         while ((line = sr.ReadLine()) != null)
         {
             lines.Add(line);
         }
         return(await serial.QueueCommandsAsync(lines.ToArray()));
     }
 }
 /// <summary>
 /// Queue command - do not wait - not for transfer and not for replay
 /// </summary>
 /// <param name="serial"></param>
 /// <param name="line">command line to send</param>
 public static IEnumerable <SerialCommand> QueueCommand(this ISerial serial, string line)
 {
     return(serial.QueueCommandsAsync(new[] { line }).ConfigureAwait(false).GetAwaiter().GetResult());
 }