I am trying to send some data to a LED display that works over serial port. This code does the job over VB6 but i needed to convert it to C#. Sadly it does not work. Any ideas?
VB6 (Example)
MSComm1.CommPort = 1
MSComm1.Settings = "9600,N,8,1"
MSComm1.PortOpen = True
MSComm1.Output = Chr(170)
MSComm1.Output = Chr(2)
C# (Example)
var serialPort1 = new SerialPort("COM1", 9600, Parity.None, 8, StopBits.One);
serialPort1.Open();
serialPort1.Write(((char)170).ToString());
serialPort1.Write(((char)2).ToString());
serialPort1.Close();
I think the problem is about serialPort1.Write function but i could not figure it out. Can you help please?
Also figured out how to do it with serialPort class. The important deal is using designer to add serialPort1 definition instead of manual definition with “var serialPort1 = new SerialPort(“COM1″, 9600, Parity.None, 8, StopBits.One);”. My problem occured because of missing definitions i guess. Here is the sample :