/// <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)))); }
/// <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)))); }
/// <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))); }