Unsolved Subclassing QIODevice
-
Hi,
Since you are mentioning modbus on the bug report, then maybe the Qt SerialBus module will be a better choice.
-
@SGaist hi, Qt SerialBus is possible way but we have our own modbus implementation based on QSerialPort... And one some serious thing with QtSerialBus that it has problems with catching parity errors
P.S. I have 2 acc(Moonraiser)
-
@Christian-Ehrlicher https://github.com/Jihadist/libserial-wrapper/blob/e7774ba9f01bbd6487d2e4639c1e5240ee0fc930/main.cpp#L34 here is error App crashes when i try to call read or write
-
int error_code = port1.open(QIODevice::ReadWrite); if (error_code) qDebug("Port opened");
This is wrong - if you can't open the port you should not work on it.
-
@Christian-Ehrlicher Look at implementation please, open returns true if opened or false if not
-
@PaulNewman But you still go on when it failed.
-
@MoonRaiser
you open the serial port before you try to change the settings, you should actually get console warnings about that.
Set settings first than open the port -
@J-Hilk Do you see i use another backend which works another than QSerialPort and requires to set settings after openning port?
-
@PaulNewman I did in fact not see that 🤷♂️
-
@Christian-Ehrlicher i dont, look at check() func
-
@PaulNewman said in Subclassing QIODevice:
i dont, look at check() func
You do...
int error_code = port1.open(QIODevice::ReadWrite); if (error_code) qDebug("Port opened"); if (port1.setBaudRate(9600)) <<-- here you try access even if open failed
and btw: open() returns a boolean, not an integer
-
@Christian-Ehrlicher you are right here, but check() calls abort() if not true, so it never returns if port cannot be opened. It's only test case but it doesnt work when port was opened
-
@Christian-Ehrlicher said in Subclassing QIODevice:
if (port1.setBaudRate(9600)) <<-- here you try access even if open failed
I fixed this, but problem stays...
Source code from topic header was updated to.
Why did it call QIODevice::isSequential but not my own implementation?