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

Need to receive data from Serial Port

Status
Not open for further replies.

Shivaram

Programmer
Nov 18, 2001
3
0
0
MY
Hi

I need to receive the data from a weighing machine which sends in 15 characters alphanumeric format.

Kindly let me know the code in Foxpro for DOS or in C.

Thanks.
 
If you are running under DOS, then you may be able to use the low-level IO routines to open and read the appropriate COM: port. If you are running this under Windows, then it may not work, depending on the version and what else might be accessing the COM: port interrupts.

While I used some routines from Silverware in a number of old FPD programs, they went out of business a number of years ago. Any chance you can upgrade to VFP? The MSCOMM32.DLL makes this real easy.

Rick


 
Hi,

I had the same problem, I had some Data Terminals that I needed to get data from through serial port, What I did was, I made a Visual Basic Program to capture and save them to DBF. And I called it through FoxPro; you can do the same thing.

-Nuclear
 

if found those source that do the job:

* SLMISKL2.PRG BS"D.
* AT INIT:
* OLD: MODE COM2:9600,e,8
* !MODE COM2:1200,E,8
* OLD: F28 on machine must be set to 0

DO WEIGHT
RETURN


PROC Weight && READ DATA FROM MISKAL.
PRIVATE ALL
m.cOldDecimals = SET( 'DECIMALS')
SET DECIMALS TO 3
m.lExit = .F.
m.nWeight = -1
WAIT WINDOW '00.000' NOWAIT
DO WHILE !lExit .AND. INKEY() = 0
m.nFile = FOPEN( 'COM2', 12)
IF m.nFile > -1
=FPUTS( m.nFile, 'S')
wait wind 'put' nowait
m.cWeight = FGETS ( m.nFile)
m.cNumWeight = SUBSTR( m.cWeight, 4, 6)
m.cMotion = SUBSTR( m.cWeight, 2, 1)

IF LEN( m.cWeight) = 10
WAIT WINDOW m.cNumWeight NOWAIT
DO CASE
CASE m.cMotion = '0'
m.nWeight = VAL( m.cNumWeight)
IF m.nWeight > 0
m.lExit = .T.
?? CHR( 7)
ENDIF
CASE m.cMotion = '1'
ENDCASE
ENDIF
=FCLOSE( m.nFile)
ELSE
EXIT
ENDIF
ENDDO
IF m.nWeight = -1
WAIT WINDOW 'Error' NOWAIT
ENDIF
SET DECIMALS TO &cOldDecimals
M.I = m.nWeight
RETURN

* END SLMISKL2.PRG


i hope it will help.
eliezer.

yarpa@zahav.net.il
 
While this may work on a DOS or Win 9x workstation, have you tested it under Win NT / 2000 / XP?

Rick
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top