I've been banging my head the last two days. I have a Freeduino Board with the ATmega 328, running at 16Mhz.
I am using a simple serial protocoll to communicate with the Freeduino, similar to the protocoll described by Guyt. On my host I have a program written in Qt, communicating with the Freeduino. Everything works fine as long as I stay below 28800 Baud. At 28800 and above I don't get any answer back from the serial interface.
Strangely, If I use the Serial Monitor, I can go up to the 115200 Baud rate. On the Qt side I already used two different libraries for the serial communication, each resulting in no communication above 19200 Baud.
Does anyone have an Idea where to search for the Problem? Any good Idea for debug is welcome. Thanks for the hints so far. I managed to strip down my Problem to a simple example that does not need Qt.
Setting Serial Port Baud Rate
I have a sketch for arduino and one for processing with the exact wrong behavior. The processing side sends an command string to the arduino and there it is returned with a OK added. As soon as I use a speed above 19200 (28800 even crashes) the processing side always claims to receive 'null' Slower speeds work fine. Could someone please try those two sketches at a high Baud rate? Here's the arduino code. Well, as I stated before, the serial monitor seems to be the only thing that can communicate with my arduino at 115200 Baud.
Everything else (QtSerial or Processing) simply does not work at any speed above 19200Baud. Something seems different in the way that the serial monitor communicates with the arduino compared to my applications. Does anyone have a high speed example showing data exchange from a processing sketch to the arduino at 115200 Baud, that I could use as starting point for my application? Both of your serial streams passing over the same pin, aren't they? Do you really need to save the two pins that moving 'your' stream (as opposed the the one used by the development system) to dedicated pins, by using NewSoftSerial?
If not, it removes all possibility of your stream and the serial monitor's stream clashing. And it is easy to do. (That's couched in 'Delphi running the other partner in the exchange' terms, but there is lots of generally useful material along the way.).
It doesn't seem to work. I check the baud rate using myPort.baudRate and the return value of setBaudeRate and for 416000 it returns 9600 resp. It does accept 400000 and 500000, but not numbers in between.
I've checked the setBaudRate function in qserialport.cpp, and it does not contain any check of valid values. It simply sets the BR. My only idea is that some other control function listens to the emitted signal and immediately sets it to default value again.??? I can communicate over serial interface in 416000 Bd using a python script so it's not a hardware issue. Here's an printout of all baud rates accepted by setBaudRate between 0 and 600000 in steps of 100.
600 500 400 300 300 200 200 100 100 100 10 0 0 0 0 0 0 0 0 0 0 0 8000 7500 6400 6000 5000 4800 4000 3200 3000 2500 2400 2000 1800 1600 1500 1200 1000 800 600 500 400 300 200 100. I have Qt 5.5.1 (Clang 6.1 (Apple), 64 bit) Built on Nov 25 2015 01:02:16. I try to use QserialPort to 62500. I send QByteArray FF00. At 115200 work fine with terminal in windows.
In terminal). But if i add SetBaudRate(62500) before open,(work return true). BUT don't work correctly in data. I connect terminal windows at 62500(works, i have capture correct trame in protocol who work in 62500) the data in terminal is different.
![]()
Can you help me? My project may be abandoned why don't work. I use two same USB-RS232 converter we work in 62500 ( in windows) USB CONVERTER(pc windows) croissing wire USB CONVERTER (in mac Qt) thank's.
I faced a strange problem using serial port. I can't write on serial port by a thread loop!! However I can write on it by thread constructor!
I can read from serial port in thread but I can't write on it. I don't know where is the problem but by my personal experience in using QSerialPort I think Serial port in Qt have some issues with thread! Because it's not my firs problem with QSerialPort and QThread together. Maybe I'm wrong but I wrote this code before with c# and this sort of things are not issue there!
Linux Set Serial Port Baud Rate![]()
Thanks in advices. Creating your serial port instance in the constructor of the QThread subclass means it's created in the thread calling the constructor (in your case probably the main thread). The run method is running in the thread managed by QThread which means that you are using a serial port which has affinity with a different thread than the one that runs 'run'. The moveToThread function moves a QObject from the thread that created the object to the thread that is handled by QThread. 's documentation shows the worker object approach.
Dragon City MOD APK [Unlimited Money] Latest - Games Android. Dragon City hack is working cheat tool online for generating gold, food, and gems. Dragon City Cheats and Hack 2018 Gems Generator MOD (Unlimited) Safe and Easy to Use Legal Dragon City Hack Tool 2018 Dragon City Cheats on Free. [NEW] DRAGON CITY HACK ONLINE 2016 REAL WORKS: www.online.generatorgame.com Add up to 999999 Gold Food and Gems for Free:. Dragon city mod apk unlimited gems and money android 1. Dragon City Hack Online 2018 - Get Unlimited Gems Instantly. Dragon city hack apk 5.0 dragon city hack and cheats dragon city hack android apk dragon city.
In your case create an object that will contain your QSerialPort (don't forget to set it as the parent of the QSerialPort) and that will handle the communication/processing you need for your application. Thank you dear SGaist for your answers. I did this as you said but it seems it not the problem. Maybe I'm doing this wrong. Working with serial port in qt became a huge trouble for me! I can't figure out how to do this correctly! I need to read from arduino and write missions on it but in both sides I stocked!
In reading I have run time errors after 2 or 3 hours and I had no success on writing! Someone told me to not use thread and use Qt examples but managing serial port in this baud rate is a blocking operation and I have to use thread!
Standard Serial Baud Rates
And no matter how many times I try it's not working as it expected!! I'm saying again maybe I'm doing it all wrong but I can't find an example for this!:(. Yes I used QThread and QSerialPort wrong together but it's not mean that I don't know what I'm doing! I'm newbie in qt and still have trouble to use some of qt libraries. But you are right. Using thread was wrong at the first place! I didn't need it.
Thanks to SGaist I realize it now! I tried without thread before and it has delay. Today I figured out using readyRead signal is not my solution!
![]()
I used QTimer and 10 milliseconds for connecting to parser function(slot) and it's solved my problem for good. Thank you for your response.:).
Comments are closed.
|
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |