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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to send data through COM1... 2

Status
Not open for further replies.

alwi

Programmer
Aug 17, 2002
10
ID
Hi All,
I have some code in QBASIC to open drawer through COM1...

OPEN "COM1:300,N,8,1"
FOR RANDOM AS #1
PRINT #1,"0000000000"

How can I write code in VFP ....

Alwi
 
Alwi,
Welcom to Windows - DOS code that directly accesses hardware normally won't work reliably.

Some sample code for accessing serial data in VFP using MSCOMM32 can be found in the following:
- HOWTO: Receive from the Serial Port by Using MScomm32.ocx.
Also useful may be
- HOWTO: Send to the Serial Port by Using Mscomm32.ocx.
And of course,
- HOWTO: Transmit and Receive Binary Data using MSCOMM32.

If MSCOMM32 doesn't provide you with enough control, you'll need to find another 3rd party control to handle the serial communication. Remember that in the Windows environment, it controls the I/O ports - you can't do it directly - especially in WinNT, Win2000 and XP.

Rick
 
Thank you for the responses Rick and Mike Gagnon.
 
The MS links in Rick's reply state that this only applies to Win95 or NT OSs.

I still have the challenge of opening cash drawers. I send multiple CHR(7) string to COM1 but string gets sent to printer instead.

I would appreciate any advice, soltions or code snippets that will let me open the cash drawer by COM or USB.

Thanks,
Tony
 
tondi

May I suggest you start your own thread on this matter.

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
I solved this problem by creating a .txt file containing the required CHR ( in this case CHR[28] ) and copying it to the printer port.

Code:
! copy opentill.txt to LPT1

Keith
 
Rondi,
While the articles only reference Win95 and NT, it's only because they were current when the articles were written. They apply as well to Win98, SE, ME, 2000, XP, 2003!

Rick
 
Sorry Mike,
My question seemed to me in line with the thread.
This has been an ongoing challenge for me and am looking everywhere for a solution. With all the POS systems on the market I find it incredible there is not a solution for popping open cash drawers with serial or USB connections using VFP8 app on Win2k or XP systems.
 
tondi,

You may try using the site's Keyword Search feature...I just put in "cash drawer" and used exact phrase option and got a number of hits, including some with POS right in the title. If you've already looked at all of those threads, then disregard.

Mike is right however, though your problem may have a solution that depends on sending data through a serial port, it does deserve it's own thread given the specific nature of the technology involved...you may decide to just add onto one of those threads that you find with the keyword search also, as some of the ground will already be covered and everyone can benefit from the work on this problem already done.

boyd.gif

 
Do you by chance have printing captured to lpt1 from the comm port?

Anyway, here's a brief example of what should work using the mscomm control:
Code:
WITH thisform
    .oComm.commport = 1   &&... com1
    .oComm.settings = "9600,n,8,1"
    .oComm.portopen = .T.
    .oComm.Output(CHR(7))
    &&... may or may not need the next line
    .oComm.Output(CHR(13) + CHR(10))  
ENDWITH

-Dave Summers-
[cheers]
Even more Fox stuff at:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top