How do i print to my com printer?

New to FreeBASIC? Post your questions here.
Post Reply
porfirio
Posts: 154
Joined: Mar 17, 2006 11:54
Location: Portugal

How do i print to my com printer?

Post by porfirio »

Hi!

I want todo a small program to print to my com Printer

This is the printer i have:
Epson TM-U210
baudrate: 9600
parity:none
data_bits:8
stop_bits:1
Protocol:RTS/CTS
sequence to open Money Drawer:27,112,0,48,0,48

I want to be able to Open the Drawer and to print text into the paper, also feed out paper ( println )

Thanks in advance!
phishguy
Posts: 1201
Joined: May 05, 2006 16:12
Location: West Richland, Wa

Post by phishguy »

This example should work.

Code: Select all

dim as integer total = 5.97
open com "com1:9600,n,8,1,cd0,ds0" as #1 'change port if needed
if err then
   print "error opening port"
  sleep
 end
end if
sleep 500
print #1,chr$(27);chr$(112);chr$(0);chr$(48);chr$(0);chr$(48);
sleep 500
print #1,"Total purchase $";
print #1,using "###.##";total
sleep
porfirio
Posts: 154
Joined: Mar 17, 2006 11:54
Location: Portugal

Post by porfirio »

phishguy wrote:This example should work.

Code: Select all

dim as integer total = 5.97
open com "com1:9600,n,8,1,cd0,ds0" as #1 'change port if needed
if err then
   print "error opening port"
  sleep
 end
end if
sleep 500
print #1,chr$(27);chr$(112);chr$(0);chr$(48);chr$(0);chr$(48);
sleep 500
print #1,"Total purchase $";
print #1,using "###.##";total
sleep
Wow thank's, i have been messing with Open com but was not able to get it to work, now i understand what i was doing wrong

Just a small question...
This code would also work in linux too or it is just windows, if yes do i still use COM1 or i use the linux port name?
coderJeff
Site Admin
Posts: 4386
Joined: Nov 04, 2005 14:23
Location: Ontario, Canada
Contact:

Post by coderJeff »

Darn, I guess that's not on the doc pages.

"COM:" should map to "/dev/modem"
"COM1:" should map to "/dev/ttyS0"
"COM2:" should map to "/dev/ttyS1", etc
"/dev/whatever:" is unchanged.

So "COMn:" should be the cross platform compatible version. But if you test the other variations also, and they don't work, please let us know.
porfirio
Posts: 154
Joined: Mar 17, 2006 11:54
Location: Portugal

Post by porfirio »

coderJeff wrote:Darn, I guess that's not on the doc pages.

"COM:" should map to "/dev/modem"
"COM1:" should map to "/dev/ttyS0"
"COM2:" should map to "/dev/ttyS1", etc
"/dev/whatever:" is unchanged.

So "COMn:" should be the cross platform compatible version. But if you test the other variations also, and they don't work, please let us know.
Thank you!!

I had lots of headaches trying to do this, and it's so damn easy in FreeBasic :)

I am using it already for the app i created for open MoneyDrawer when i click a global shortcut
Its handy

Later i will try to find a way to use it an application i have doe in Java ( maybe using JNI or a single exe that prints from parameters )

Thanks again freebasic!!
Post Reply