Skip navigation.
Home
The QNX Community Portal

View topic - A data gather program without resource manager

A data gather program without resource manager

Isn't the name clear?

A data gather program without resource manager

Postby wangxueli » Tue Mar 13, 2007 7:52 am

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.
wangxueli
Active Member
 
Posts: 23
Joined: Tue Feb 07, 2006 7:55 am

RE: A data gather program without resource manager

Postby mario » Tue Mar 13, 2007 1:19 pm

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.
mario
QNX Master
 
Posts: 4132
Joined: Sun Sep 01, 2002 1:04 am

RE: A data gather program without resource manager

Postby wangxueli » Wed Mar 14, 2007 1:41 am

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?
wangxueli
Active Member
 
Posts: 23
Joined: Tue Feb 07, 2006 7:55 am

RE: A data gather program without resource manager

Postby mario » Wed Mar 14, 2007 3:59 am

Check the section on Parallels Operation in Photon Programmer's Guide
mario
QNX Master
 
Posts: 4132
Joined: Sun Sep 01, 2002 1:04 am

RE: A data gather program without resource manager

Postby maschoen » Wed Mar 14, 2007 5:36 pm

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.
maschoen
QNX Master
 
Posts: 2640
Joined: Wed Jun 25, 2003 5:18 pm

RE: A data gather program without resource manager

Postby wangxueli » Thu Mar 15, 2007 2:06 am

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.
wangxueli
Active Member
 
Posts: 23
Joined: Tue Feb 07, 2006 7:55 am

RE: A data gather program without resource manager

Postby maschoen » Thu Mar 15, 2007 3:17 am

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.
maschoen
QNX Master
 
Posts: 2640
Joined: Wed Jun 25, 2003 5:18 pm

RE: A data gather program without resource manager

Postby wangxueli » Thu Mar 15, 2007 7:10 am

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.
wangxueli
Active Member
 
Posts: 23
Joined: Tue Feb 07, 2006 7:55 am

RE: A data gather program without resource manager

Postby wangxueli » Thu Mar 22, 2007 1:17 pm

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.
wangxueli
Active Member
 
Posts: 23
Joined: Tue Feb 07, 2006 7:55 am

RE: A data gather program without resource manager

Postby maschoen » Thu Mar 22, 2007 6:34 pm

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.
maschoen
QNX Master
 
Posts: 2640
Joined: Wed Jun 25, 2003 5:18 pm

RE: A data gather program without resource manager

Postby wangxueli » Fri Mar 23, 2007 2:13 am

Thank you maschoen.very very thank you!! :)
wangxueli
Active Member
 
Posts: 23
Joined: Tue Feb 07, 2006 7:55 am

RE: A data gather program without resource manager

Postby wangxueli » Tue Apr 17, 2007 7:46 am

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 !!
wangxueli
Active Member
 
Posts: 23
Joined: Tue Feb 07, 2006 7:55 am

RE: A data gather program without resource manager

Postby maschoen » Tue Apr 17, 2007 7:51 am

It is ok to use in8() and out8() directly to adjust DMA registers directly. I can't figure out what else you are asking.
maschoen
QNX Master
 
Posts: 2640
Joined: Wed Jun 25, 2003 5:18 pm

RE: A data gather program without resource manager

Postby mario » Tue Apr 17, 2007 12:09 pm

Well it depends on the device. If it's a PCI device then the register could be memory mapped.
mario
QNX Master
 
Posts: 4132
Joined: Sun Sep 01, 2002 1:04 am

RE: A data gather program without resource manager

Postby wangxueli » Wed Apr 18, 2007 2:26 am

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.
wangxueli
Active Member
 
Posts: 23
Joined: Tue Feb 07, 2006 7:55 am

Next

Return to GUI Programming

Who is online

Users browsing this forum: No registered users and 2 guests