Project Home
Project Home
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - Qt 4.7 on QNX 6.5.0 SDP1 using Rs232 interface on Beagleboard XM: (22 Items)
   
Qt 4.7 on QNX 6.5.0 SDP1 using Rs232 interface on Beagleboard XM  
Hi there

I want to send informations via usb to the rs232 serial interface on a Beagleboard xM and read these informations for 
use in my qt program which I ported to QNX OS.
Problem now is, that I don't know how to start with this topic..

Can I read the sended data with Qt, or do I have to use QNX Code for this?

If I have to use QNX Code.. what do I need (to do) and is there an example which combines QT and QNX available for 
further research on this topic?

I have to finish this task in a short time, so I would appreciate it if you could give examples or tell me the exact 
chapters where I have to look.

My knowledge about this at the moment:
I think I have to include QNX libraries in my Qt code and write the code somewhere in my normal Qt code (?). But never 
tried this until now (was busy with qt and porting to qnx :) had my share of problems with that..)

So, please help!
Re: Qt 4.7 on QNX 6.5.0 SDP1 using Rs232 interface on Beagleboard XM  
>>>Can I read the sended data with Qt, or do I have to use QNX Code for this?
There isn't "Qt" code and "QNX" code - it's all QNX C++ code.

Since the serial reader will sleep most of the time, you will need a separate thread for this - otherwise the UI will "
freeze".   

Fortunately, Qt provides a thread object (QThread) where you can put your serial comm logic.  There are already posted 
examples of using a thread - aMeter, speedo and qTstat all use one so they can sleep waiting for external data.  The 
relevant code is...

#include <QThread>

class watchThread : public QThread
{
public:
    void run();  // re-implement this method - from default QThread
};

...
watchThread *valThread;
valThread = new watchThread;
valThread->start();  // calls valThread->run() implemented below

