LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Cannot close a parallel printer connection

I am attempting to send information to a parallel printer and I am having problems with the CloseFile function in the code fragment below. When I run the application, the following error is displayed on the CloseFile line: Library function error (return value == -1[0xffffffff]). General I/O failure. The application will print the first time through the FOR loop, but will stop at the closefile statement. I am running LabWindows/CVI 5.5 on a Windows 2000 operating system, with the same error on XP as well.

This error in the executable will allow the first print operation to work, but all subsequent printing won't take place.

// Test App
#include
#include

char file[24];
int fhdl;
int i;

int main (void){

for (i=0; i < 3; ++i){

Fmt (file, "PRN");
fhdl = OpenFile (file, VAL_WRITE_ONLY, VAL_APPEND, VAL_ASCII);
FmtFile(fhdl, "8732-0208 FUNCTIONAL TEST LIMITS\n" );
FmtFile(fhdl,"\n\n\n\n\n\n\n\n");

CloseFile (fhdl);

}
}
//End of App
0 Kudos
Message 1 of 3
(3,066 Views)
It may be an issue with those particular functions. I would try using the fopen and fclose commands from ansi.h or the inp and outp functions that are specifically for I/O space access.
Jeremy L.
National Instruments
Message 2 of 3
(3,050 Views)
I tried fopen and fclose commands, which resulted in an error on fopen with no printing at all. Because of this, I ended up looking into the printer parallel port driver and updating it. This resulted in the original openfile, closefile commands working.

Thanks
0 Kudos
Message 3 of 3
(3,040 Views)