#!/bin/bash
# ---------------------------------------------------------------------------
# NAME
#
#     ReportBoardVersion - reports the version of the SMC board
#
# SYNOPSIS
#
#     ReportBoardVersion {-v}
#
# DESCRIPTION
#
#     Reports the SMC board version
#
# ---------------------------------------------------------------------------

# determine if it is verbose output
arg="$1"

# script exits on error
set -e

# get the number from the board
LLVersion=`sudo i2cget -y 2 0x38 0`

# decode the version
decodeOK="Y"
case "$LLVersion" in
	0x00)
		decoded="Rev A or B"
		;;
	0x01)
		decoded="Rev C"
		;;
	*)
		decoded="unknown"
		decodeOK="N"
		;;
esac

# output the result
if [ "$arg" = "-v" -o "$arg" = "-V" -o "$decodeOK" != "Y" ]
then
	echo "$LLVersion $decoded"
else
	echo "$decoded"
fi

exit 0

