So what is the output from your program, "Writed text file" ?
So what is the output from your program, "Writed text file" ?
Sorry there is an error:
Qt Code:
if (r == quint64(data.size())) qDebug() << "Writed binary file.";To copy to clipboard, switch view to plain text mode
this means:
"r" is the number of sent bytes
if r is equal to the file size the program prints "Writed binary file."
The error is: the program sends all the bytes but if there is a XOFF the device doesn't read all the bytes.
Now I've to find this XOFF answer, wait the XON signal and restart to write.
I thought the QSerialDevice manage this XON/XOFF but I don't know if it works.
2 ilpaso,
1.
try in the file nativeserialengine_win.cpp in the method:
"bool NativeSerialEnginePrivate:: nativeSetFlowControl (AbstractSerial:: Flow flow)" in the selection
of "case AbstractSerial:: FlowControlXonXoff:" add the following code (example):
Try to change or XonLim XoffLim (see MSDN for these parameters).Qt Code:
... this->dcb.XonChar = 0x11; this->dcb.XoffChar = 0x13; this->dcb.XonLim = 128; this->dcb.XoffLim = 128; ...To copy to clipboard, switch view to plain text mode
But I'm not sure that this will help. I have not tested mode Xon / Xoff.
2.
Try to open a port in Unbuffered! Maybe this will help.
3. Install it on your computer program such as: port sniffer, such as Free Serial Port Monitor.
This will help to analyze the traffic.
And look what happens, because I do not have your printer and I can not help you. Define the problem, and I'll try to fix it.
4. Another idea: in some way (I do not know how) the software simulated your printer. Ie so that this "virtual" printer with a buffer overflow, reported the suspension of transmission.
Thank you kuzulis for your help. You are the QSerialDevice developer and you know your class.
I'm working on a linux distro and I think the file to read is nativenerialnngine_unix
Ok. This is an important info to know! I'll try your code but an easy solution could be to implement the XON/XOFF manually.
Thankyou very much. I'll install a port sniffer.
Regards
ilpaso
Yes.I'm working on a linux distro and I think the file to read is nativenerialnngine_unix
Then look at the documentation: Serial Programming Guide for POSIX Operating Systems
There is information on xon/xoff.
Look also to parameters: termios.c_cc, maybe you want to add (define) in nativenerialnngine_unix.cpp options: VSTART, VSTOP (ie, check them out and maybe give them a value of 0x31, 011).
I do not know sniffers for Linux. Try using strace. But I'm not sure.Thankyou very much. I'll install a port sniffer.
Hi,
Just to make sure I understand you right : you do get the message "Writed binary file.", right ? This may be significant because QSerialDevice doesn't send all data at once, but in chuncks of 512 or so bytes. It might be that the serial port driver returns false on a write() when an XOff has been received. Unlikely though.if r is equal to the file size the program prints "Writed binary file."
The error is: the program sends all the bytes but if there is a XOFF the device doesn't read all the bytes.
The operating system should take care of this. QSerialDevice doesn't need to do this.I thought the QSerialDevice manage this XON/XOFF but I don't know if it works.
It is very easy to implement the Xon/Xoff handshaking yourself :
Qt Code:
// until all data sent : // send a chunck of data // if something is received from the printer : // if Xoff was received : // wait until Xon receivedTo copy to clipboard, switch view to plain text mode
Best regards,
Marc
What is likely is that if you are sending data that is larger than the serial port buffers. What does QSerialDevice typically set the serial buffers to?
Also, try sending in smaller chunks, say 128 bytes or even 64 or 32 bytes (you can always increase the number if it starts to work) and possibly put in a small delay between each chunk, say 100ms or so.
Yes, you can try to reduce the size of the pieces, as The default library sends data chunks of 512 bytes:Also, try sending in smaller chunks, say 128 bytes or even 64 or 32 bytes (you can always increase the number if it starts to work) and possibly put in a small delay between each chunk, say 100ms or so.
Qt Code:
#define WRITE_CHUNKSIZE Q_INT64_C(512)To copy to clipboard, switch view to plain text mode
ilpaso (9th December 2010)
Hi all,
I implemented myself the flow control and the transfer works with a buffer size of 256bytes and 512bytes.
I tried to change the "WRITE_CHUNKSIZE" variable to 256bytes and send datas without my flow control. The transfer doesn't work.
Great.
Maybe kuzulis could integrate it in QSerialDevice. Xon/Xoff handshaking in software instead of in the driver of the OS.
Regards,
Marc
Bookmarks