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 wOOdy-Soft 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 and Receive text from COM port from VFP

Status
Not open for further replies.

dejanj

Programmer
Apr 22, 2002
25
AU
Hi All,


Are there any sample code i can use for sending AT commands to COM port and
receiving responses.

I want to send some text to COM port and wait for response i.e.

AT+CMGF=1
then wait for modem to respond with OK
then
AT+CSCA="045151511"
wait for OK

and so on...


I am using VFP 6 SP5 under NT 4.

Thanks

Dejan
 
Hi Dejan,

Try this:

Thisform.Olecontrol1.CommPort=1
Thisform.Olecontrol1.PortOpen=.T.
Thisform.Olecontrol1.InBufferCount=0
do case
case output
xtxt='Hello'
Thisform.Olecontrol1.Output=xtxt
case input
"In the procedure OnComm of the Olecontrol1"
xtxt=Thisform.Olecontrol1.Input
Thisform.Olecontrol1.InBufferCount=0
endcase

HTH,

Bogdan
 
Hi Bogdan,

Can you be more specific?
Where does the case structure goes?

Ok this goes in OLECONTROL1.init()

Thisform.Olecontrol1.CommPort=1
Thisform.Olecontrol1.PortOpen=.T.
Thisform.Olecontrol1.InBufferCount=0

...but what about the rest?

Do i need to have 2 OLECONTROLS on 1 form. One for Transmiting and one for receiving or just have 1 form with 1 OLECONTROL

PLease help.

Thanks

Dejan
 
Excuse me for the late response, but i've got to travel a while.

The fact is that i write that like a generic code so forget the do case:

&& This goes in the form.init() where you insert the Olecontrol1

Thisform.Olecontrol1.CommPort=1
Thisform.Olecontrol1.PortOpen=.T.
Thisform.Olecontrol1.InBufferCount=0

&& if you want to send data trough the Olecontrol1 this can goes to the form.activate or something like that
xtxt='Hello'
Thisform.Olecontrol1.Output=xtxt
&& if you want to receive data trough the same Olecontrol1 This goes in the procedure OnComm of the Olecontrol1 Olecontrol1.OnComm()
xtxt=Thisform.Olecontrol1.Input
Thisform.Olecontrol1.InBufferCount=0

&& in both cases you use the same Olecontrol

Bogdan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top