1. I do not know what is written in an assistant to do so:What is the size reported by QIODevice::bytesAvailable() and what is the size reported by "bytesQueued"?
[code]
qint64 CustomDevice:: bytesAvailable () const
(
return buffer.size () + QIODevice:: bytesAvailable ();
)
[/ code]
?????
2. I'm reading 10 bytes from the port situation is this:
- Run a test program: examples / release / reader
- Opens a port / dev/ttyS0
- Configure read 10 bytes
- Do waitForReadyRead (5000) / / 5 seconds
- Wait for data to / dev/ttyS0
- Run a test program: examples / release / writer
- Opens a port / dev/ttyUSB0
- Configure write 10 bytes
- Press Enter (while in port / dev/ttyUSB0 recorded 10 bytes)
- At this point in the examples / release / reader - triggered function waitForReadyRead (5000) = true,
which indicates that the / dev/ttyS0 come at least 1 byte
- Then I give the read (10); / /
- Inside the function read (10) is bytesAvailable () and this function returns the number of bytes = 16392
where: QIODevice:: bytesAvailable () = 16384, bytesQueued = 8
- And further back is triggered waitForReadyRead (50) / / inside function read () waiting for the next character
- Inside the function read (10) is bytesAvailable () and this function returns the number of bytes = 16386
where: QIODevice:: bytesAvailable () = 16384, bytesQueued = 2
ie really comes into / dev/ttyS0 10 bytes = 8 + 2
but where the number 16384 is taken - I do not know! o_O
Here is an example of the withdrawal of the test:
[quote]
[root @ myhost reader] # release / reader
Please Enter Device name, specific by OS: / dev/ttyS0
= Defaults parameters =
Device name: / dev/ttyS0
Baud rate: 12
Data bits: 3
Parity: 0
Stop bits: 0
Flow: 0
Char timeout, msec: 50
Trying to open File
Opened File succesfully
Serial device / dev/ttyS0 open in Read Only mode
Please Enter wait timeout for ready read, msec: 5000
Please Enter len data for read, bytes: 10
Starting waiting ready read in time: 18:38:18
bytesQueued = 8
bav = 16392 <======== 16392-8 = 16384 bytes o_O!
bytesRead = 8
TPosixSerialDevice:: readData-> (bytesRead! = Bav) with OK! Error!
bytesQueued = 0
bav = 0
TPosixSerialDevice:: readData-> (bav <= 0)! Error!
Readed is: 0 bytes
Rx:
bytesQueued = 2
bav = 16386 <======== 16386-2 = 16384 tytes o_O!
bytesRead = 2
TPosixSerialDevice:: readData-> (bytesRead! = Bav) with OK! Error!
bytesQueued = 0
bav = 0
TPosixSerialDevice:: readData-> (bav <= 0)! Error!
Readed is: 0 bytes
Rx:
^ C
[root @ myhost reader] #
[/ quote]
Bookmarks