-
printing to usb port
Is it possible to access a printer attached to a usb port. Have tried the usual way:-
FILE *prn_ptr;
if((fp_ptr = fopen(prn_ptr,"LPT1"))==NULL)
{
/* print error message*/
}
fprintf(prn_ptr,"Does this work??");
but to no avail. I know LPT1 is the parallel port, have tried the name of the port as it shows up in the printer properties, with no different result.have also tried putting form feeds in.
p.s. I'm "programming" in C not C++
-
wouldn't know off hand how to deal with USB/serial IO in dos... nor how to communicate with particular devices [which is why we have drivers]... but so far as your example, since when do we use file io functions for serial comm. io? where did you ever get that idea?
-
oops
oops. Sorry late night taking it's toll.
Should have written:
if((prn_ptr = fopen("LPT1","w"))==NULL).
As far as accessing serial goes, haven't yet covered this (still learning the basics, as you can tell).Just tried the above code as this accessed the printer on my system when it was attached via the parallel port.I do know that serial and parallel ports are completely different, didn't know if the drivers would sort it out. Now have new printer which is attached to USB, just wondering how to get printout to check the output layout of progs. Sorry for the confusion.
-
To access the USB you must go through the driver for it.
-
At this site you can find a universal USB driver. It replaces the USB driver for your device. According to the creators it can be attached to any USB device. It comes with a lot of documentation and examples. But... it is for Windows.
http://www.thesycon.de/usbio/eng/dl_usb_l.htm
But I think it is very valuable to study the documentation and the examples to learn about USB programming.