You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
1.7 KiB

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. namespace ModbusDemo.Device
  7. {
  8. public interface IStreamResource : IDisposable
  9. {
  10. int InfiniteTimeout { get; }
  11. /// <summary>
  12. /// Gets or sets the number of milliseconds before a timeout occurs when a read operation does not finish.
  13. /// </summary>
  14. int ReadTimeout { get; set; }
  15. /// <summary>
  16. /// Gets or sets the number of milliseconds before a timeout occurs when a write operation does not finish.
  17. /// </summary>
  18. int WriteTimeout { get; set; }
  19. /// <summary>
  20. /// Purges the receive buffer.
  21. /// </summary>
  22. void DiscardInBuffer();
  23. /// <summary>
  24. /// Reads a number of bytes from the input buffer and writes those bytes into a byte array at the specified offset.
  25. /// </summary>
  26. /// <param name="buffer">The byte array to write the input to.</param>
  27. /// <param name="offset">The offset in the buffer array to begin writing.</param>
  28. /// <param name="count">The number of bytes to read.</param>
  29. /// <returns>The number of bytes read.</returns>
  30. int Read(byte[] buffer, int offset, int count);
  31. /// <summary>
  32. /// Writes a specified number of bytes to the port from an output buffer, starting at the specified offset.
  33. /// </summary>
  34. /// <param name="buffer">The byte array that contains the data to write to the port.</param>
  35. /// <param name="offset">The offset in the buffer array to begin writing.</param>
  36. /// <param name="count">The number of bytes to write.</param>
  37. void Write(byte[] buffer, int offset, int count);
  38. }
  39. }