LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

serial printer works in debugmode does not work in released

Hi,
I am working with serial printer and I can print label in debug mode but in rrelease mode my printer does not print label.
Here is what I am using...
 
 size = strlen(read_file);  //read_file is a char array.
 
 written = ComWrt (PRINTER_PORT, read_file, size);    //print prints 2 lables if size-3 is used
Printer is intermec easycoder PM4i.
 
Any help?
 
Thanks.
CVI 2010
LabVIEW 2011 SP1
Vision Builder AI 2011 SP1
0 Kudos
Message 1 of 7
(3,854 Views)
Forgot to mention that read_file array size is appr. 6000+ characters.
Thanks.
CVI 2010
LabVIEW 2011 SP1
Vision Builder AI 2011 SP1
0 Kudos
Message 2 of 7
(3,848 Views)
The obvious place to start is to see if read_file is null terminated.  If you print out the value of size in debug and release mode, does it change?  If it does, then the initialization of the read_file array to zero by debug mode is providing the null termination of read_file required for strlen() to work correctly.
0 Kudos
Message 3 of 7
(3,827 Views)

Hi Sheetal,

Well In debug mode things work at a slower rate than release mode. So considering you are writing to the serial port....there could be time outs occuring or if u are using wait loops or anyting.....in release mode these are executed at a faster rate.

My suggestion from over the top is you should get a port monitor software, capture the port u using, have a breakpoint write after that line.....and observe what was sent out....

Hope it helps....if u can provide more parts to ur code that could help narrow the problem.

k1_ke

0 Kudos
Message 4 of 7
(3,812 Views)

Thanks for your response.

It is very strange. It some time works in release mode and some time does not. Even if I don't change any thing in my code. I am still investigating this problem and post solution if I find one!

 

Thanks.
CVI 2010
LabVIEW 2011 SP1
Vision Builder AI 2011 SP1
0 Kudos
Message 5 of 7
(3,780 Views)

Ok. Here is what I found. It still does not work in release mode 

Here is my code.

/////////////////////////////////////////////////////////////////////////////////////////////////////////
 FlushInQ (PRINTER_PORT);
 FlushOutQ (PRINTER_PORT);
 
 size = strlen(read_file);  //size is > 6000 bytes
 
 written = ComWrt (PRINTER_PORT, read_file, size);
 

 if(written != size)
 {
  Error(__FILE__, __FUNCTION__, __LINE__, "Printer Bytes written is not same as filesize FAILED");
  Write_Status("Printing Error FAILED");
  Write_Message("Printing Error FAILED");
  return FAIL;
 }

return PASS;
//////////////////////////////////////////////////////////////////////////////////

I used serial port monitor and in release mode I do not see any data but in debug mode I do see data. So problem is on PC side not on printer side.

In release mode I do not get error. that means bytes written is same as size.

It this functions always returns PASS.

 

 

Thanks.
CVI 2010
LabVIEW 2011 SP1
Vision Builder AI 2011 SP1
0 Kudos
Message 6 of 7
(3,762 Views)

I think I found problem.

here is my code where I read a file.

 stream = fopen (PRINT_FILE_MASTER, "r");  
 
 written = fread (read_file, 1, size, stream);
 
 fclose(stream);

if PRINT_FILE is    "print.txt"   it does not work in release mode. my project location is Z:\ .

But If I use "Z:\print.txt"   it works.. in release mode.

Thanks.
CVI 2010
LabVIEW 2011 SP1
Vision Builder AI 2011 SP1
0 Kudos
Message 7 of 7
(3,756 Views)