How to Communicate with SerialPort Use C# Programming?
-
Can C# Control Serial Port? Which class in .NET Framework is for SerialPort Communicate Programming? thanks a lot.
For low level communication you can write to the virtual file "COM1".
-
For low level communication you can write to the virtual file "COM1".
-
Dear Corinna John Can you explain for detail how to write to the virtual file "COM1" in c#? Thanks a lot!
Usually you open a file with the name of the serial port (COM[x]). The file doesn't exist in the file system. Whatever you write to the "file" will be sent to the serial port, messages from the device can be read from that virtual file.
//open serial port COM1 FileStream fs = new FileStream("COM1", FileMode.OpenOrCreate); //sending data to the port it like writing them to a file fs.Write(...); fs.Flush();
It worked with other languages, I think it should also work with .NET -
Usually you open a file with the name of the serial port (COM[x]). The file doesn't exist in the file system. Whatever you write to the "file" will be sent to the serial port, messages from the device can be read from that virtual file.
//open serial port COM1 FileStream fs = new FileStream("COM1", FileMode.OpenOrCreate); //sending data to the port it like writing them to a file fs.Write(...); fs.Flush();
It worked with other languages, I think it should also work with .NET -
As far as I know, you can do that with every port.