summaryrefslogtreecommitdiff
path: root/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/dcmotor/dcmotor_both.sh
diff options
context:
space:
mode:
authorSiddharth112352019-09-03 18:09:16 +0530
committerSiddharth112352019-09-03 18:09:16 +0530
commitb4b6aa36e3486a3544acc52419149b5671f841e9 (patch)
tree66c1783158f23e6d21c77324156fc57e18d4ac67 /Modelica-Arduino-MDD_Arduino_Revised/MDD_build/dcmotor/dcmotor_both.sh
parentf5266f634f4fb4fd39933a83551a01cf446256b8 (diff)
downloadOpenModelica_HIL-master.tar.gz
OpenModelica_HIL-master.tar.bz2
OpenModelica_HIL-master.zip
Pushing entire Modelica HIL Tasks repoHEADmaster
Diffstat (limited to 'Modelica-Arduino-MDD_Arduino_Revised/MDD_build/dcmotor/dcmotor_both.sh')
-rwxr-xr-xModelica-Arduino-MDD_Arduino_Revised/MDD_build/dcmotor/dcmotor_both.sh61
1 files changed, 61 insertions, 0 deletions
diff --git a/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/dcmotor/dcmotor_both.sh b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/dcmotor/dcmotor_both.sh
new file mode 100755
index 0000000..762735b
--- /dev/null
+++ b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/dcmotor/dcmotor_both.sh
@@ -0,0 +1,61 @@
+#!/bin/bash
+clear
+if [ "$#" -ne 2 ]; then
+ echo "Usage: $0 port baudrate" >&2
+ exit 1
+fi
+
+re='^[0-9]+$'
+if ! [[ $1 =~ $re ]] ; then
+ echo "error: $1 -> Not a number" >&2; exit 1
+fi
+
+if ! [[ $2 =~ $re ]] ; then
+ echo "error: $2-> Not a number" >&2; exit 1
+fi
+
+b_rate=$2
+
+present=`pwd`
+unamestr=`uname`
+
+if [[ "$unamestr" == 'Linux' ]]; then
+ mdd_path=($(locate Modelica_DeviceDrivers/Modelica_DeviceDrivers/Resources/Include))
+ om_path=($(locate /usr/include/omc/c))
+ port="/dev/ttyACM$1"
+ omc --simCodeTarget=ExperimentalEmbeddedC runMDD_dcmotor_both.mos
+ if [ $? -ne 0 ]; then
+ exit 1
+ fi
+else
+ cd c:
+ om_path=($(dir -d OpenModelica*/include/omc/c/))
+ path_to_om="C:$om_path"
+ cd f:
+ mdd_path=($(dir -d */Modelica_DeviceDrivers/Modelica_DeviceDrivers/Resources/Include/))
+ if [ $? -eq 0 ]; then
+ path_to_mdd="F:/$mdd_path"
+ else
+ exit 1
+ fi
+
+ port="COM$1"
+ cd $present
+ omc --simCodeTarget=ExperimentalEmbeddedC run_dcmotor_both.mos
+ if [ $? -ne 0 ]; then
+ exit 1
+ fi
+fi
+
+avr-gcc -Os -std=c11 -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000UL -Wl,--gc-sections dcmotor_both_main.c -o dcmotor_both -I${mdd_path[0]} -I${path_to_om} -I${path_to_mdd} -I${om_path[0]}
+if [ $? -ne 0 ]; then
+ exit 1
+fi
+avr-objcopy -O ihex -R .eeprom dcmotor_both dcmotor_both.hex
+if [ $? -ne 0 ]; then
+ exit 1
+fi
+avrdude -F -V -c arduino -p ATMEGA328P -P $port -b $b_rate -U flash:w:dcmotor_both.hex
+if [ $? -ne 0 ]; then
+ exit 1
+fi \ No newline at end of file