Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Programto send characters using a serial port to open a cashdraw 2

Status
Not open for further replies.

VicGarra

Programmer
Jun 6, 2001
6
AU
I have tried using set printer to com2 etc - but no luck.
I am at a loss for what seems to me to be a simple job.
Any help would be greatly apprecieted
 
Despite FPW2.6 help saying it cannot be done,
I have had some success with the following code :
** assign value 'COM1' or 'COM2' to nComport
cashdrawer = FOPEN(nComport,11) && write, unbuffered
IF cashdrawer = -1
WAIT WIND NOWAIT 'Cannot Open Cash Drawer'
RETURN
ENDIF
writeok = FWRITE(cashdrawer,'@') && any char should do
IF writeok = 0
WAIT WIND NOWAIT 'Cannot Open Cash Drawer'
ENDIF
=FCLOSE(cashdrawer)

Somtimes, though I get an error ' Cannot write to device COM2'
Can anyone help ?
 
Andrew,
Let's see, the documentation says it can't be done, and it sometimes doesn't work <humm>. I think you'd simply be glad when it does!

Remember that most (all?) BIOS/motherboards piggyback the COM1/COM3, and COM2/COM4 interrupts, so if you've cot something assigned to COM4, it may be causing problems on COM2.

Rick
 
Thanks for that,Rick - I've had a look at the configuration of ports of 4 different machines and tried removing some or all of them (interestingly I can disable a port and yet still open it though not always write to it ) and checking piggy backing of interrupts, drivers, resources etc etc and still get inconsistent results. On 1 machine, no matter what I do, I can write successfully every time, other machines may let me open a port but won't write to it. It seems there IS a consistency with different flavours of FoxPro though - If it won't work in FPW26, it won't work in FPDOS25 OR VFP6. Still a bit of a mystery. I'll keep trying.
Andrew
 
Ok, here is a bit of code out of our invoicing module
for firing a cash draw... (foxpro for dos)

Fires 2 Different ways.... If cm_getreg(&quot;POS&quot;) = &quot;O&quot;
is firing though an OKIPos 80 Thermal receipt printer
and the other is firing though a star receipt printer..
(star SP300's & TSP 300's) or via a com kicker... note: com kickers seem to need a charge before going into fox.... i.e. in the autoexec.bat echo ^G> COM1 or something like that to do the first fire...

also you may need to set the com port speed up using the
mode command in dos... (don't know if it is needed for the
cash draw but is needed to print to our receipt printers)

Zim

********************************************************

Procedure OpenDrawer

* Open the cash drawer. Attaches as a printer then sends Ctrl-G to open
* the drawer

m.currprint = SYS(6)
set print to (m.cashdrawer)
IF SYS(13) <> &quot;OFFLINE&quot;
If cm_getreg(&quot;POS&quot;) = &quot;O&quot;
??? chr(27)+'p'+chr(0)+&quot;AA&quot;
Else
??? CHR(7)
Endif
ELSE
?? CHR(7)

WAIT &quot;Cannot open Cash Drawer, Please Check Connections and Power&quot; WINDOW
ENDIF
SET PRINTER TO (m.currprint)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top