Last active
July 12, 2017 11:22
C# - cteni stavu DSR na seriovem portu
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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