فهرست منبع

Added script for uploading text file. Updated syncCfiles script.

bart 7 ماه پیش
والد
کامیت
da7bf6bf21
3فایلهای تغییر یافته به همراه40 افزوده شده و 11 حذف شده
  1. 1 0
      .gitignore
  2. 17 11
      BCC/syncCfiles.sh
  3. 22 0
      Programmer/sendTextFile.sh

+ 1 - 0
.gitignore

@@ -37,4 +37,5 @@ BCC/*.out
 BCC/bcc
 Programmer/code.list
 Programmer/code.bin
+Programmer/wordfile
 .vscode/

+ 17 - 11
BCC/syncCfiles.sh

@@ -1,8 +1,6 @@
 #!/bin/bash
 
-# script to sync all C files in UserBDOS/ to /C/SRC/ on FPGC
-# assumes the subdirectories already exist. In theory a mkdir command could be added
-#  (mkdir does nothing if the directory already exists)
+# script to sync all C files in UserBDOS/ to /c/src on FPGC
 
 MAINPATH=$(pwd)
 
@@ -10,19 +8,27 @@ echo $MAINPATH
 
 cd userBDOS
 
+# Go to root directory
 echo "clear" | python3 "$MAINPATH/../Programmer/sendCommand.py"
-echo "cd" | python3 "$MAINPATH/../Programmer/sendCommand.py"
-echo "clear" | python3 "$MAINPATH/../Programmer/sendCommand.py"
+echo "cd /" | python3 "$MAINPATH/../Programmer/sendCommand.py"
+
+# Create directories
+echo "mkdir c" | python3 "$MAINPATH/../Programmer/sendCommand.py"
+echo "mkdir c/src" | python3 "$MAINPATH/../Programmer/sendCommand.py"
 
 for i in $(find . -type f -print)
 do
     FNAME=$(basename $i)
-    DIR=$(dirname $i | cut -c 2-)
+    DIR="/c/src$(dirname $i | cut -c 2-)"
+
+    # Create directory
+    echo "mkdir $DIR" | python3 "$MAINPATH/../Programmer/sendCommand.py"
 
-    echo "sending $DIR/$FNAME"
-    # move to directory
-    echo "cd /C/SRC$DIR" | python3 "$MAINPATH/../Programmer/sendCommand.py"
-    # send file
-    python3 "$MAINPATH/../Programmer/netUpload.py" "$i" "$FNAME"
+    # Move to directory
+    echo "cd $DIR" | python3 "$MAINPATH/../Programmer/sendCommand.py"
+    
+    # Send file
+    cd $MAINPATH/../Programmer
+    sh sendTextFile.sh $MAINPATH/userBDOS/$i
 
 done

+ 22 - 0
Programmer/sendTextFile.sh

@@ -0,0 +1,22 @@
+#!/bin/bash
+
+if [ "$1" == "" ]
+then
+    echo "No file to send"
+    exit 1
+fi
+
+echo "Converting $1 to wordfile"
+
+# Get base name of file
+filename=$(basename -- "$1")
+
+xxd -p -c 1 $1 | sed 's/\(..\)/000000\1/g' | xxd -r -p > wordfile
+
+echo "Sending wordfile to FPGC"
+python3 netUpload.py wordfile $filename
+
+echo "File sent"
+
+# Clean up
+rm wordfile