OpenQNX :: The QNX Community Portal

Aug 08, 2008 - 12:58 AM
Google
  Web openqnx.com   
     Create an account Home · Submit News · QNX Forums · QNX Download · Search   
_
Main Menu
Who's Online
There are 47 unlogged users and 0 registered users online.

You can log-in or register for a user account here.

Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Author Message
wangxueli
Post subject: A data gather program without resource manager  PostPosted: Mar 13, 2007 - 07:52 AM
Active Member


Joined: Feb 07, 2006
Posts: 23

I am write a data gather programm. I want read and write the PCI card just in the phAb with out write the resource manager. With pressing a "start" button,I can read the data from the PCI card.And pressing a "stop" button,I can stop the data transfer.In some web sit,I realized that it is should be created a new thread to do this work.
The question is I don't know where and how to create the new thread .
Thanks for everyone who give me the hint.
 
 View user's profile Send private message  
Reply with quote Back to top
mario
Post subject: RE: A data gather program without resource manager  PostPosted: Mar 13, 2007 - 01:19 PM
QNX Master


Joined: Sep 01, 2002
Posts: 2812

You don't have to create a thread, you can create a create a photon handler called when receiving interrupt or a pulse.

If you want to create thread look at pthread_* function. Remember the photon library is not thread safe.
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
wangxueli
Post subject: RE: A data gather program without resource manager  PostPosted: Mar 14, 2007 - 01:41 AM
Active Member


Joined: Feb 07, 2006
Posts: 23

thanks mario
but my purpose is when I press the start button,the program read data from hardware.It doesn't need to receive interrupt or a pulse.The data transfer is controled by the PhAB.
And how to create a photon handler? which chapter I can reference in the QNX document?
 
 View user's profile Send private message  
Reply with quote Back to top
mario
Post subject: RE: A data gather program without resource manager  PostPosted: Mar 14, 2007 - 03:59 AM
QNX Master


Joined: Sep 01, 2002
Posts: 2812

Check the section on Parallels Operation in Photon Programmer's Guide
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
maschoen
Post subject: RE: A data gather program without resource manager  PostPosted: Mar 14, 2007 - 05:36 PM
QNX Master


Joined: Jun 25, 2003
Posts: 1051

Mario,
The Photon library may not be thread safe, but it is safe to create a thread in a photon program that doesn't do any photon calls, which is (I think) what wangxeli wants to do. It's also worth noting that with QNX, hardware code (usually called a driver) does not have to lie in the kernel. For this reason, the making of a "driver" using the resource manager is optional, and for the convience of creating a reusable interface. If you just want to write one program that accesses the hardware, you clearly don't need a resource manager.
 
 View user's profile Send private message Send e-mail Visit poster's website  
Reply with quote Back to top
wangxueli
Post subject: RE: A data gather program without resource manager  PostPosted: Mar 15, 2007 - 02:06 AM
Active Member


Joined: Feb 07, 2006
Posts: 23

I just want to write a simpler programme to gather the data from pci card. The hardware always send the data to computer,so that I can decide what time to start the gathering.And simultaneously store the data in file system , display them as image.resource manager or not,which method more simple?
please give me some suggestions.
 
 View user's profile Send private message  
Reply with quote Back to top
maschoen
Post subject: RE: A data gather program without resource manager  PostPosted: Mar 15, 2007 - 03:17 AM
QNX Master


Joined: Jun 25, 2003
Posts: 1051

Well, as I think I implied, it is much simpler (at least the first time around) to just write the code directly without a resource manager. Once you've done that, if you want to make it all a little fancier, you can build a resource manager around the hardware code.
 
 View user's profile Send private message Send e-mail Visit poster's website  
Reply with quote Back to top
wangxueli
Post subject: RE: A data gather program without resource manager  PostPosted: Mar 15, 2007 - 07:10 AM
Active Member


Joined: Feb 07, 2006
Posts: 23

