genielabs / serialport-lib-dotnet

Serial Port libray for .Net / Mono
https://www.nuget.org/packages/SerialPortLib/
Apache License 2.0
157 stars 65 forks source link

Arduino Mega 2560 Response Problem #4

Open ghost opened 8 years ago

ghost commented 8 years ago

Sorry for my English.

i'm using SerialPortLib for communicating with Arduino Mega 2560. My code written like in Example usage manual section. Sending data to serial is correct, but the event MessageReceived does not raise.

is any suggestions about my problem? Thank you.

var serialPort = new SerialPortInput();
serialPort.ConnectionStatusChanged += SerialPort_ConnectionStatusChanged;
serialPort.MessageReceived += SerialPort_MessageReceived;
serialPort.SetPort("COM3", 250000);
serialPort.Connect();

foreach (var workContext in WorkContexts.Where(c=>c != null)) {
    var cmd = workContext.CommandFrame;
    var message = Encoding.UTF8.GetBytes(cmd);
    serialPort.SendMessage(message);
    Console.WriteLine($">> {cmd}"); 
}

...
VladimirAkopyan commented 7 years ago

I don't know much about the library, but your baud rate is 250,000. ATmega doesn't support speeds above 115,200.