hi i start work with c# three week ago i'm an electronic engineer and i want send some data from micro to pc i want work with c# for data monitoring how can we work with serial port in c#? thank you
I've written a few apps using the System.IO.Ports.SerialPort library. It's pretty straight forward. Simply create an instance of System.IO.Ports.SerialPort, example from MSDN: // Create a new SerialPort object with default settings. System.IO.Ports.SerialPort _serialPort = new SerialPort(); // Allow the user to set the appropriate properties. _serialPort.PortName = SetPortName(_serialPort.PortName); _serialPort.BaudRate = SetPortBaudRate(_serialPort.BaudRate); _serialPort.Parity = SetPortParity(_serialPort.Parity); _serialPort.DataBits = SetPortDataBits(_serialPort.DataBits); _serialPort.StopBits = SetPortStopBits(_serialPort.StopBits); _serialPort.Handshake = SetPortHandshake(_serialPort.Handshake); // Set the read/write timeouts _serialPort.ReadTimeout = 500; _serialPort.WriteTimeout = 500; _serialPort.Open(); when you want to write something to the port _serialPort.Write(.....); there's a few different ways to write, you can write a string, or a byte array. when your done with the port, _serialPort.Close();