I have a automation task that I am not able to figure out yet. I have two computers connected by a serial cable. One is networked and the other is stand alone (vision gage). I am having difficulties automating the task to monitor COM port #2, capture the contents and then save results to a text file called OGP Data.txt. The attached file is what I have modified from a existing script to get to where I am at and it does perform the task with the missing piece being that I want the script to constantly run or monitor Com port # 2 and save the text file without the user having to do anything after the initial startup.
;Receive.WAS
;*****************************************************************************
;* *
;* Receive.WAS *
;* This script file receives data from COM2 and saves it to download *
;* folder. *
;* *
;*****************************************************************************
;********************************************************************
;* GLOBAL VARIABLES *
;********************************************************************
string DownloadPath ;holds the download path
string TempFile ;holds file to be printed
;********************************************************************
;* Main () *
;* *
;* Called by: None *
;* Modifies globals: None *
;* Calls: Initialize(), Cleanup() *
;********************************************************************
proc main
integer XferProgress ;holds the transfer status
Initialize() ;init parameters
getfile ASCII TempFile ;download file using ASCII
XferProgress=$XFERSTATUS ;init transfer status
while XferProgress==1 ;while transfer in progress
yield ;yield CPU time
XferProgress=$XFERSTATUS ;update transfer status
endwhile
rxflush ;clear receive buffer
txflush ;clear transmit buffer
pause 2
if XferProgress==2 ;file transfer was successful
else
usermsg "Failed to download file, try again..."
Cleanup()
endif
endproc
;********************************************************************
;* Initialize () *
;* This procedure inits the Tempfile name and deletes if it is *
;* present on local harddrive *
;* Called by: main *
;* Modifies globals: TempFile *
;********************************************************************
proc Initialize
fetch dnldpath DownloadPath ;get the download path
strfmt TempFile "%s\OGP_Data.txt" DownloadPath ;set file name
if isfile TempFile ;if file is present
delfile TempFile ;delete it
endif
endproc
;Receive.WAS
;*****************************************************************************
;* *
;* Receive.WAS *
;* This script file receives data from COM2 and saves it to download *
;* folder. *
;* *
;*****************************************************************************
;********************************************************************
;* GLOBAL VARIABLES *
;********************************************************************
string DownloadPath ;holds the download path
string TempFile ;holds file to be printed
;********************************************************************
;* Main () *
;* *
;* Called by: None *
;* Modifies globals: None *
;* Calls: Initialize(), Cleanup() *
;********************************************************************
proc main
integer XferProgress ;holds the transfer status
Initialize() ;init parameters
getfile ASCII TempFile ;download file using ASCII
XferProgress=$XFERSTATUS ;init transfer status
while XferProgress==1 ;while transfer in progress
yield ;yield CPU time
XferProgress=$XFERSTATUS ;update transfer status
endwhile
rxflush ;clear receive buffer
txflush ;clear transmit buffer
pause 2
if XferProgress==2 ;file transfer was successful
else
usermsg "Failed to download file, try again..."
Cleanup()
endif
endproc
;********************************************************************
;* Initialize () *
;* This procedure inits the Tempfile name and deletes if it is *
;* present on local harddrive *
;* Called by: main *
;* Modifies globals: TempFile *
;********************************************************************
proc Initialize
fetch dnldpath DownloadPath ;get the download path
strfmt TempFile "%s\OGP_Data.txt" DownloadPath ;set file name
if isfile TempFile ;if file is present
delfile TempFile ;delete it
endif
endproc