Issue reading from QSerialPort
-
@Anna_64
Well I don't have your device so I do not know whether it can send, whether it is sending, whether you are receiving, whether your code is correct, or what. Nor do I know what your code where you callserial->readAll();
looks like (where it is being called from etc.) So far you have only shown code which sends.If the code is just as you show, after your
ba=serial->readAll();
what about at leastqDebug() << ba.size()
so we can at least see how many bytes were received? And if that turns out to be 0, don't forget:This function has no way of reporting errors; returning an empty QByteArray can mean either that no data was currently available for reading, or that an error occurred.
You might find that https://doc.qt.io/qt-5/qiodevice.html#read or https://doc.qt.io/qt-5/qiodevice.html#errorString would then tell you if there was an error.
-
@JonB i can read also
its like "\xAAU\t\x00\x00 \x00\x02\x00\x00\x03!"
and lenght s 12
now i have to take only 10th one that is 03 how to do that -
@JonB its showing 12bytes
-
Hi,
I have forked your question into its own topic thread.
Why are you creating a new QSerialPort object each time you call
on_COM9_clicked
?Do you have a protocol to communicate with your device ? e.g. a start and stop sequence so you can separate frames you send and receive ?
If you have one, then you can parse the received data once you know you have enough bytes to contain at least one frame.
-
@Anna_64 said in Issue reading from QSerialPort:
now i have to take only 10th one that is 03 how to do that
It seems a surprising question to ask, but if that's really what you want to know it would be
ba[9]
.You should also always read, understand & act on what @SGaist asks/suggests.
-
@JonB how to split a bin file of size 1050 bytes into 64 chunks in qt
-
@SGaist i want to split a file which looks like
QFile file("C:\Users\Desktop\binfile_enc.bin");
this file is of size 1050.624 bytes
i want to split into 64 chunks please help -
-
@JonB its a stupid answer
-
@JonB its a stupid answer
Thank you so much. It's an exact answer to the question as posed by you. And follows on from the time I spent trying to answer your earlier questions. I haven't insulted you so far in your questions, thanks for insulting me. You are rude. I'm done with you, find out how people will respond to you, given that this support forum provides voluntary help....