<commit_before>#!/bin/bash
#
# Upload a PIC32 compatible application compiled to a .hex file to a device.
#
#    ./upload_hex.sh <path to hex file>
#
# This functionality is mostly copied from the Makefile so normal developers
# don't need to have that installed.
#

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
KERNEL=`uname`
HEX_FILE="$1"
PORT=$2

die() {
    echo >&2 "$@"
    exit 1
}

if [ ${KERNEL:0:7} == "MINGW32" ]; then
    OS="windows"
elif [ ${KERNEL:0:6} == "CYGWIN" ]; then
    OS="cygwin"
elif [ $KERNEL == "Darwin" ]; then
    OS="mac"
else
    OS="linux"
fi

if [ -z $PORT ]; then
    if [ $OS == "windows" ] || [ $OS == "cygwin" ]; then
        PORT="com4"
    else
        PORT=`ls /dev/ttyUSB* 2> /dev/null | head -n 1`
        if [ -z $PORT ]; then
            PORT=`ls /dev/tty.usbserial* 2> /dev/null | head -n 1`
            if [ -z $PORT ]; then
                die "No CAN translator found - is it plugged in?"
            fi
        fi
    fi
fi

if [ -z "$MPIDE_DIR" ]; then
    echo "No MPIDE_DIR environment variable found, will use standalone avrdude"
    if [ -z "$AVRDUDE" ]; then
        AVRDUDE="`which avrdude`"
    fi


    if [ -z "$AVRDUDE" ]; then
        die "ERROR: No avrdude binary found in your path"
    else
        echo "Using $AVRDUDE..."
    fi
else
    echo "Using avrdude from MPIDE installation at $MPIDE_DIR..."
    AVRDUDE_TOOLS_PATH="$MPIDE_DIR/hardware/tools"
    AVRDUDE="$AVRDUDE_TOOLS_PATH/avrdude"

    if [ ! -e "$AVRDUDE" ]; then
        # OS X and Windows MPIDE have different directory structure
        AVRDUDE="$AVRDUDE_TOOLS_PATH/avr/bin/avrdude"
    fi
fi

if [ -z $AVRDUDE_CONF ]; then
    if [ $OS == "cygwin" ]; then
        # avrdude in cygwin expects windows style paths, so the absolute
        # path throws a "file not found" error
        AVRDUDE_CONF="conf/avrdude.conf"
    else
        AVRDUDE_CONF="$DIR/conf/avrdude.conf"
    fi
fi
<commit_msg>Require WinAVR's avrdude in Cygwin - MPIDE version missing a library.<commit_after>#!/bin/bash
#
# Upload a PIC32 compatible application compiled to a .hex file to a device.
#
#    ./upload_hex.sh <path to hex file>
#
# This functionality is mostly copied from the Makefile so normal developers
# don't need to have that installed.
#

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
KERNEL=`uname`
HEX_FILE="$1"
PORT=$2

die() {
    echo >&2 "$@"
    exit 1
}

if [ ${KERNEL:0:7} == "MINGW32" ]; then
    OS="windows"
elif [ ${KERNEL:0:6} == "CYGWIN" ]; then
    OS="cygwin"
elif [ $KERNEL == "Darwin" ]; then
    OS="mac"
else
    OS="linux"
fi

if [ -z $PORT ]; then
    if [ $OS == "windows" ] || [ $OS == "cygwin" ]; then
        PORT="com4"
    else
        PORT=`ls /dev/ttyUSB* 2> /dev/null | head -n 1`
        if [ -z $PORT ]; then
            PORT=`ls /dev/tty.usbserial* 2> /dev/null | head -n 1`
            if [ -z $PORT ]; then
                die "No CAN translator found - is it plugged in?"
            fi
        fi
    fi
fi

if [ -z "$MPIDE_DIR" ]; then
    MPIDE_DIR="dependencies/mpide"
fi

if [ $OS == "windows" ] || [ $OS == "cygwin" ]; then
    # avrdude from MPIDE not working in Cygwin, requiring WinAVR 
    unset MPIDE_DIR
fi

if [ -z "$MPIDE_DIR" ] || ! [ -d "$MPIDE_DIR" ]; then
    echo "No MPIDE_DIR environment variable found, will use standalone avrdude"
    if [ -z "$AVRDUDE" ]; then
        AVRDUDE="`which avrdude`"
    fi

    if [ -z "$AVRDUDE" ]; then
        if [ $OS == "windows" ] || [ $OS == "cygwin" ]; then
            echo "Install WinAVR to get avrdude"
        fi
        die "ERROR: No avrdude binary found in your path"
    else
        echo "Using $AVRDUDE..."
    fi
else
    echo "Using avrdude from MPIDE installation at $MPIDE_DIR..."
    AVRDUDE_TOOLS_PATH="$MPIDE_DIR/hardware/tools"
    AVRDUDE="$AVRDUDE_TOOLS_PATH/avrdude"

    if [ ! -e "$AVRDUDE" ]; then
        # OS X and Windows MPIDE have different directory structure
        AVRDUDE="$AVRDUDE_TOOLS_PATH/avr/bin/avrdude"
    fi
fi

if [ -z $AVRDUDE_CONF ]; then
    if [ $OS == "cygwin" ]; then
        # avrdude in cygwin expects windows style paths, so the absolute
        # path throws a "file not found" error
        AVRDUDE_CONF="conf/avrdude.conf"
    else
        AVRDUDE_CONF="$DIR/conf/avrdude.conf"
    fi
fi

{'fraction_non_alphanumeric': 0.14015858208955223, 'fraction_numerical': 0.008395522388059701, 'mean_word_length': 2.3985736925515058, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2522632', 'n_tokens_mistral': 1620, 'n_tokens_neox': 1541, 'n_words': 468}