Parallel port command

J

john

Hi,

I am trying to use "_outp " function to write to parallel port . I am
using microsoft visual C++6.0. I am using it like this _outp ( 956,
255) . I am using decimal numbers. The thing is that program crahes
evertime , I run it. Please advice!

John

#include < stdio. >
#include <dos.h >

main ()

{
_outp ( 956, 255);

}
 
J

John F

john said:
Hi,

I am trying to use "_outp " function to write to parallel port . I am
using microsoft visual C++6.0. I am using it like this _outp ( 956,
255) . I am using decimal numbers. The thing is that program crahes
evertime , I run it. Please advice!

Visual C(++) is for windows... I suppose you are running XP,2K or NT...
these prevent you from accessing hardware directly. You will need a kernel
mode driver to do that. have a look at:
http://www.logix4u.net/inpout32.htm will do it for the OSes mentioned
above...

Your problem has nothing to do with C... thus it is off topic here...

First: it is int main()...
_outp ( 956, 255);

does work perfectly for me ... under DOS or W95, W98 ...

regards
John F(dot)
 
K

Keith Thompson

john said:
I am trying to use "_outp " function to write to parallel port . I am
using microsoft visual C++6.0. I am using it like this _outp ( 956,
255) . I am using decimal numbers. The thing is that program crahes
evertime , I run it. Please advice!

John

"program crashes" doesn't tell us much. Without knowing *how* it
crashes, and what error message you get, it's less likely that anyone
will be able help.
#include < stdio. >

This should be "#include <stdio.h>". I don't know whether the spaces
are allowed (though at least some compilers will treat them as part of
the header name), but the missing 'h' will almost certainly cause an
error.

The code you posted is almost certainly not the code you actually
compiled. Don't re-type your code; copy-and-paste it *exactly*. If
you're writing code off the top of your head into your editor or
newsreader, copy-and-paste it into a source file and compile it before
hitting "send". Don't ask us to waste our time guessing which errors
are in your original code and which were introduced when you re-typed
it.

#include <dos.h >


This should be "int main(void)".
{
_outp ( 956, 255);

Non-standard function.

You should have a "return 0;" here.

I suggest you fix these errors and then post your question to a
newsgroup where it's actually topical.
 
T

The Grue - James T. Sprinkle

john said:
Hi,

I am trying to use "_outp " function to write to parallel port . I am
using microsoft visual C++6.0. I am using it like this _outp ( 956,
255) . I am using decimal numbers. The thing is that program crahes
evertime , I run it. Please advice!

John

#include < stdio. >
#include <dos.h >

Using dos.h will require, most likely, a dos compiler and dos to actually
run on. You can get a free version of turbo c or c++ from the borland
museum. Just google it.

The Grue
 
S

Sjouke Burry

john said:
Hi,

I am trying to use "_outp " function to write to parallel port . I am
using microsoft visual C++6.0. I am using it like this _outp ( 956,
255) . I am using decimal numbers. The thing is that program crahes
evertime , I run it. Please advice!

John

#include < stdio. >
#include <dos.h >

main ()

{
_outp ( 956, 255);

}
Dont you have to allow access to those ports first?
Otherwise acces to those port WILL crash your
program.
Google for "USERPORT" or "PORT ACCESS".
There are a number of utilitys to do this for you.


Copy'd from readme:
UserPort.txt

The files UserPort.sys and UserPort.exe are required if you want to have
access to
your printer port using the GMT g_n*h.dll library.
These file stem from an lp object for Pure-Data, taken from zexy (pd
project)
ported by Olaf Matthes.
Adapted to GMT use by Godfried-Willem Raes, 28.05.2002.

To get it running under WinNT/2000/XP a special kernel driver is needed.
These systems do not allow direct access to I/O ports. The subfolder
'UserPort' contains a kernel driver that handles the I/O stuff. Just copy
the file UserPort.sys into
c:\winnt\system32\drivers
and run the program
UserPort.exe.
Click on 'Start' and then 'Exit'. If you ever whish to remove
the kernel driver start the programm again and click 'Stop'.

Under Win95/98/Me all this is not needed!!!

Good Luck!
 
K

Keith Thompson

Sjouke Burry said:
Dont you have to allow access to those ports first?
Otherwise acces to those port WILL crash your
program.
Google for "USERPORT" or "PORT ACCESS".
There are a number of utilitys to do this for you.
[snip]

This is entirely off-topic in comp.lang.c. Please take this
discussion to a DOS or Windows newsgroup, where you'll find people who
are far more likely to have answers than we are here.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,174
Messages
2,570,940
Members
47,486
Latest member
websterztechnologies01

Latest Threads

Top