Unsolved Subclassing QIODevice
-
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?