Skip to content

Instantly share code, notes, and snippets.

@tuxmartin
Last active July 12, 2017 11:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tuxmartin/2e065e09592729372e1cd19faa258888 to your computer and use it in GitHub Desktop.
Save tuxmartin/2e065e09592729372e1cd19faa258888 to your computer and use it in GitHub Desktop.
C# - cteni stavu DSR na seriovem portu
// zdroj: http://xanthium.in/Serial-Programming-using-Csharp-on-Windows
using System;
using System.IO.Ports;
namespace SerialPort_Tutorial
{
class SerialPort_Write
{
static void Main(string[] args)
{
SerialPort MyCOMPort = new SerialPort(); // Create a new SerialPort Object
MyCOMPort.PortName = "COM46"; // Assign the name of the serial port to be opened
MyCOMPort.Open(); // Open the port
MyCOMPort.RtsEnable = true; // RTS pin = 1 ,~RTS = 0
Console.Read(); // Press any key
MyCOMPort.RtsEnable = false; // RTS pin = 0 ,~RTS = 1
Console.Read();
MyCOMPort.DtrEnable = true; // DTR pin = 1, ~DTR = 0
Console.Read();
MyCOMPort.DtrEnable = false; // DTR pin = 0, ~DTR = 1
Console.Read();
MyCOMPort.Close(); // Close port
}//end of Main
}//end of class
}//end of namespace
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment