namespace Unosquare.WiringPi.Native { using System.Runtime.InteropServices; public partial class WiringPi { /// /// This opens and initialises the serial device and sets the baud rate. It sets the port into “raw” mode (character at a time and no translations), /// and sets the read timeout to 10 seconds. The return value is the file descriptor or -1 for any error, in which case errno will be set as appropriate. /// The wiringSerial library is intended to provide simplified control – suitable for most applications, however if you need advanced control /// – e.g. parity control, modem control lines (via a USB adapter, there are none on the Pi’s on-board UART!) and so on, /// then you need to do some of this the old fashioned way. /// /// The device. /// The baud. /// The result. [DllImport(WiringPiLibrary, EntryPoint = "serialOpen", SetLastError = true)] public static extern int SerialOpen(string device, int baud); /// /// Closes the device identified by the file descriptor given. /// /// The fd. /// The result. [DllImport(WiringPiLibrary, EntryPoint = "serialClose", SetLastError = true)] public static extern int SerialClose(int fd); /// /// Sends the single byte to the serial device identified by the given file descriptor. /// /// The fd. /// The c. [DllImport(WiringPiLibrary, EntryPoint = "serialPutchar", SetLastError = true)] public static extern void SerialPutchar(int fd, byte c); /// /// Sends the nul-terminated string to the serial device identified by the given file descriptor. /// /// The fd. /// The s. [DllImport(WiringPiLibrary, EntryPoint = "serialPuts", SetLastError = true)] public static extern void SerialPuts(int fd, string s); /// /// Returns the number of characters available for reading, or -1 for any error condition, /// in which case errno will be set appropriately. /// /// The fd. /// The result. [DllImport(WiringPiLibrary, EntryPoint = "serialDataAvail", SetLastError = true)] public static extern int SerialDataAvail(int fd); /// /// Returns the next character available on the serial device. /// This call will block for up to 10 seconds if no data is available (when it will return -1). /// /// The fd. /// The result. [DllImport(WiringPiLibrary, EntryPoint = "serialGetchar", SetLastError = true)] public static extern int SerialGetchar(int fd); /// /// This discards all data received, or waiting to be send down the given device. /// /// The fd. [DllImport(WiringPiLibrary, EntryPoint = "serialFlush", SetLastError = true)] public static extern void SerialFlush(int fd); } }