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!

Sending data using MSCOMM

Status
Not open for further replies.

Borgrail

Programmer
Nov 26, 2009
5
FR
Hi,

I am still trying to get a VFP6 application to send data via MSCOMM. I would like to be able to test it using virtual comports and HyperTerminal.
Problem - doesn't seem to work with virtual comports. There's no problem using VB, so why doesn't it work with VFP?

Stephen
 
Maybe you could clarify a little. What sort of virtual comm ports are you using?
I have a USB->Serial converter I am using which employs serial ports 3 through 6. I can communicate just fine with various serial devices successfully using the MSCOMM control.


-Dave Summers-
[cheers]
Even more Fox stuff at:
 
Hi,

That's promising. The type of virtual comport I'm referring to is com0com. I'm trying to get VFP to send to hyperterminal - it's all on the same computer. I can get it to work on a Visual Basic program but I'd prefer to use VFP if possible.

 
If that emulator works fine with VB, then it should work just fine with VFP. I haven't worked with VB much at all, but I'm guessing the only difference in this case may be the way VB handles system events.

That said, when you say it doesn't work with VFP, what is it that doesn't work? Are you getting an error of some sort? Does it just seem to hang? No bits getting passed? Is the get/put timing off? Do you have an actual serial device such as a printer or modem you can hook up on a physical comm port to verify it's not the code causing issues?


-Dave Summers-
[cheers]
Even more Fox stuff at:
 
The settings for MSCOMM in the VB version are standard as are those in VFP. i.e. I haven't messed with them.

When I send, it (VFP)seems to do something but nothing appears in the HyperTerminal window.

I know there is some data in the output command line. So am a bit baffled at the moment. I'll perhaps have another look at it over the weekend.
 
The settings for MSCOMM in the VB version are standard as are those in VFP. i.e. I haven't messed with them.

When I send, it (VFP)seems to do something but nothing appears in the HyperTerminal window.

I know there is some data in the output command line. So am a bit baffled at the moment. I'll perhaps have another look at it over the weekend. Perhaps try using the modem.
 
As I alluded to in my prior post, it may be all in the way VB handles system events.
What I mean by that is especially with VFP 6 as opposed to later versions, you may have to add a DOEVENTS, maybe even paired with an INKEY(.1), to get VFP to force the 'output' event.
You may also need to change the AutoYield setting somewhere in your code.
Maybe a sample of your code would help.

Here is a snippet I have in the OnComm event of my MSCOMM control to send ACK when I receive an inquiry:
Code:
*... if we get a ENQ, send ACK
CASE ASC(cInString ) = nENQ
   THIS.OUTPUT = CHR(ACK)
   DOEVENTS
   x = INKEY(.1, 'HM')


-Dave Summers-
[cheers]
Even more Fox stuff at:
 
Hi,
OK Panic over! Figured it out! In the VB program it sends a null character at the beginning of each string. Try and do that in Foxpro and it thinks it's a null string and sends nothing, even though you can see the contents of the string in the debugger.

Now whether or not the ultimate recipient piece of hardware actually needs a null character is another matter. All I can say at the moment is that the data that appears in Hyperterminal from both programs looks identical.

I will perhaps know more a couple of days time.
 
Glad to hear you made progress.
In another one of my apps I need to send a two character message length in the first two bytes of my message, so I understand your pain.
You can do that easy enough though by just outputting a CHR(0) then the rest of your data. Something like:

THIS.OUTPUT = CHR(0) + cMyString



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

Part and Inventory Search

Sponsor

Back
Top