Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!verifone!jimmy_t From: jimmy_t@verifone.com Newsgroups: comp.os.msdos.programmer Subject: Re: Printing Graphics files via LPT1: Message-ID: <2498.278cc4a0@verifone.com> Date: 12 Jan 91 03:13:04 GMT References: <8280@emcard.UUCP> Organization: VeriFone Inc., Honolulu HI Lines: 60 In article <8280@emcard.UUCP>, mat@emcard.UUCP (W Mat Waites) writes: > I'm trying to print bitmaps files to a Laserjet via LPT1: and the image > gets all trashed. I'm wondering if LPT1: is only passing 7 bits, playing > with what it thinks are tabs, etc. I know the file is good because I can > print it to a Laserjet from a Unix system (serial interface) and it works > fine. > > How can I get raw data through the parallel port? > If you are opening the LPT in a program as a DOS file, even if you tell DOS you want binary mode it may not give it to you. Here is the Microsoft C code I use to get around this problem. After I do a normal open of the file in binary mode, I call this routine with the handle returned by the open function: /**************************************************************************** Set Binary Mode *****************************************************************************/ void set_binary_mode (int target_handle) { int hand; union REGS r; /* get device info */ memset(&r, 0, sizeof(r)); r.h.ah = 0x44; r.h.al = 0x00; r.x.bx = target_handle; r.x.dx = 0; (void) int86(0x21, &r, &r); /* Check to see if DOS actually put device in character mode despite our request for binary mode. This is rumored to happen if you open a character device like LPT1: */ if ( (r.h.dl & 0x80) /* is it a character device? */ && !(r.h.dl & 0x20) /* in "cooked" mode */ ) { memset(&r, 0, sizeof(r)); r.h.ah = 0x44; r.h.al = 0x01; r.x.bx = target_handle; r.h.dh = 0x00; r.h.dl |= 0x20; /* set raw mode */ (void) int86(0x21, &r, &r); } } -- +------------------------------------+--------------------------------------+ | James H. Thompson | jimmy_t@verifone.com (Internet) | | VeriFone Inc. | uunet!verifone!jimmy_t (UUCP) | | 100 Kahelu Avenue | 808-623-2911 (Phone) | | Mililani, HI 96789 | | +------------------------------------+--------------------------------------+