....
 /* Thread routine to drive the simulation
void watchThread::run()
{
    // open /dev/ser1
    while (true)
    {
         // read data from /dev/ser1 - will sleep most of the time
    }
}
Re: Qt 4.7 on QNX 6.5.0 SDP1 using Rs232 interface on Beagleboard XM  
Thanks a lot for this incredible fast answer!

This helps me a lot!
I have not noticed the thread code in speedo, but will check this now.

Again, thanks!
Re: Qt 4.7 on QNX 6.5.0 SDP1 using Rs232 interface on Beagleboard XM  
Hi

Using QThreads is easy (relatively), but my problem now is the following:

<<  /* Thread routine to drive the simulation
<<  void watchThread::run()
<<  {
<<      // open /dev/ser1
<<      while (true)
<<      {
<<           // read data from /dev/ser1 - will sleep most of the time
<<      }
<<  }

How can I connect to the rs232 interface? 
I know there is the Qextserialport - project, but is there an easier way? 
Re: Qt 4.7 on QNX 6.5.0 SDP1 using Rs232 interface on Beagleboard XM  
And whats more: 

Is this interface even working on QNX? The docu says:

"QextSerialPort provides an interface to old fashioned serial ports for Qt-based applications. It currently supports Mac
 OS X, Windows, Linux, FreeBSD."
Re: Qt 4.7 on QNX 6.5.0 SDP1 using Rs232 interface on Beagleboard XM  
Since QextSerialPort supports posix operating systems, it would probably need little change to work with QNX.

However, once inside run(), you can just write your own QNX serial code.  The biggest issue for newbies is getting the 
serial port set to "raw" mode - so it acts like a windows comport.  To do that you can run "stty +raw </dev/ser1" - then
 use open()/read()/write() calls.

The attached sample program "should" open, set "raw" and then print received data to the console.  (Code based on sample
, can be placed inside your run() method.)
Attachment: Text rawcom.c 1.78 KB
Re: Qt 4.7 on QNX 6.5.0 SDP1 using Rs232 interface on Beagleboard XM  
thanks!

I will try it your way, because I am afraid that it isnot so easy to change QestSerialPort (for a newbie) :)
Re: Qt 4.7 on QNX 6.5.0 SDP1 using Rs232 interface on Beagleboard XM  
Hi Dennis

I worked with your example code and used the same parameter changes. As I understood termios this should set the 
terminal settings to raw mode.
------------------------------------------------
// Set input baud rate
	speed = 115200;
        cfsetispeed(&raw, speed);
	cfsetospeed(&raw, speed);
	raw.c_iflag &= ~(BRKINT | ICRNL | INPCK | ISTRIP | IXON );
	raw.c_oflag &= ~(OPOST);
        raw.c_cflag &= ~(CSIZE|IHFLOW|OHFLOW);
        raw.c_cflag |= CS8 | CREAD | CLOCAL;
        raw.c_cflag &= ~CSTOPB;
	raw.c_cflag &= ~PARENB;
	raw.c_lflag &= ~(ECHO | ICANON | ISIG | ECHOE | ECHOK | ECHONL | IEXTEN);
	raw.c_cc[VMIN] =  1;
	raw.c_cc[VTIME] = 0;
---------------------------------------------

Then I tried to read and write between my laptop and the BBxM. (for testing and snding the qnx code I use Momentics via 
qconn). My Problem now:
1. the first character/byte/int/whatever is ignored. only after the second send it is recognized on the BBxM
2. I cannot receive signals from Qnx on my laptop. however, if I don´t use the testprogram and send from my laptop a 
string ("Hello") I receice immediately from QNX the same string ("Hello"). 
I am sure that it is a problem from the QNX side, because I don´t receive anything if the serial port isn´t connected 
to the BBxM.

It looks like there is another program by default which is monitoring the serial interface and if I try to open the 
serial device on my own to send and read, then it meddle with the data.
What can I do about this? Any idea? (need some screenshots for explaining my problem?)

Re: Qt 4.7 on QNX 6.5.0 SDP1 using Rs232 interface on Beagleboard XM  
>>>It looks like there is another program by default which is monitoring the serial interface and if I try to open the 
serial device on my own to send and read, then it meddle with the data.

Probably true.  Make sure 'tinit' is not running.  If so "slay" it and try your app.

Edit /etc/config/ttys and remove/comment any reference to "ser1".
Re: Qt 4.7 on QNX 6.5.0 SDP1 using Rs232 interface on Beagleboard XM  
Hi Dennis

I checked the processes on the BBxM and the folder /etc, but there is no "ttys" named-file and "tinit" is also not 
running.

In the pictures you can seee the processes running on BBxM after start and the fileSystem structure.
Hope this helps 
Attachment: Image SystemInformationPerspective.jpg 513.19 KB
Re: Qt 4.7 on QNX 6.5.0 SDP1 using Rs232 interface on Beagleboard XM  
And the FileSystem
Attachment: Image FileSystem.jpg 279.24 KB
Re: Qt 4.7 on QNX 6.5.0 SDP1 using Rs232 interface on Beagleboard XM  
Normally the last line of a build file is..

[+session] sh &

Have you removed this?  (I don't see "sh" in the process list.)  

If sh is not running on /dev/ser1, not sure what would be interfering.     I don't see any other issue with the process 
list.

The issue could be the Windows end? You might try a different terminal emulator.
Re: Qt 4.7 on QNX 6.5.0 SDP1 using Rs232 interface on Beagleboard XM  
the qnx os is from your example qnx_bglxm.
There I don´t have a buildfile, so I don´t know what it is written in it.
Re: Qt 4.7 on QNX 6.5.0 SDP1 using Rs232 interface on Beagleboard XM  
If you have a terminal emulator @115200 on the port, do you see "#" when you hit enter?  If so, that is what is 
interfering.
Re: Qt 4.7 on QNX 6.5.0 SDP1 using Rs232 interface on Beagleboard XM  
At first there is no "#" sign.
After I write an command, like ls, the "#" is present.

My terminal-program is putty (for windows)
Re: Qt 4.7 on QNX 6.5.0 SDP1 using Rs232 interface on Beagleboard XM  
Here is the buildfile - exported from my ide project.  You can build with a command like...

mkifs -v bsp-TI-omap3730-Beagle-xm.mkifs \temp\xm.ifs

There are some warnings about missing files.  You should be able to obtain them from your running image - using ftp.

If you want to use the serial port for your purposes, be sure to comment or remove this line:
[+session] sh &
Attachment: Text bsp-TI-omap3730-Beagle-xm.mkifs 16.96 KB
Re: Qt 4.7 on QNX 6.5.0 SDP1 using Rs232 interface on Beagleboard XM  
ok, i will try
Re: Qt 4.7 on QNX 6.5.0 SDP1 using Rs232 interface on Beagleboard XM  
Hi Dennis

I am trying to build a bsp with your buildfile.
First I copied the folders with ending "-xm-src", "-xm" from the official bsp for Beagle-xM and "target" (from my QNx 
Momentics folder) to a new folder on C:\QNX650\workspace.
Then I tried the suggested command (I was prepared to search for mising files :) ). 
Problem now is:
1.) Am I trying correct? (not sure..)
2.) I cannot find the missing file

In the picture you can see the what I tried.
Attachment: Image mkfs1_bsp_erstellen.jpg 354.48 KB
Re: Qt 4.7 on QNX 6.5.0 SDP1 using Rs232 interface on Beagleboard XM  
I use now a different approach for getting rid of sh, until I can figure out my problem with the building process :)

Now I have another question for you:

I use write(), open(), close(), etc.. for communicationg with the serial interface. For this I include the following 
files:

#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <termios.h>
#include <fcntl.h>
#include <string.h>

I have everytime the following warnings:

warning: implicit declaration of function 'open'
warning: implicit declaration of function 'close'
warning: implicit declaration of function 'write'

How can I get rid of these warnings?
Re: Qt 4.7 on QNX 6.5.0 SDP1 using Rs232 interface on Beagleboard XM  
I forgot:

I use the function like this:

count = write(fd, bif, sizeof(bif));

if ((fd = open ("/dev/ser1", O_RDWR)) == -1)

if (tcgetattr( fd, &raw))
	{
	       close( fd );
	       return -1;
    }
Re: Qt 4.7 on QNX 6.5.0 SDP1 using Rs232 interface on Beagleboard XM  
I call open(), write(), close() in my thread "Run()" code and get no warnings from compiler... even without explicitly 
including the standard C headers.  I cannot tell where your setup goes wrong.
Re: Qt 4.7 on QNX 6.5.0 SDP1 using Rs232 interface on Beagleboard XM  
Strange..

Maybe the setup from QNX momentics? hmm...

I read today that termios.h and such would be from ANSI and I could add a QNX_SOURCE macro. Something like:

#define _POSIX_C_SOURCE=199506
#include <limits.h>
#include <stdio.h>
...
#if defined(_QNX_SOURCE)
#include "non_POSIX_header1.h"
#include "non_POSIX_header2.h"
#include "non_POSIX_header3.h"
#endif

but truth to be told.. I don´t understand this.. :D
Could this help in my case?

(I tried already  "#define _POSIX_C_SOURCE=199506", but then it couldn´t understand "return EXIT_SUCCESS;" anymore..)

I also use "-Wc,-std=c99" as an option in the momentics compiler properties (if this helps)