diff options
author | Siddharth11235 | 2019-09-03 18:09:16 +0530 |
---|---|---|
committer | Siddharth11235 | 2019-09-03 18:09:16 +0530 |
commit | b4b6aa36e3486a3544acc52419149b5671f841e9 (patch) | |
tree | 66c1783158f23e6d21c77324156fc57e18d4ac67 /Modelica-Arduino-MDD_Arduino_Revised/MDD_build/servo/servo_pot.sh | |
parent | f5266f634f4fb4fd39933a83551a01cf446256b8 (diff) | |
download | OpenModelica_HIL-master.tar.gz OpenModelica_HIL-master.tar.bz2 OpenModelica_HIL-master.zip |
Diffstat (limited to 'Modelica-Arduino-MDD_Arduino_Revised/MDD_build/servo/servo_pot.sh')
-rwxr-xr-x | Modelica-Arduino-MDD_Arduino_Revised/MDD_build/servo/servo_pot.sh | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/servo/servo_pot.sh b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/servo/servo_pot.sh new file mode 100755 index 0000000..41f9d90 --- /dev/null +++ b/Modelica-Arduino-MDD_Arduino_Revised/MDD_build/servo/servo_pot.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_servo_pot.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_servo_pot.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 servo_pot_main.c -o servo_pot -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 servo_pot servo_pot.hex +if [ $? -ne 0 ]; then + exit 1 +fi +avrdude -F -V -c arduino -p ATMEGA328P -P $port -b $b_rate -U flash:w:servo_pot.hex +if [ $? -ne 0 ]; then + exit 1 +fi
\ No newline at end of file |