| Author |
Message |
|
|
Post subject: A data gather program without resource manager
Posted: 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. |
|
|
| |
|
|
|
 |
|
|
Post subject: RE: A data gather program without resource manager
Posted: 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. |
|
|
| |
|
|
|
 |
|
|
Post subject: RE: A data gather program without resource manager
Posted: 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? |
|
|
| |
|
|
|
 |
|
|
Post subject: RE: A data gather program without resource manager
Posted: 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 |
|
|
| |
|
|
|
 |
|
|
Post subject: RE: A data gather program without resource manager
Posted: 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. |
|
|
| |
|
|
|
 |
|
|
Post subject: RE: A data gather program without resource manager
Posted: 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. |
|
|
| |
|
|
|
 |
|
|
Post subject: RE: A data gather program without resource manager
Posted: 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. |
|
|
| |
|
|
|
 |
|
|
Post subject: RE: A data gather program without resource manager
Posted: 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. |
|
|
| |
|
|
|
 |
|
|
Post subject: RE: A data gather program without resource manager
Posted: 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. |
|
|
| |
|
|
|
 |
|
|
Post subject: RE: A data gather program without resource manager
Posted: 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. |
|
|
| |
|
|
|
 |
|
|
Post subject: RE: A data gather program without resource manager
Posted: Mar 23, 2007 - 02:13 AM
|
|
Active Member
Joined: Feb 07, 2006
Posts: 23
|
|
Thank you maschoen.very very thank you!!  |
|
|
| |
|
|
|
 |
|
|
Post subject: RE: A data gather program without resource manager
Posted: 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 !! |
|
|
| |
|
|
|
 |
|
|
Post subject: RE: A data gather program without resource manager
Posted: 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. |
|
|
| |
|
|
|
 |
|
|
Post subject: RE: A data gather program without resource manager
Posted: 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. |
|
|
| |
|
|
|
 |
|
|
Post subject: RE: A data gather program without resource manager
Posted: 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. |
|
|
| |
|
|
|
 |
|
|