Hello,
I have a basic script that generates a file based on tag history. This part seems to be working fine. The issue comes when I am trying to move the file from local usr directory(usr/Reports) to the SD card (usr/sdext/Reports). I see “uact-Export block descriptor writing failed (file open)” when the file copy is scheduled to occur. Any help would be greatly appreciated!!
The code used to generate the one of the files:
///////////////////////////////////////////////////////////////////////
//Temperature Report Functions
///////////////////////////////////////////////////////////////////////
Function SttTempReport()
PRINT “Creating Temperature File…”
//Make sure files are closed prior to reading
CLOSE 1
CLOSE 2
//Open tag history and create daily file
OPEN “exp:$dtHT $ftT $flA $st_m15 $et_s0 $in1” FOR TEXT INPUT AS 1
OPEN “file:/usr/Reports/” + @GetCurrentTimeStamp$() + “TempReport.txt" FOR BINARY APPEND AS 2
//Read history and create first row containing headers
IF EOF 1 THEN GOTO $ReadDone
Line$ = GET 1
IF Line$ = “” THEN GOTO $ReadDone
PosStart% = INSTR 1, Line$, “;”
PosStart% = PosStart% + 1 //Remove ; as well
Keep$ = Line$(PosStart% TO LEN(Line$))
Tab$ = CHR$ 9
Temp$ = @ReplaceStr$(Keep$ , “;”, Tab$)
Temp$ = @ReplaceStr$(Temp$ , "”, " ")
Temp$ = @ReplaceStr$(Temp$ , “TimeStr”, “Date”)
PUT 2, Temp$
$ReadDone:
CLOSE 1
CLOSE 2
PRINT “Created Temperature File”
EndFN
//
Function BldTempReport()
//Check if its time to create a new file
y% = GETIO “INT_MOVETEMP”
IF (y% = 1) THEN
SETIO “INT_MOVETEMP”, 0
@SttTempReport
ENDIF
PRINT “Temperature file processing…”
//Make sure files are closed prior to reading
CLOSE 1
CLOSE 2
//Open tag history and create daily file
OPEN “exp:$dtHT $ftT $flA $st_m15 $et_s0 $in5” FOR TEXT INPUT AS 1
OPEN “file:/usr/Reports/” + @GetCurrentTimeStamp$() + “_TempReport.txt” FOR BINARY APPEND AS 2
//Skip first header line
Line$ = GET 1
//Loop through the tag history
$ReadNext:
IF EOF 1 THEN GOTO $ReadDone
Line$ = GET 1
IF Line$ = “” THEN GOTO $ReadDone
PosStart% = INSTR 1, Line$, “;”
PosStart% = PosStart% + 1 //Remove ; as well
If PosStart% = 0 Then GOTO $ReadNext
Keep$ = Line$(PosStart% TO LEN(Line$))
PosEnd% = INSTR PosStart%, Line$, “;”
If PosEnd% = 0 THEN GOTO $ReadNext
DateOrig$ = Line$(PosStart% TO PosEnd%)
DateNew$ = CHR$ 34 + DateOrig$(13 TO 20) + " " + DateOrig$(8 TO 11) + “-” + DateOrig$(5 TO 6) + “-” + DateOrig$(2 TO 3) + CHR$ 34 + “;”
KeepNew$ = DateNew$ + Keep$(Len(DateNew$)+1 TO LEN(Keep$))
Tab$ = CHR$ 9
PUT 2, @ReplaceStr$(KeepNew$ , “;”, Tab$)
GOTO $ReadNext
$ReadDone:
CLOSE 1
CLOSE 2
PRINT “Temperature file processed”
//
EndFN
//
And this is the code used to move the files:
FUNCTION Move_Reports()
//Check if SD card is inserted or if there is enough space
SETSYS INF,“LOAD”
SDCardSize$ = GETSYS INF, “SDExtFree”
SDCardSize_Int% = Val SDCardSize$
Print SDCardSize_Int%
IF SDCardSize_Int% > 10000 THEN // 10 MB remains
//Check all directories exist and if not then create them
bF1 = FS “isDir”, “/usr/sdext/Reports”
bF2 = FS “isDir”, “/usr/sdext/Reports/Temperature”
bF3 = FS “isDir”, “/usr/sdext/Reports/Pressure”
bF4 = FS “isDir”, “/usr/sdext/Reports/Events”
IF (bF1 = -1) THEN FS “mkDir”, “/usr/sdext/Reports”
IF (bF2 = -1) THEN FS “mkDir”, “/usr/sdext/Reports/Temperature”
IF (bF3 = -1) THEN FS “mkDir”, “/usr/sdext/Reports/Pressure”
IF (bF4 = -1) THEN FS “mkDir”, “/usr/sdext/Reports/Events”
//Create File Names
F_NAME1$ = @GetYestTimeStamp$() + “_EventReport.txt”
F_NAME2$ = @GetYestTimeStamp$() + “_TempReport.txt”
F_NAME3$ = @GetYestTimeStamp$() + “_PressReport.txt”
//Check if source files exist
bFN1 = FS “isFile”, “/usr/Reports/” + F_NAME1$
bFN2 = FS “isFile”, “/usr/Reports/” + F_NAME2$
bFN3 = FS “isFile”, “/usr/Reports/” + F_NAME3$
//Check yesterdays file already exists
bFC1 = FS “isFile”, “/usr/sdext/Reports/Events/” + F_NAME1$
bFC2 = FS “isFile”, “/usr/sdext/Reports/Temperature/” + F_NAME2$
bFC3 = FS “isFile”, “/usr/sdext/Reports/Pressure/” + F_NAME3$
//Copy the Event Report
IF (bFN1 = 1) THEN
IF (bFC1 = -1) THEN
EBD_STRING$ = “$dtUF$uf/Reports/” + F_NAME1$
FILENAME$ = “/usr/sdext/Reports/Events/”+ F_NAME1$
WRITEEBD EBD_STRING$, FILENAME$
ActionID% = GETSYS Prg, “ACTIONID”
PRINT ActionID%
ENDIF
ENDIF
//Copy the Temperature Report
IF (bFN2 = 1) THEN
IF (bFC2 = -1) THEN
EBD_STRING$ = “$dtUF$uf/Reports/” + F_NAME2$
FILENAME$ = “/usr/sdext/Reports/Temperature/”+ F_NAME2$
WRITEEBD EBD_STRING$, FILENAME$
ActionID% = GETSYS Prg, “ACTIONID”
ENDIF
ENDIF
//Copy the Pressure Report
IF (bFN3 = 1) THEN
IF (bFC3 = -1) THEN
EBD_STRING$ = “$dtUF$uf/Reports/” + F_NAME3$
FILENAME$ = “/usr/sdext/Reports/Pressure/”+ F_NAME3$
WRITEEBD EBD_STRING$, FILENAME$
ActionID% = GETSYS Prg, “ACTIONID”
ENDIF
ENDIF
ELSE
LOGEVENT “EUM Card full or not present”, -1
ENDIF
ENDFN