Thread: printing to usb port

  1. #1
    Unregistered
    Guest

    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++

  2. #2
    Linguistic Engineer... doubleanti's Avatar
    Join Date
    Aug 2001
    Location
    CA
    Posts
    2,459
    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?
    hasafraggin shizigishin oppashigger...

  3. #3
    Unregistered
    Guest

    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.

  4. #4
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    To access the USB you must go through the driver for it.

  5. #5
    ....
    Join Date
    Aug 2001
    Location
    Groningen (NL)
    Posts
    2,380
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Parallel Port to USB controller and outb()
    By coletek in forum Linux Programming
    Replies: 1
    Last Post: 06-05-2009, 06:57 AM
  2. FTP program
    By jakemott in forum Linux Programming
    Replies: 14
    Last Post: 10-06-2008, 01:58 PM
  3. brace-enclosed error
    By jdc18 in forum C++ Programming
    Replies: 53
    Last Post: 05-03-2007, 05:49 PM
  4. USB port "monitor"
    By Victor in forum Windows Programming
    Replies: 1
    Last Post: 04-13-2005, 05:45 AM
  5. Printing via USB port
    By Unregistered in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 10-31-2001, 04:19 PM