
First project is the class which I posted as a question yesterday. Let me tell you more detail so that you could give me suggestion for better way. It is miracle to me which I have no idea how this happen. I am not sure that I face good luck or bad luck because this new class could make fire DataReceived event which is from older console application that is still running.
ObjCom.Write(Char.ConvertFromUtf32(STX) + strText + Char.ConvertFromUtf32(ETX)) Private bool SendToPort(System.IO.Ports.SerialPort objCom, string strText) Private bool SerialPortOpen(System.IO.Ports.SerialPort objCom, string portName)
So, I created new project by hoping that I will face a way to solve.Īt that new project, I created a class. Unfortunately, I still could not make to fire DataReceived event in any way.
I get output result from mystring array (COM1, COM2, COM3, COM4)īut I still don't know why DataReceived event is not fired. My computer has COM1 and COM2 ports already. My problem is DataReceived event never gets fired. Public static void OpenPort(SerialPort ComPort) Private static void InitializeComPort(string port, int baud)ĬomPort.Handshake = System.IO. ĬomPort.DataReceived += OnSerialDataReceived String mystring = System.IO.() ĬomPort.Write(Char.ConvertFromUtf32(STX) + text + Char.ConvertFromUtf32(ETX)) Public static void OnSerialDataReceived(object sender, SerialDataReceivedEventArgs args) #Serial port datareceived not firing code
NET SerialPort DataReceived event not firing, I make my code like that. I am developing program which need to interact with COM ports.īy learning from this Q&A.