Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Ron Getgen
  Where is Ron Getgen?
 Pennsylvania - United States
 Ron Getgen
Subject: Reading Serial Port in VFP 9.0
Thread ID: 66913 Message ID: 66913 # Views: 24 # Ratings: 0
Version: Visual FoxPro 9 Category: Active X Controls & OLE Automation
Date: Thursday, April 28, 2005 9:26:14 PM         

I am having trouble reading information collected from a scale connected to COM1: (Windows XP Professional). There is no problem writing data (the fputs statement works fine). But the fread do loop sits and waits.. and waits.. and waits, virtually tying up all resources on my computer and never populating the cScaleweight variable. If I remove the do loop and just try to read one byte using only the fread(nHandle,1) statement, I get a timeout error.
How does one read serial data directly coming in the COM port without having to purchase an add-on library?

* Open Connection to scale
nHandle = fopen("com1:9600,n,8,1",2)

* Send Command
nRet = fputs(nHandle,"GIVE_WEIGHT")

* Read Result
nHandle = fopen("com1:9600,n,8,1",0)
cScaleValue = ""
do while true
cRead = fread(nHandle,1)
if cread = chr(13)
cScaleValue = cScaleValue + cRead



Reading Serial Port in VFP 9.0 Posted by Ron Getgen @ 4/28/2005 9:26:14 PM
RE: Reading Serial Port in VFP 9.0 Posted by Eric den Doop @ 4/28/2005 9:31:24 PM