Hi I want to send some command to my device which is connected via serial port. How to send it?
For example i found this on google search but for me it\'s useless.>
To send the enter key, you would have to use SerialPort.NewLine Property - A value that represents the end of a line
_serialPort = new SerialPort();
// ... this COM port parameters
_serialPort.NewLine = "\r"; // "\r" - CR (0x0D); "\r\n" - CRLF (0x0D 0x0A)
try
{
_serialPort.Open();
}
catch (Exception ex)
{
Console.Write(ex.Message);
return;
}
_serialPort.WriteLine("Send string"); // Writes `Send string` string and the `NewLine` value to serial port
// or
_serialPort.WriteLine((char)2 + "VWD:040" + (char)3); // Writes `VWD:040` string and the `NewLine` value to serial port
For a full example of working with serial port, see here.