With the generous assistance of Trev, I have a script that I use to compile the current source code and, assuming no errors are found, program a target device using the NSDSP programmer. The script automatically detects the #Chip type and then passes this to the command line utility (nsprog) provided by NS. This script requires that it is placed into the same directory as your GCB compiler (gcbasic) and that the NS utility (nsprog) is also located in the same directory. Trev gave me lots of advice on making this more flexible by searching for the GCB installation directory, but this failed to work correctly for me.
I have saved this script as 'MakeHex_Burn.sh' and I call it from the Geany IDE using this:
/Users/mkstevo/GreatCowBasic/makehex_burn.sh "%f" "%d"
In Geany the parameters "%f" and "%d" are replaced by Geany with the current filename, and the directory path to that file.
Script:
#!/bin/bash##Version0.95.002##AdaptedforuseonLinuxfrommakeHEX.bat.NottobeusedonWindows.##Youcanadaptthisfiletoyourneedsincludingremovingthe.shextensionforconvenience.##Inthisscript,$1getsreplacedwithwhateveryouenterfor<sourcefile>onthecommandline.#$0containsthepathtothedirectorycontainingthisscript.#Ifthislocationalsoincludesboththegcbasicandnsprog#executables,thisscriptshouldbeabletolocatethemcorrectly.TIMEFORMAT='Compilation and programming time: %Rs'time{basename=${0##*/}#installdir=$(dirname$(whichgcbasic))#Didn't work for me?#installdir=/Users/mkstevo/GreatCowBasic#Staticaddressinstalldir=`echo"$0"|rev|cut-d"/"-f2-|rev`echo"Installation directory assumed to be: "$installdir#DynamicaddressdirName=${2}/hex_file=$(basename"$1"|rev|cut-d"."-f2-|rev).hexhtml_file=$(basename"$1"|rev|cut-d"."-f2-|rev).htmlif[$#-ne2];thenecho"Usage: $basename <sourcefile> <path\directory> in Geany use ''"%f"'' ''"%d"'' (double quotes) "echo"Example: $basename myfile.gcb /my_Path/my_Directory/"echoexit1fiout_name=$(basename"$1"|cut-d.-f1).hex#NoteHEXsuffix${installdir}/gcbasic/NP/K:A/v/A:GCASM"${1}"Err=$?if[$Err-eq0];thenecho"No compilation errors found. Continuing with device programming process."elseecho"ERROR running ${0} with parameters: ${*}"echoecho"Error during compile. Error: ($Err) Skipping device programming."exit${Err}fi#ExtractPICdevicenamefromhtmlfiledevice_name=`grep"Chip Model""${dirName}${html_file}"`device_name=PIC`echo${device_name}|cut-d" "-f3|cut-d"<"-f1`#Programdevice${installdir}/nsprogp-h-d"${device_name}"-i"${hex_file}"Err=$?if[$Err-ne0];thenecho"Error: ($Err) running nsprog with parameters: p -h -d ${device_name} -i ${hex_file}"exit${Err}fi##---editEND----------------------------------------------}
If you copy and paste the script contents into an existing script file, be sure to change the command that invokes it to reflect the filename of the script.
The -h parameter selects High Voltage Programming for the NSDSP programming interface. If you do not want to use HVP, remove the -h.
Should anyone else be using Geany (or SynWrite) on the Mac, to allow the IDE to correctly locate any errors found in the source code on compile, the error Regular Expression should be set to:
(?P<file>[^(]+)\((?P<line>\d+)
Hope this helps someone.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
With the generous assistance of Trev, I have a script that I use to compile the current source code and, assuming no errors are found, program a target device using the NSDSP programmer. The script automatically detects the #Chip type and then passes this to the command line utility (nsprog) provided by NS. This script requires that it is placed into the same directory as your GCB compiler (gcbasic) and that the NS utility (nsprog) is also located in the same directory. Trev gave me lots of advice on making this more flexible by searching for the GCB installation directory, but this failed to work correctly for me.
I have saved this script as 'MakeHex_Burn.sh' and I call it from the Geany IDE using this:
/Users/mkstevo/GreatCowBasic/makehex_burn.sh "%f" "%d"
In Geany the parameters "%f" and "%d" are replaced by Geany with the current filename, and the directory path to that file.
Script:
If you copy and paste the script contents into an existing script file, be sure to change the command that invokes it to reflect the filename of the script.
Note that on the line:
The -h parameter selects High Voltage Programming for the NSDSP programming interface. If you do not want to use HVP, remove the -h.
Should anyone else be using Geany (or SynWrite) on the Mac, to allow the IDE to correctly locate any errors found in the source code on compile, the error Regular Expression should be set to:
Hope this helps someone.