Beispiel #1
0
        /// <summary>
        /// Reads a specified number of characters asynchronous.
        /// </summary>
        /// <param name="length">The number of characters to be read (default is 1)</param>
        /// <returns>An awaitable <see cref="Task{String}"/> returning the string read</returns>
        public static async Task <string> ReadAsync(this ArduinoSession session, int length = 1)
        {
            if (length < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(length), Messages.ArgumentEx_PositiveValue);
            }

            return(await Task.Run(() => session.messageHeader.GetStringFromQueue(StringRequest.CreateReadRequest(length))));
        }
Beispiel #2
0
 /// <summary>
 /// Reads a string asynchronous up to the first terminating character.
 /// </summary>
 /// <param name="terminator">The character identifying the end of the string</param>
 /// <returns>An awaitable <see cref="Task{String}"/> returning the string read</returns>
 public static async Task <string> ReadToAsync(this ArduinoSession session, char terminator)
 {
     return(await Task.Run(() => session.messageHeader.GetStringFromQueue(StringRequest.CreateReadRequest(terminator))));
 }
Beispiel #3
0
 /// <summary>
 /// Reads a string up to the first terminating character.
 /// </summary>
 /// <param name="terminator">The character identifying the end of the string</param>
 /// <returns>The string read</returns>
 public static string ReadTo(this ArduinoSession session, char terminator)
 {
     return(session.messageHeader.GetStringFromQueue(StringRequest.CreateReadRequest(terminator)));
 }