[comp.os.msdos.programmer] Printing Graphics files via LPT1:

mat@emcard.UUCP (W Mat Waites) (01/09/91)

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?

Thanks,

Mat
-- 
W Mat Waites              |  Walking the wire is living,
{gatech,emory}!emcard!mat |  the rest is just waiting. - Wallenda

frank@cavebbs.gen.nz (Frank van der Hulst) (01/10/91)

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

How are you doing it -- if you want to do it from DOS, try COPY/B FILE LPT1:
-- the /B tells DOS it's binary, and not to stop at a ^Z.

The same type of problem applies to TurboC/Pascal -- it thinks the printer is
a text device, so it bombs out on ^Zs... there are workarounds, although I
don't know the specifics of them.


-- 

Take a walk on the wild side, and I don't mean the Milford Track.

stanley@phoenix.com (John Stanley) (01/10/91)

frank@cavebbs.gen.nz (Frank van der Hulst) writes:

> 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
> 
> The same type of problem applies to TurboC/Pascal -- it thinks the printer is
> a text device, so it bombs out on ^Zs... there are workarounds, although I
> don't know the specifics of them.

   There are supposedly at least 2 ways around the problem in TC. One I
do, one I think will work.

   Use the call biosprint(). While this makes your code non-portable, if
you are using TC it probably already is. This is the one I use to get around
the binary output problem.

   The other, untested, way is to do a setmode() on the output. 

mat@emcard.UUCP (W Mat Waites) (01/11/91)

In article <1991Jan09.220846.15527@cavebbs.gen.nz> frank@cavebbs.gen.nz (Frank van der Hulst) writes:
>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
>
>How are you doing it -- if you want to do it from DOS, try COPY/B FILE LPT1:
>-- the /B tells DOS it's binary, and not to stop at a ^Z.

Well, I have figured out the problem, and I mis-interpreted the symptoms.
My files will print fine to a LJII, but screw up on a LJIII. I thought that
the PCL stuff was compatible. BTW, I'm printing output from Gnuplot 2.0 pl 2
with the hpljii driver.

Does anyone know why the LJIII should have trouble?

Thanks,
Mat



-- 
W Mat Waites              |  Walking the wire is living,
{gatech,emory}!emcard!mat |  the rest is just waiting. - Wallenda

jimmy_t@verifone.com (01/12/91)

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