2 Copyright © 2012, The AROS Development Team. All rights reserved.
6 #include <devices/printer.h>
10 #include <proto/exec.h>
13 #include <aros/debug.h>
15 const char version
[] = "$VER: InitPrinter 1.0 (03.03.2012) © AROS Dev Team";
17 char __stdiowin
[]="CON:/30/400/100/InitPrinter/AUTO/CLOSE/WAIT";
25 static BOOL
init_printer(ULONG unit
)
27 struct MsgPort
*PrintMP
;
28 struct IOPrtCmdReq
*PrintIO
;
31 if ((PrintMP
= CreateMsgPort()))
33 if ((PrintIO
= CreateIORequest(PrintMP
, sizeof(struct IOPrtCmdReq
))))
35 if (OpenDevice("printer.device", unit
, (struct IORequest
*)PrintIO
, 0))
37 PutStr("Error: printer.device did not open\n");
41 D(bug("[InitPrinter] unit %d request %p msgport %p\n", unit
, PrintIO
, PrintMP
));
42 PrintIO
->io_PrtCommand
= aRIN
; // Initialize
43 PrintIO
->io_Parm0
= 0;
44 PrintIO
->io_Parm1
= 0;
45 PrintIO
->io_Parm2
= 0;
46 PrintIO
->io_Parm3
= 0;
47 PrintIO
->io_Command
= PRD_PRTCOMMAND
;
49 if (DoIO((struct IORequest
*)PrintIO
))
51 Printf("Printer reset failed. Error: %d\n", (IPTR
)PrintIO
->io_Error
);
57 CloseDevice((struct IORequest
*)PrintIO
);
59 DeleteIORequest(PrintIO
);
63 PutStr("Error: Could not create I/O request\n");
65 DeleteMsgPort(PrintMP
);
69 PutStr("Error: Could not create message port\n");
78 IPTR args
[ARG_COUNT
] = {0};
80 ULONG retval
= RETURN_ERROR
;
82 if ((rda
= ReadArgs("UNIT/N", args
, NULL
)))
86 unit
= *(LONG
*)args
[ARG_UNIT
];
88 if (init_printer(unit
))
96 PutStr("Error: Could not read arguments\n");