#!/bin/sh

KO_DIR=/usr/lib/modules

function fun_get_motor_params()
{
	motor_params="gpio_pin=52,53,54,55,48,49,50,51,0xff,0xff,0xff,0xff auto_test=0 x_stepmax=8388 y_stepmax=1438 x_steps=8388 y_steps=1438 #auto_scan=0"
	if [ -e "/mnt/mtd/Log/motorset" ];then
		motor_params=`cat /mnt/mtd/Log/motorset`
	elif [ -e "/mnt/custom/CustomConfig/motor.init" ];then
		motor_params=`cat /mnt/custom/CustomConfig/motor.init`
	fi
	if [ -e "/mnt/mtd/Config/maintain" ];then
		motor_params=`echo $motor_params | sed "s/auto_test=1/auto_test=0/g"`
	fi

	echo -n "x_faster=2 y_faster=2 $motor_params"
}

if [ -e $KO_DIR/XmMotor.ko ];then
	insmod $KO_DIR/XmMotor.ko $(fun_get_motor_params)
fi


