#roloFlash 2, v07+
! ***************************************************************************
! *
! * script for copying:
! * from: SD-card /TO_RF/RUN_V07.BIN
! * to: roloFlash flashDisk RUN_V07.BIN
! *
! * Copyright (C) 2009-2025 by halec embedded solutions
! *
! ***************************************************************************
! Green running light from LED 1 to LED 4 -> symbolizes script processing
! (Data transfer direction: write)
! (LED 5 is kept free for display of "Done")
led_runningLight 1, 4, COLOR_GREEN, 200
! ---- Preparations ----
! Delete old log file, if present
f = "LOG.TXT"
if fs_fileExists(0,f)
fs_remove 0, f
endif
procedure copyFile fsSrc, filenameSrc, fsDst, filenameDst
dataSize = fs_fileSize(fsSrc, filenameSrc)
fs_create fsDst, filenameDst, dataSize
src = fs_open(fsSrc, filenameSrc)
dst = fs_open(fsDst, filenameDst)
blockSize = 512
filePos = 0
do while dataSize > 0
mySize = blockSize
if mySize > dataSize
mySize = dataSize
endif
a = fs_read(src, filePos, mySize)
fs_write dst, filePos, a
filePos = filePos + mySize
dataSize = dataSize - mySize
loop
fs_close dst
fs_close src
end
! -- copy "RUN_V07.BIN" from SD-card (folder TO_RF) to FlashDisk (root folder):
copyFile SDCARD, "TO_RF/RUN_V07.BIN", FLASHDISK, "RUN_V07.BIN"
! ---- Check for possibly occurred exceptions, write ----
! ---- evaluation to log file and signal it via LEDs ----
catch exception
print "Duration [ms]: ", sys_getSystemTime(), "\r\n"
catch dummyException ! If the last print throws an exception
if exception <> 0
! There has been an error, record the error in LOG.TXT
print "ERROR: Exception ", exception
! Throw exception again, after it has been caught. As a result, the number
! of the exception gets displayed via LED blink codes. The blink codes
! are documented in the manual, chapter "Meaning of LED Codes", subchapter
! "Exception has Occurred"
throw exception
else
! No errors: write to log file and switch LED 5 to green
print "Script ran successfully.\r\n"
led_on 5, COLOR_GREEN
endif