Skip navigation.
Home
The QNX Community Portal

View topic - serial communication by using PhAB

serial communication by using PhAB

Isn't the name clear?

serial communication by using PhAB

Postby snowingfish » Mon Feb 09, 2009 9:56 pm

Hi everyone,
I am going to build a serial communication application with PhAB. I need a window to show the received data, which widget should I use?
Is there any example of serial communication avialable? Thanks very much!
snowingfish
Active Member
 
Posts: 54
Joined: Tue Nov 18, 2008 1:15 pm

RE: serial communication by using PhAB

Postby juanplacco » Mon Feb 09, 2009 10:32 pm

I suggest you to make a separate "server" that communicates with the hardware (a resource manager), and dedicate the graphical application only to show the data received by it... So the app send a msg to the RM, the RM implements the serial communication and when it has the data from somewhere, then it Reply with it to your graphical app.

IMHO I don't think is a good idea to communicate "directly" with hardware from you graphical app... Maybe in the future more apps or other proceeses will need to communicate with the same hardware and if you have that intermediary "server", it will be very easy to synchronize all the clients you need...

Regards,
JM
juanplacco
Senior Member
 
Posts: 318
Joined: Wed May 17, 2006 2:30 pm

RE: serial communication by using PhAB

Postby snowingfish » Tue Feb 10, 2009 8:57 am

Thank you juanplacco,
your suggestion is a very good idea, but I am a newbie of QNX, so it is difficult for me to write a RM...........
snowingfish
Active Member
 
Posts: 54
Joined: Tue Nov 18, 2008 1:15 pm

Postby juanplacco » Tue Feb 10, 2009 2:14 pm

hum... It is no so difficult to write a RM since it is very well documented.

Anyway, I sent you a code, which I hope is helpful.

To get started writing and reading to/from the serial port, you can just use standars open/read/write functions... like

fd = open( "/dev/ser1", O_RDONLY );
size_read = read( fd, buffer, sizeof( buffer ) );

To set the configuration of the stream you can do it from the console with stty command. For example:

stty baud=9600 bits=8 stopb=1 par=none < /dev/ser1

Ok, "I can only show you the door, you're the one that has to walk through it" (Morpheus) :D

Good Luck
JM
Attachments
client_server.tar.gz
client/server example
(2.73 KiB) Downloaded 191 times
juanplacco
Senior Member
 
Posts: 318
Joined: Wed May 17, 2006 2:30 pm

Postby juanplacco » Tue Feb 10, 2009 2:20 pm

juanplacco
Senior Member
 
Posts: 318
Joined: Wed May 17, 2006 2:30 pm

Postby snowingfish » Tue Feb 10, 2009 2:55 pm

Thank you so much JM!! It is must be helpful (but I should figure out how to use it first :D ). I am reading the RM document now.
By the way, I am using a self-host QNX neutrino 6.4 now, there is no IDE with it. so is there any problem for writing RM?
snowingfish
Active Member
 
Posts: 54
Joined: Tue Nov 18, 2008 1:15 pm

Postby juanplacco » Tue Feb 10, 2009 4:50 pm

Not at all. You can write a full RM with vi editor.

Anyway, maybe you can start, developing your application with AppBuilder and interface with your hardware from there as start point.

Regards,
JM
juanplacco
Senior Member
 
Posts: 318
Joined: Wed May 17, 2006 2:30 pm

Postby mario » Tue Feb 10, 2009 7:31 pm

You can't throw vi at a newbees, you'll kill their spirits lol! You can try workspace, far less powerful but less intimidating ;-)
mario
QNX Master
 
Posts: 4132
Joined: Sun Sep 01, 2002 1:04 am

Postby juanplacco » Tue Feb 10, 2009 7:43 pm

hey mario... you are right...

As far as I'm concerned, I can live with med since vedit is unfortunately no longer available...
juanplacco
Senior Member
 
Posts: 318
Joined: Wed May 17, 2006 2:30 pm

Postby analyser » Wed Feb 11, 2009 12:47 am

Juan, thanks for code, very useful (message passing).

Un saludo,

illes
analyser
Active Member
 
Posts: 42
Joined: Sat Sep 08, 2007 9:05 am
Location: Hungary

Postby snowingfish » Wed Feb 11, 2009 10:37 am

thanks guys....I think I'd better use ped..the workspace is not available, need to be installed first...
snowingfish
Active Member
 
Posts: 54
Joined: Tue Nov 18, 2008 1:15 pm

Postby mario » Wed Feb 11, 2009 12:08 pm

ped, you got to be kidding?
mario
QNX Master
 
Posts: 4132
Joined: Sun Sep 01, 2002 1:04 am

Postby snowingfish » Wed Feb 11, 2009 12:35 pm

:oops: ...I am full of shame at lack of knowledge about this. Because I use ped for edit the code of the project in PhAB. So I though it could be working....or I need to install the workspace?

Many thanks!
snowingfish
Active Member
 
Posts: 54
Joined: Tue Nov 18, 2008 1:15 pm

Postby juanplacco » Wed Feb 11, 2009 2:02 pm

I think you must install workspace. Also med is a good choice if you want a text mode fast editor with syntax highlighting but no undo and not so powerfull... ws is pretty slow for my taste, but better choice than ped in all respects...

You can also edit from windows if you want, of course.

JM
juanplacco
Senior Member
 
Posts: 318
Joined: Wed May 17, 2006 2:30 pm

Postby Tim » Wed Feb 11, 2009 2:48 pm

I prefer to download jed, the emacs clone.

It's a very good text editor with text highlighting, undo etc. It's available from the 3rd party repository and is a snap to install. It's so useful that I can't understand why it doesn't ship with QNX.

Tim
Tim
Senior Member
 
Posts: 1390
Joined: Wed Mar 10, 2004 12:28 am

Next

Return to GUI Programming

Who is online

Users browsing this forum: No registered users and 1 guest