Tengo un problema al querer leer un puerto serial desde c# (Bascula)
el metodo "DataReceivedHandler" nunca es lanzado
private static SerialPort puertoSerial;
public static void InitSerialInterface(string puerto, int baudios)
{
mySerialPort.PortName = "COM1";
mySerialPort.BaudRate = 9600;
mySerialPort.Parity = Parity.Even;
mySerialPort.StopBits = StopBits.One;
mySerialPort.DataBits = 7;
mySerialPort.Handshake = Handshake.None;
mySerialPort.DtrEnable = true;
mySerialPort.RtsEnable = true;
mySerialPort.DataReceived += new SerialDataReceivedEventHandler(mySerialPort_DataReceived);
mySerialPort.Open();
}
//Este metodo nunca es lanzado :(
private static void DataReceivedHandler(object sender,SerialDataReceivedEventArgs e)
{
SerialPort sp = (SerialPort)sender;
string indata = sp.ReadExisting();
Console.WriteLine("Data Received:");
Console.Write(indata);
}