www.digitalmars.com         C & C++   DMDScript  

c++ - Stream output to USB device

reply "Heinz-Peter Nuettgens" <hnuettgens t-online.de> writes:
This might be a newbie question, but nevertheless i have got a problem:

I want to open a stream output to a printer device by calling fopen().
Normally I would open "LPT1:".
BUT my printer isn't connected to the printer port anymore. Instead of this
I use the USB port for the printer for several reasons. But now I am not
able to open a stream to the printer device to output ASCII data via
fprintf().

My question is: Is there a possibility to call fopen() to open an USB device
or any other existing device ??

Thanks for your help, if a get any :-))

Heinz-Peter
Mar 01 2001
parent reply Jan Knepper <jan smartsoft.cc> writes:
As far as I know fopen passes the supplied file name more or less direct to the
Operating System. So what you need to do is find out what the 'system name' is
your printer printer has in your operating system. I actually think you would be
able to assign LPT1: to your printer somewhere. After you find the system name
or assign LPT1: to your USB printer I would suspect that everything works as
before.

HTH

Jan



Heinz-Peter Nuettgens wrote:

 This might be a newbie question, but nevertheless i have got a problem:

 I want to open a stream output to a printer device by calling fopen().
 Normally I would open "LPT1:".
 BUT my printer isn't connected to the printer port anymore. Instead of this
 I use the USB port for the printer for several reasons. But now I am not
 able to open a stream to the printer device to output ASCII data via
 fprintf().

 My question is: Is there a possibility to call fopen() to open an USB device
 or any other existing device ??

 Thanks for your help, if a get any :-))

 Heinz-Peter

Mar 01 2001
parent "Kar Gay Lim" <kagay kimay.net> writes:
www.usb.org has links to a few good resources on USB but they
are mainly for engineers.

On Windows, if you are using fopen() etc, you are NOT actually
talking to the device directly, but rather to the "virtual" device. The
detail is probably beyond the scope of this discussion.  Nevertheless,
if your default printer is the USB printer and it has been set up to
capture another port, you can still generate your output to it.

Try Control Panel -> printers, open "Properties" on the default
printer, click on "Details" tab, you will see a button that says
"Capture Printer Port". Also make sure "Port Setting" has
"Spool MS-Dos Print Job" on. Otherwise, when you
are already printing in Windows, you won't be able to use
fopen() to write to "LPTx".

This would be like piping your output to a spooler in Unix/Linux.

Try it and see if this works.  Using fopen() on "prn" achieves the
same MS-DOS print captures as well.

Jan Knepper <jan smartsoft.cc> wrote in message
news:3A9E3A32.A3748C7D smartsoft.cc...
 As far as I know fopen passes the supplied file name more or less direct to the
 Operating System. So what you need to do is find out what the 'system name' is
 your printer printer has in your operating system. I actually think you would
be
 able to assign LPT1: to your printer somewhere. After you find the system name
 or assign LPT1: to your USB printer I would suspect that everything works as
 before.

 HTH

 Jan



 Heinz-Peter Nuettgens wrote:

 This might be a newbie question, but nevertheless i have got a problem:

 I want to open a stream output to a printer device by calling fopen().
 Normally I would open "LPT1:".
 BUT my printer isn't connected to the printer port anymore. Instead of this
 I use the USB port for the printer for several reasons. But now I am not
 able to open a stream to the printer device to output ASCII data via
 fprintf().

 My question is: Is there a possibility to call fopen() to open an USB device
 or any other existing device ??

 Thanks for your help, if a get any :-))

 Heinz-Peter


Mar 01 2001