thanks maschoen and Mario.
because I have to complete this work in one month,I want just write the code without a resource manager.I'll write the reource manager in the future.
 
 View user's profile Send private message  
Reply with quote Back to top
wangxueli
Post subject: RE: A data gather program without resource manager  PostPosted: Mar 22, 2007 - 01:17 PM
Active Member


Joined: Feb 07, 2006
Posts: 23

another question: when I repeatedly use PhDrawPhImage() to draw images,it is seems not refresh the images. Should I use some functions just like PgFlush() so that I can redraw the other image?

any help appreciated.
 
 View user's profile Send private message  
Reply with quote Back to top
maschoen
Post subject: RE: A data gather program without resource manager  PostPosted: Mar 22, 2007 - 06:34 PM
QNX Master


Joined: Jun 25, 2003
Posts: 1051

If you have code like this, do not expect it to work:

while(1)
{
sleep(delay);
PhDrawPhImage(image[i++]...);
}

That's not at all how Photon works. You have to exit your code before screen updates can occur.
Instead you might use a timer widget, and when it fires, update the image.
 
 View user's profile Send private message Send e-mail Visit poster's website  
Reply with quote Back to top
wangxueli
Post subject: RE: A data gather program without resource manager  PostPosted: Mar 23, 2007 - 02:13 AM
Active Member


Joined: Feb 07, 2006
Posts: 23

Thank you maschoen.very very thank you!! Smile
 
 View user's profile Send private message  
Reply with quote Back to top
wangxueli
Post subject: RE: A data gather program without resource manager  PostPosted: Apr 17, 2007 - 07:46 AM
Active Member


Joined: Feb 07, 2006
Posts: 23

I have another quenstion:I use the DMA mode to transfer the data.but the output data is not the one I want to output. And the input data can't be transfered to the appointed buffer,I don't know where it is.
I don't use the mmap() and mem_offset() to map the DMA register space into the process address space.I just use the in() and out() to operate these register directly. is this wrong?
Maybe my description is not clear.but I really don't know what's wrong.
please help me !!
 
 View user's profile Send private message  
Reply with quote Back to top
maschoen
Post subject: RE: A data gather program without resource manager  PostPosted: Apr 17, 2007 - 07:51 AM
QNX Master


Joined: Jun 25, 2003
Posts: 1051

It is ok to use in8() and out8() directly to adjust DMA registers directly. I can't figure out what else you are asking.
 
 View user's profile Send private message Send e-mail Visit poster's website  
Reply with quote Back to top
mario
Post subject: RE: A data gather program without resource manager  PostPosted: Apr 17, 2007 - 12:09 PM
QNX Master


Joined: Sep 01, 2002
Posts: 2812

Well it depends on the device. If it's a PCI device then the register could be memory mapped.
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
wangxueli
Post subject: RE: A data gather program without resource manager  PostPosted: Apr 18, 2007 - 02:26 AM
Active Member


Joined: Feb 07, 2006
Posts: 23

I am sorry my english is awful.
yes,It's a PCI device.I didn't use the mapp() function because of two reason.
The first, the function of
addr = mmap( 0,
XXXX,
PROT_READ|PROT_WRITE|PROT_NOCACHE,
MAP_PHYS|MAP_ANON,
NOFD,
0 );
mem_offset(addr, NOFD, 1, &offset, 0) ;
doesn't work on the DMA register.maybe some key point i don't konw.
The second,in() and out() function can operate the state of these register.just the input and output data is incorrect.
 
 View user's profile Send private message  
Reply with quote Back to top
Display posts from previous:     
Jump to:  
All times are GMT
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Powered by PNphpBB2 © 2003-2007 The PNphpBB Group
Credits
All logos and trademarks in this site are property of their respective owners. The comments are property of their posters.
Powered by OpenQNX: The QNX Community Portal Site
QNX and the QNX logo are registered trademarks of QNX Software Systems.