Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
I am using serialport on my target board(TI AM335x series), everything looked fine, it could open comport, receive data... etc. But... i found if i read more data later, the serialport will give me a "QSerialPort::ReadError" information and then my program(GUI) on target board haven't received any data. Does anyone know why??
BTW, if i reconnected the comport, it became to work, but same problem would exist again.
The problem is not immediately obvious to me, but are you reading fast enough? If not, you will get a buffer overflow.
it was really not fast, this situation also happen on the example that Qt website provided. I found a thing is interesting. If i used "minicom" to execute program then everything is ok, but used other tool like "telnet", my program would failed , the fail means like above description. Does anyone know how to resolve this problem?? I think maybe "minicom" initialize the serial port so that my program later would work.
Then you should first check the parameters used by minicom to setup the serial port. Are you using exactly the same with your program ?
Does the device connected to the serial port need an initialization ?
The difference between minicom and my program are only in Baudrate which in minicom is 115200 and my program is 38400. I didn't know whether device need a initialization, i just guess. Because if my program was executed from minicom and everything is OK. I guess minicom did something i missed, but i still couldn't find any clues.
[quote author="Ivan1120" date="1409794053"]The difference between minicom and my program are only in Baudrate which in minicom is 115200 and my program is 38400.[/quote]The sender and receiver must both be configured to use the same baud rate.
There are other parameters too. Check that you are using the same parameters on both the sender and the receiver:
- Baud rate
- Data bits
- Stop bits
- Flow control
- Termination enabled?
- Termination character (if enabled)
Yes, I know that, they are the same. When I sent more data, my program would have a error message like "Resource temporarily unavailable", if i didn't execute my program through "minicom".
What version of Qt are you using? Does this still happen with Qt 5.3.1?
It might be related to "this bug":https://codereview.qt-project.org/#/c/85414/ which doesn't look like it has been fixed yet... :(
But in case it's not a Qt bug, could you show us your serial port code?
u can refer to example named "Terminal". So.....if this is a bug, it means i can't execute my program from touchscreen and should be executed from minicom?? I don't understand the bug of blog u mentioned....
What version of Qt are you using?
Can you describe what you mean by "execute my program"? How do you use a touchscreen and minicom to "execute" the program?
When you said "Terminal" example, do you mean "this one":http://qt-project.org/doc/qt-5/qtserialport-terminal-example.html?
1.I'm using Qt 4.8.4, but i take the QSerialport project from Qt5.3.1. It could pass compilation and it also work well on my host computer.
2."execute my program" means run it. for example if i want to run my program from "minicom", i should give a command like "./terminal" and if it's from touch screen, i just press the icon and my program will start to run, just like u play ur app on ur smartphone.
[quote author="Ivan1120" date="1409812270"]I don't understand the bug of blog u mentioned....[/quote]There is a bug in QSerialPort. Sometimes, when reading data, QSerialPort returns a "Resource temporarily unavailable" error, even if the resource is available.
I still don't fully understand how you have set up your system: Did you use minicom to run your Qt program? Or did you use minicom to read data from your serial port?
Hi, I used minicom to run my Qt program but I also could run my Qt program from the touch screen, because it using matrix syntax that could show my program on the GUI. In my experiment, there were two different results if I used forementioned two methods to run my Qt program. For using minicom to run my Qt program, there are no error and warning on my Qt Program which would used QSerialPort, but for the others, whatever methods(telnet, touchscreen.. etc) I used to run my Qt program, it always would get the error message like "Resource temporarily unavailable". If this was a bug ,why the official have not fixed it, I thought this is a big problem.
Ok, here is what I understand so far:
Your Target has a Touchscreen.
Your PC is connected to your Target using serial ports.
You use your PC to control your Target in the following different ways:
You open minicom on your PC, and use minicom to connect to your Target.
You open telnet on your PC, and use telnet to connect to your Target.
You built the Qt Terminal Example Program to run on your Target.
You tried to launch your Program in the following different ways:
You type a command into minicom (see #3.1) to launch the Program. Using this method, your Program produces no errors.
You type a command into telnet (see #3.2) to launch the Program. Using this method, your Program produces "Resource temporarily unavailable" errors.
You tap an icon on the Touchscreen to launch the Program. Using this method, your Program produces "Resource temporarily unavailable" errors.
Is this correct? If so, please tell us:
- Which Target serial port does your PC connect to for #3.1?
- Which Target serial port does your PC connect to for #3.2?
- Which Target serial port does your Program open?
- How do you see the error messages for #5.1?
- How do you see the error messages for #5.2?
- How do you see the error messages for #5.3?
- At first, you said you ran the "Terminal" example, then you said you ran a matrix GUI. Do you run both programs at the same time?
[quote author="Ivan1120" date="1410743901"]If this was a bug ,why the official have not fixed it, I thought this is a big problem. [/quote]Note that I said you might be seeing this bug. It could be the same issue, or it could be something different. The bug I mentioned is rare. It doesn't affect most people.
bq. Which Target serial port does your PC connect to for #3.1?
I do not really sure what you asked.., I open the port on the target named "ttyUSB1".
bq. Which Target serial port does your PC connect to for #3.2?
Use telnet only require ip address, in this test, i used 172.22.100.xx to connect the target board.
bq. Which Target serial port does your Program open?
bq. How do you see the error messages for #5.1?
How do you see the error messages for #5.2?
How do you see the error messages for #5.3?
Use the API QserialPort provide.
bq. At first, you said you ran the “Terminal” example, then you said you ran a matrix GUI. Do you run both programs at the same time?
Matrix GUI start to run when the board boot up and I have wrote some code that make "Terminal" can be showed on the screen through matrix syntax.