trevorhartman
asked on
sending files to COM
Hi,
I'm interfacing a thermal printer on COM3 via RS232. From the command prompt, this is all I need:
copy 0.txt COM3: /b
That obviously copies my file to COM3 in binary mode. Now, how do I do that in .NET? (I'm new to serial communications and have no idea how to do it in .net)
Thanks - Trevor
I'm interfacing a thermal printer on COM3 via RS232. From the command prompt, this is all I need:
copy 0.txt COM3: /b
That obviously copies my file to COM3 in binary mode. Now, how do I do that in .NET? (I'm new to serial communications and have no idea how to do it in .net)
Thanks - Trevor
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
yes, you can send anything to the printer. I take it you are talking about control-P ?? you can send any ascii character.
I've used this in the past to print to a receipt printer, which meant that I had to send certain escape sequences to switch fonts, and even to guillotine the paper after printing.
I'm sure this class will work for you.
I'm sure this class will work for you.
ASKER
great, thanks a lot for your help
ASKER
i got the class working, but it ONLY works if i send files to the printer... the test file i have been sending contains this string:
^P|9|1|405796171|YOUR ESTABLISHMENT|YOUR LOCATION|CITY / STATE / ZIP|TEST COUPON| |405796171|04/12/2005|12:0 2:21|TICKE T# X|FIFTY DOLLARS AND NO CENTS| |$50.00|Expires in 7 days|MACHINE# 0|405796171|^
i need to generate the string dynamically, so rather than create the string, write to file, send file, i want to just send the string directly. I used:
success = RawPrinterHelper.SendStrin gToPrinter ("\\\\plan ar\\FL", "^P|9|1|405796171|YOUR ESTABLISHMENT|YOUR LOCATION|CITY / STATE / ZIP|TEST COUPON| |405796171|04/12/2005|12:0 2:21|TICKE T# X|FIFTY DOLLARS AND NO CENTS| |$50.00|Expires in 7 days|MACHINE# 0|405796171|^");
but it doesn't work? any idea why?
thanks - Trevor
^P|9|1|405796171|YOUR ESTABLISHMENT|YOUR LOCATION|CITY / STATE / ZIP|TEST COUPON| |405796171|04/12/2005|12:0
i need to generate the string dynamically, so rather than create the string, write to file, send file, i want to just send the string directly. I used:
success = RawPrinterHelper.SendStrin
but it doesn't work? any idea why?
thanks - Trevor
maybe you have to pass a form feed ?
What happens if you just send "Hello" ??
What happens if you just send "Hello" ??
ASKER
doesn't do anything if i just send "Hello"... it has an embedded proprietary printer langauage, and "^p" is the print command, everything after is parameters that populate a ticket template stored in the printer.
ASKER
note: success returns true every time.. i think the printer is just not intepretting the string that is sent.. everything must be sent binary
ok, what if you send ^pHello ??
This works for me sending directly to a printer.
This works for me sending directly to a printer.
ASKER
the printer only accepts strings in a very strict format, it requries that all parameters be present. so "^pHello" doesnt do anything..
in the SendStringToPrinter, it is converting the string to ANSI text. do you know how i could convert it into binary instead? i think that is the problem.
in the SendStringToPrinter, it is converting the string to ANSI text. do you know how i could convert it into binary instead? i think that is the problem.
As far as I'm aware, ANSI is raw format.
You could always try this article.. it uses the same winspool function, but has an alternative way of calling it.
http://www.codeproject.com/useritems/pclprinting.asp
You could always try this article.. it uses the same winspool function, but has an alternative way of calling it.
http://www.codeproject.com/useritems/pclprinting.asp
ASKER
ok, thanks for the additional help on this one
ASKER
thanks - Trevor