Clear CF data

Overview

The easiest way to clear the CF card is to extract it from the mCCNC (power off first !), insert it in a card reader and delete the directories and only the directories from a file explorer. However, when no card reader is available or the mCCNC is operated remotely, this is not possible. The procedure detailed hereafter applies when the mCCNC is attached to a Linux box.

The data on the mCCNC flash disk are organized in subdirectories under C:\, making it more complicated than a mere del *.dat to clear the data. To do so, you will have to :
  1. create a file, listing all the directory names you want to delete
  2. use the Bash script mk-clrtree to create a custom PicoDOS batch file
  3. transfer the batch file to the mCCNC flash disk and run it from the PicoDOS prompt.

Create the directory list

Connect to the mCCNC, capturing the output :

$ minicom -C capture.txt ccn

From the PicoDOS prompt, list all directories, and only directories, in a bare format :

C:\>dir /ad /b

Exit Minicom. Now, there should be a capture.txt file in the current directory, containing all that you saw in the PicoDOS shell. But it needs some clean-up. Edit the file, and remove all the lines before and after the directory listing, as well as all empty lines, including the last line.

Example directory listing :

14-03-03
14-03-04
14-03-05
14-03-06
14-03-07
14-03-08
14-03-09
14-03-10

Create the PicoDOS batch file

It's as simple as :

mk-clrtree capture.txt > clrtree.bat

Check the file, to make sure you're not going to delete important stuff.

Transfer the PicoDOS batch file to the mCCNC flash disk

Connect to the mCCNC with Minicom and put it in capture mode. At the PicoDOS prompt, type :

C:\>capture clrtree.bat

In another Linux terminal, send the batch file to the mCCNC :

$ cat clrtree.bat > /dev/ttyS0

Return to the PicoDOS shell, and type Ctrl+C to exit the capture mode.

Note : if the CompactFlash has 0 byte free, PicoDOS won't be able to capture the file from the PC. Clear one or two directories first.

Running the batch file

At the PicoDOS prompt, type :

C:\>clrtree

PicoDOS may prompt for every directory, before deleting the files. You can hit the 'Y' key repeatedly (10-20 times) to try to make the process a bit faster... In any case, the whole process will take a few minutes.

When you're done, it is safe to delete the batch file :

C:\>del clrtree.bat