serialport-lib-dotnet
serialport-lib-dotnet copied to clipboard
Setting a new baudrate with SetPort(...) doesn't work
Hi All,
I tried to set a new baudrate with SetPort() methode, but it doesn't work. Indeed, SetPort() test if a change occured for portName only, but not the other parameters. I suggest the following changes
public void SetPort(string portName, int baudRate = 115200, StopBits stopBits = StopBits.One, Parity parity = Parity.None, DataBits dataBits = DataBits.Eight)
{
if (_portName != portName || _baudRate != baudRate || stopBits != _stopBits || parity != _parity || dataBits != _dataBits)
{
// set to error so that the connection watcher will reconnect
// using the new port
gotReadWriteError = true;
logger.Trace("Port parameter changed (port name / baudrate / stopbits / parity / databits) = " + portName + " / " + baudRate + " / " + stopBits + " / " + parity + " / " + dataBits);
}
_portName = portName;
_baudRate = baudRate;
_stopBits = stopBits;
_parity = parity;
_dataBits = dataBits;
}
Hi, Is this repository still alive ?
Hi @gitjsdr26, make a pull request with this fix and I will merge it and publish a new release. Also make sure that the code does not break backward compatibility because I have no time to test it in this very moment.
@genemars , ok I'll do it. I've been testing these changes for 2 monthes on my application and it works well. Thank you Regards
can you already make a pull-request for this?
Yes, within 6 hours.
It was done in #21