Friday, July 18, 2008

Get Data Temperature Sensor with VFP

This sample VFP code for read data from temperature sensor :

*** Com1 setting = "9600,n,8,1"
thisform.MsCom.settings = "9600,n,8,1"
thisform.timer1.Interval = 1000


** SENSOR 01
VAL_01 = ASC(substr(thisform.MsCom.Input,5,5))
thisform.text1.Value = VAL_01

** SENSOR 02
thisform.MsCom.Output = '02R;'
VAL_02 = ASC(substr(thisform.MsCom.Input,5,5))
thisform.text2.Value = VAL_02

** SENSOR 03
thisform.MsCom.Output=':03R;'
VAL_03 = ASC(substr(thisform.MsCom.Input,5,5))
thisform.text3.Value = VAL_03

** SENSOR 04
thisform.MsCom.Output=':04R;'
VAL_04 = ASC(substr(thisform.MsCom.Input,5,5))
thisform.text4.Value = VAL_04

** SENSOR 05
thisform.MsCom.Output=':05R;'
VAL_05 = ASC(substr(thisform.MsCom.Input,5,5))
thisform.text5.Value = VAL_05

thisform.MsCom.inBufferCount = 0
thisform.MsCom.Refresh

No comments: