Unsolved How to write code that enters lines in the Command Arguments Section
-
well if if app sees that it got no parameter it could open the text file if u place it next to exe
yes it very possible.
You can use QFileQFile file("comm.txt"); if(!file.open(QIODevice::ReadOnly)) { QMessageBox::information(0, "error", file.errorString()); } QTextStream in(&file); while(!in.atEnd()) { QString line = in.readLine(); // read first line qDebug() << line; // here u should set com port/ baud instead. } file.close();
-
@mrjj Thank you mrjj
-
@lolilol78
so tutor said ok to read from file?
Note that sample read one line at a time -
@mrjj yes the fils has already been read with another function, but now :
how to actually send those lines one by one to Arduino via Serial Com? -
Hi @lolilol78
You are searching for QSerialPort
-
@aha_1980 hello aha,
i am really having troubles searching through the site of qt, i am a novice and i cant really manage to code properly every time i try.
after having my text file read and every line read as QString, i want to send each line to Arduino via Serial. how can I do it ?
-
No no, it's not working that way - I'm not going to do your homework. I gave you two links and there are several examples.
The minimum you can do now is to have a look at the examples. Hint: this one looks close to your task :)
-
@lolilol78
You will use http://doc.qt.io/qt-5/qserialport.html#open to open your serial device for write and something like http://doc.qt.io/qt-5/qserialport.html#writeData or http://doc.qt.io/qt-5/qiodevice.html#write-2 to send the strings down the line. -
@aha_1980 Actually there are not several examples as I am searching for days on the internet how to simply send a string line from a text file through Serial, but thank you for your help.
-
@lolilol78 said in How to write code that enters lines in the Command Arguments Section:
Actually there are not several examples
Did you actually check the links @aha_1980 gave you?
There ARE examples, 9 to be precise.
You should study documentation and try. If you then still have problems or questions then ask. -
@jsulm yes I checked, I would like to know the difference between Asynchronized and Synchronized?
-
I could not explain better than this Stackoverflow answer:
When you execute something synchronously, you wait for it to finish before moving on to another task. When you execute something asynchronously, you can move on to another task before it finishes.
Edit: the post contained an even better comment:
In simpler terms:
SYNCHRONOUS
You are in a queue to get a movie ticket. You cannot get one until everybody in front of you gets one, and the same applies to the people queued behind you.
ASYNCHRONOUS
You are in a restaurant with many other people. You order your food. Other people can also order their food, they don't have to wait for your food to be cooked and served to you before they can order. In the kitchen restaurant workers are continuously cooking, serving, and taking orders. People will get their food served as soon as it is cooked.