Hi, on which platform are you? I guess your problem is most likely, that onBytesWritten is called when QSerialPort has written the data to the operating system (which has it's own buffers), but that does not mean the data is actually (completely) written on the serial line (and therefore not completely received from the other side).
Magix music maker soundpool dvd collection 18 free download. Newegg.com - A great place to buy computers, computer parts, electronics, software, accessories, and DVDs online. With great prices, fast shipping, and top-rated customer service - Newegg shopping upgraded ™ If you are reading this message, Please to reload this page.(Do not use your browser's 'Refresh' button).
We had a problem like this some month ago, where a Linux flush call helped; I just don't find it now:( In any case, this will mean you have to block your program so it should preferable be done in a thread. Edit: found it.
Said in: Now, I am able to create a simple GUI application and run it on my target device Ok, that's a great step. Reading briefly the link you posted to that wiki page, I assume you setup your environment in a Linux PC and using Qt Creator there, you built that simple GUI app that Qt Creator deployed and run in your device.
If that's correct, I'd try the following:. from command line in let's say /home/douglas/projects do cd /home/douglas/projects git clone git://code.qt.io/qt/qtserialport.git -b 5.9 cd qtserialport so you should now have a folder /home/douglas/projects/qtserialport will sources for Qt serial port module release 5.9 (the Qt release should match what you have in your dev environment/device, you didn't stated it so far). run commands: /opt/fslc-x11/2.2.1/sysroot/x8664-fslcsdk-linux/usr/bin/qt5/qmake make make install once build and install finishes, you should have the.so shared library and headers into the proper location under your host PC (I couldn't figure out the proper location from the wiki page). But look for something like this (version shuold be the one you cloned.):./include/QtSerialPort/qtserialportversion.h./include/QtSerialPort/qserialportinfo.h./include/QtSerialPort/qserialportglobal.h./include/QtSerialPort/5.9.0/QtSerialPort/private/qserialportp.h./include/QtSerialPort/5.9.0/QtSerialPort/private/qserialportinfop.h./include/QtSerialPort/qserialport.h and./lib/libQt5SerialPort.so if you succeed here, then you should be able to create a project file (.pro) for your application and add the serial port modulie like this. QT += serialport. And the magic will flow. Thanks a lot for your post, I'll now begin to put it into practice.
I have just one doubt: if I run: qmake -version I obtain: QMake version 2.01a Using Qt version 4.8.7 in /usr/lib/x8664-linux-gnu So, if I'm not wrong, the installed version of Qt is the 4.8.7 (quite old). When you stated, in your #1 step, 'git clone git://code.qt.io/qt/qtserialport.git -b 5.9' were you assuming my Qt version was 5.9? In other words, the serialport version and the installed qt version should be the same? If so, how can I upgrade from my actual Qt version to the latest one?
Thanks a lot!
Terminal shows how to create a terminal for a simple serial interface by using. This example shows the main features of the class, like configuration, I/O implementation and so forth. Also, the class is invoked to display information about the serial ports available in the system. Supports two general programming approaches:.
Vga Port
The asynchronous (non-blocking) approach. Operations are scheduled and performed when the control returns to Qt's event loop. Emits a signal when the operation is finished. For examplereturns immediately. When the data is sent to the serial port, emits. The synchronous (blocking) approach. In non-GUI and multithreaded applications, the waitFor.
functions can be called (i.e. ) to suspend the calling thread until the operation has completed. In this example, the asynchronous approach is demonstrated. The example illustrates the synchronous approach. Our example contains some GUI widgets:. is the main application window that contains all the working logic for the serial port programming, including configuration, I/O processing and so forth, while inheriting the QMainWindow. is the central widget of the main window, displaying the transmitted or received data.
The widget is derived from the QPlainTextEdit class. is a dialog for configuring the serial port, as well as for displaying the available serial ports and information about them. The serial port is instantiated in the constructor.
The main widget is passed as the parent, so the object deletion happens automatically according to the parent and child mechanism in Qt.
Qt Serial Port Programming
Did anybody make QSerialPort(Info) work on /dev/spidev. kernel driver?
I have running (visible, configured, operable via spidevtest.c) /dev/spidev0.0, however QSerialPortInfo::availablePorts returns list with just one member, for /dev/ttyAMA0. I guess I can not (simply) use QSerialPort constructor with '/dev/spidev0.0' parameter before 'somehow' getting /dev/spidev0.0 accepted by QSerialPortInfo. What to do to make /dev/spidev0.0 appear in the list? Deepak chopra books in hindi pdf free download. Any clues and advices heartily welcome. (I am able to workaround based on QFile of course, however I would love to do things Qt way;).). Thanks for explanation. SPI has same basic characteristics like serial port (baud rate, parity.) and even (kind of) asynchronous in/out driven by kernel device so this is why I expected same object could manage them both.
Now I intend to develop some object for accessing RS-485 UART on RaspComm board (which is itself driven via SPI). Is there something in Qt (ready or WIP) about this (not to re-invent wheel) or is there some design skeleton/advice allowing eventually later extend QtSerialPort by this 'device'? (I am willing to contribute, should my development be evaluated as worth it.). Getting back to document conclusions of my research on best practice of using RaspiComm RS-485 under Qt for anybody, who finds this thread useful (I expect many of it is valid for RS-232 on same board as well, did not test myself):. Do not try to implement communication with MAX3140 UART chip yourself (maybe except of asm based implementation, what is however most probably unnecessary exertion).
I succeeded to implement it based on kernel /dev/spidev0.0 only to find out that even this partially system driver supported solution is too slow for even 19 200 Bd speed (loosing about 5 characters on one received). I myself feared about RaspiComm RS-485 driver /dev/ttyRPC0 based on some forums complaints and not clear versioning, however found out, that the forum thread was heavy outdated. Worked like a charm and the resulting driver worked out-of-box for my latest Raspbian Wheezy (4.1.7+ #817). So I strongly recommend to take this approach. QSerialPort class has constructor with signature QSerialPort(const QString &, QObject.), where QString may contain even device which is not included in the QList that QSerialPortInfo::availablePorts returns. This works with no surprise.
If one does not set anything than (eventually) baud speed, one gets standard 8 bit, 1 stop bit, no parity without any character translations, good old plain raw binary. So QSerialPort may be used with /dev/ttyRPC0 directly and easily. QSerialPort rpc0('/dev/ttyRPC0'); rpc0.write('Binary request 0even xffcontaining weird x03characters', lengthofbinary); if(rpc0.waitForReadyRead(100)) // Enough long time in miliseconds QByteArray data = rpc0.readAll; // You may have to wait/read repetitively in loop // and merge data on higher link speeds. Hardware of RaspiComm uses RTS pin to select in/out direction of data.
CTS is kept active permanently by wiring, so using default use RTS/CTS mode works properly with no inappropriate blocking. That's all you should need, so enjoy your communication.
Comments are closed.
|
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |