Writing a paraller port resource manager

Hi all,

I’ve been writing a resource manager for a digital/analog D/A A/D controller
attached to the paraller port of x86 machine having RTOS 6.1.0. The
controller doesn’t have capabilities fro communication, it just waits for
proper valuesSo far the resource manager works nicely and I can pergorm
io_write and io_read actions. However I’m having problems in giving the
actual commad to the hardware. The hardware supplier states that, for
exaple, activating a digital output is done by setting a 8 bit digit to port
address and then triggering it by setting STROBE to port+2. So FF sets all
digital outputs on. I’ve done this in the io_write in the resource manager
by copying the data to the mapped addess (I’ve mapped the port in io_open,
and will unmap it in io_close). Is my approach too straightforward? I have
also filled the resource manager with debug printing, so I can see that all
values are copied to correct memory addresses properly. The hardware
provired has given a DOS test executables and I have verified that the
hardware works (I gan set the digital outputs on and off).

I would appreciate if someone could give a link for documentation too.

Cheers,
Pete

“Pete Tahvanainen” <pete.tahvanainen@basware.com> wrote in message
news:9u4qvc$jps$1@inn.qnx.com

actual commad to the hardware. The hardware supplier states that, for
exaple, activating a digital output is done by setting a 8 bit digit to
port
address and then triggering it by setting STROBE to port+2.
snip

Perhaps you need to use the in8()/out8() function to put the 8 bit value to
an I/O port. The x86 has a separate I/O bus - this could be what your issue
is. Documentation for in8() is located at :

http://qdn.qnx.com/support/docs/neutrino_2.11_en/lib_ref/i/in8.html

-Adam

Hi,

I tried to use in8()/out8(), but I got ‘Memory fault’. Then I wrote the
driver in DOS to see that the hw wasn’t damaged, this was succesful. I
looked the documentation about out() (in dos.h) and noticed that out writes
low byte to the address specified and high byte to address+1. in8() and
out8() propably do the same thing?

However the error message I got would suggest that I have mapped the I/O
adress incorrectly. For mapping I used mmap_device_io(), as specified in the
documentation. Since there is no example, I propably have done something
funny (unfortunatelly the source is at home, so I can not include the exact
mapping here). COuld you give me an example how to map the parallel port
correctly?

Cheers,
-Pete


“Operating System Tech Support” <os@qnx.com> wrote in message
news:9u5j08$p29$1@nntp.qnx.com

“Pete Tahvanainen” <> pete.tahvanainen@basware.com> > wrote in message
news:9u4qvc$jps$> 1@inn.qnx.com> …

snip
actual commad to the hardware. The hardware supplier states that, for
exaple, activating a digital output is done by setting a 8 bit digit to
port
address and then triggering it by setting STROBE to port+2.
snip

Perhaps you need to use the in8()/out8() function to put the 8 bit value
to
an I/O port. The x86 has a separate I/O bus - this could be what your
issue
is. Documentation for in8() is located at :

http://qdn.qnx.com/support/docs/neutrino_2.11_en/lib_ref/i/in8.html

-Adam

Pete Tahvanainen <pete.tahvanainen@basware.com> wrote:

Hi,

Have you issued a ThreadCtl() call to get io privity?

You need ThreadCtl( _NTO_TCTL_IO, 0 ) in the thread that is going
to issue any in/out calls before making those calls.

-David

I tried to use in8()/out8(), but I got ‘Memory fault’. Then I wrote the
driver in DOS to see that the hw wasn’t damaged, this was succesful. I
looked the documentation about out() (in dos.h) and noticed that out writes
low byte to the address specified and high byte to address+1. in8() and
out8() propably do the same thing?

However the error message I got would suggest that I have mapped the I/O
adress incorrectly. For mapping I used mmap_device_io(), as specified in the
documentation. Since there is no example, I propably have done something
funny (unfortunatelly the source is at home, so I can not include the exact
mapping here). COuld you give me an example how to map the parallel port
correctly?

Cheers,
-Pete



“Operating System Tech Support” <> os@qnx.com> > wrote in message
news:9u5j08$p29$> 1@nntp.qnx.com> …
“Pete Tahvanainen” <> pete.tahvanainen@basware.com> > wrote in message
news:9u4qvc$jps$> 1@inn.qnx.com> …

snip
actual commad to the hardware. The hardware supplier states that, for
exaple, activating a digital output is done by setting a 8 bit digit to
port
address and then triggering it by setting STROBE to port+2.
snip

Perhaps you need to use the in8()/out8() function to put the 8 bit value
to
an I/O port. The x86 has a separate I/O bus - this could be what your
issue
is. Documentation for in8() is located at :

http://qdn.qnx.com/support/docs/neutrino_2.11_en/lib_ref/i/in8.html

-Adam


QNX Training Services
I do not answer technical questions by email.

Hi,

Actuallly no (trying to get it to run in single thrad first). I couldn’t
quite understand from the documentation how that is done (and didn’t issue,
supprisingly code doesn’t work). Could you give an example?


Thanks,
-Pete


“David Gibbs” <dagibbs@qnx.com> wrote in message
news:a1kcvk$d48$3@nntp.qnx.com

Pete Tahvanainen <> pete.tahvanainen@basware.com> > wrote:
Hi,

Have you issued a ThreadCtl() call to get io privity?

You need ThreadCtl( _NTO_TCTL_IO, 0 ) in the thread that is going
to issue any in/out calls before making those calls.

-David

I tried to use in8()/out8(), but I got ‘Memory fault’. Then I wrote the
driver in DOS to see that the hw wasn’t damaged, this was succesful. I
looked the documentation about out() (in dos.h) and noticed that out
writes
low byte to the address specified and high byte to address+1. in8() and
out8() propably do the same thing?

However the error message I got would suggest that I have mapped the I/O
adress incorrectly. For mapping I used mmap_device_io(), as specified in
the
documentation. Since there is no example, I propably have done something
funny (unfortunatelly the source is at home, so I can not include the
exact
mapping here). COuld you give me an example how to map the parallel
port
correctly?

Cheers,
-Pete


“Operating System Tech Support” <> os@qnx.com> > wrote in message
news:9u5j08$p29$> 1@nntp.qnx.com> …
“Pete Tahvanainen” <> pete.tahvanainen@basware.com> > wrote in message
news:9u4qvc$jps$> 1@inn.qnx.com> …

snip
actual commad to the hardware. The hardware supplier states that, for
exaple, activating a digital output is done by setting a 8 bit digit
to
port
address and then triggering it by setting STROBE to port+2.
snip

Perhaps you need to use the in8()/out8() function to put the 8 bit
value
to
an I/O port. The x86 has a separate I/O bus - this could be what your
issue
is. Documentation for in8() is located at :

http://qdn.qnx.com/support/docs/neutrino_2.11_en/lib_ref/i/in8.html

-Adam




\

QNX Training Services
I do not answer technical questions by email.

Well, this propably does the trick?

// Enable IO capability.
if(ThreadCtl(_NTO_TCTL_IO, NULL) == -1) {
fprintf(stderr, “Unable to obtain I/O privity. You
must be userid root.\n”);
exit(EXIT_FAILURE);
}

I suddenly found this from:

http://cvs.qnx.com/cgi-bin/cvsweb.cgi/lib/io-char/ttc.c?rev=1.1.1.1&content-
type=text/x-cvsweb-markup

I’ll try this and tell if it worked.

-Pete


“Pete Tahvanainen” <pete.tahvanainen@basware.com> wrote in message
news:a1ugje$a80$1@inn.qnx.com

Hi,

Actuallly no (trying to get it to run in single thrad first). I couldn’t
quite understand from the documentation how that is done (and didn’t
issue,
supprisingly code doesn’t work). Could you give an example?


Thanks,
-Pete


“David Gibbs” <> dagibbs@qnx.com> > wrote in message
news:a1kcvk$d48$> 3@nntp.qnx.com> …
Pete Tahvanainen <> pete.tahvanainen@basware.com> > wrote:
Hi,

Have you issued a ThreadCtl() call to get io privity?

You need ThreadCtl( _NTO_TCTL_IO, 0 ) in the thread that is going
to issue any in/out calls before making those calls.

-David

I tried to use in8()/out8(), but I got ‘Memory fault’. Then I wrote
the
driver in DOS to see that the hw wasn’t damaged, this was succesful. I
looked the documentation about out() (in dos.h) and noticed that out
writes
low byte to the address specified and high byte to address+1. in8()
and
out8() propably do the same thing?

However the error message I got would suggest that I have mapped the
I/O
adress incorrectly. For mapping I used mmap_device_io(), as specified
in
the
documentation. Since there is no example, I propably have done
something
funny (unfortunatelly the source is at home, so I can not include the
exact
mapping here). COuld you give me an example how to map the parallel
port
correctly?

Cheers,
-Pete


“Operating System Tech Support” <> os@qnx.com> > wrote in message
news:9u5j08$p29$> 1@nntp.qnx.com> …
“Pete Tahvanainen” <> pete.tahvanainen@basware.com> > wrote in message
news:9u4qvc$jps$> 1@inn.qnx.com> …

snip
actual commad to the hardware. The hardware supplier states that,
for
exaple, activating a digital output is done by setting a 8 bit
digit
to
port
address and then triggering it by setting STROBE to port+2.
snip

Perhaps you need to use the in8()/out8() function to put the 8 bit
value
to
an I/O port. The x86 has a separate I/O bus - this could be what
your
issue
is. Documentation for in8() is located at :

http://qdn.qnx.com/support/docs/neutrino_2.11_en/lib_ref/i/in8.html

-Adam




\

QNX Training Services
I do not answer technical questions by email.