Subversion Repositories FlightCtrl

Rev

Rev 60 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

/* First version by Bjoern Biesenbach <bjoern@bjoern-b.de> */

#include <stdio.h>
#include <stdlib.h>
#include "iniparser/src/iniparser.h"
#include "iniparser/src/dictionary.h"
#include "paramSet.h"
#include "main.h"
#include "serial.h"

int main(int argv, char *argc[])
{
        if(argv != 4)
        {      
                printf("\nUsage: ./mkset <setting_file> <setting> <serial_port>\n\n\n");
                printf("\t Example: ./mkset Default.mkp 1 /dev/ttyS0\n\n");
                exit(2);
        }
        dictionary *d;
       
        d = iniparser_load(argc[1]);
       
        strcpy(Param.Name, (iniparser_getstr(d,"Setup:Name")));
        if(Param.Name=="")
                strcpy(Param.Name,"<unnamed>");
        Param.Kanalbelegung[0] = iniparser_getint(d,"Channels:Gas", 3);
        Param.Kanalbelegung[1] = iniparser_getint(d,"Channels:Gier", 4);
        Param.Kanalbelegung[2] = iniparser_getint(d,"Channels:Nick", 1);
        Param.Kanalbelegung[3] = iniparser_getint(d,"Channels:Roll", 2);
        Param.Kanalbelegung[4] = iniparser_getint(d,"Channels:Poti_1", 5);
        Param.Kanalbelegung[5] = iniparser_getint(d,"Channels:Poti_2", 6);
        Param.Kanalbelegung[6] = iniparser_getint(d,"Channels:Poti_3", 7);
        Param.Kanalbelegung[7] = iniparser_getint(d,"Channels:Poti_4", 8);
       
        Param.GlobalConfig = iniparser_getint(d,"Setup:GlobalConfig", 0);
       
        Param.Stick_P = iniparser_getint(d,"Stick:Nick_Roll-P", 4);
        Param.Stick_D = iniparser_getint(d,"Stick:Nick_Roll-D", 8);
        Param.Gier_P = iniparser_getint(d,"Stick:Gier-P", 16);
       
        Param.MaxHoehe = iniparser_getint(d,"Altitude:Setpoint", 251);
        Param.Hoehe_MinGas = iniparser_getint(d,"Altitude:MinGas", 30);
        Param.Hoehe_P = iniparser_getint(d,"Altitude:P", 10);
        Param.Luftdruck_D = iniparser_getint(d,"Altitude:Barometric-D", 90);
        Param.Hoehe_ACC_Wirkung = iniparser_getint(d,"Altitude:Z-ACC-Effect",15);
        Param.Hoehe_Verstaerkung = iniparser_getint(d,"Altitude:Gain", 2);
       
        Param.Gyro_P = iniparser_getint(d,"Gyro:P", 120);
        Param.Gyro_I = iniparser_getint(d,"Gyro:I", 150);
        Param.GyroAccFaktor = iniparser_getint(d,"Gyro:ACC_Gyro-Factor", 26);
       
        Param.I_Faktor = iniparser_getint(d,"Gyro:Main-I", 5);
       
        Param.Gas_Min = iniparser_getint(d,"Others:MinGas",15);
        Param.Gas_Max = iniparser_getint(d,"Others:MaxGas",250);
        Param.KompassWirkung = iniparser_getint(d,"Others:Compass-Effect",128);
        Param.UnterspannungsWarnung = iniparser_getint(d,"Others:UnderVoltage",90);
       
        Param.NotGas = iniparser_getint(d,"Others:NotGas",35);
        Param.NotGasZeit = iniparser_getint(d,"Others:NotGasTime",20);
       
        Param.UserParam1 = iniparser_getint(d,"User:Parameter_1",0);
        Param.UserParam2 = iniparser_getint(d,"User:Parameter_2",0);
        Param.UserParam3 = iniparser_getint(d,"User:Parameter_3",0);
        Param.UserParam4 = iniparser_getint(d,"User:Parameter_4",0);
       
        Param.ServoNickControl = iniparser_getint(d,"Camera:ServoNickControl",252);
        Param.ServoNickComp = iniparser_getint(d,"Camera:ServoNickCompensation",100);
        Param.ServoNickCompInvert = iniparser_getboolean(d,"Camera:ServoNickInvert",0);
        Param.ServoNickMin = iniparser_getint(d,"Camera:ServoNickMin",0);
        Param.ServoNickMax = iniparser_getint(d,"Camera:ServoNickMax",250);
        Param.ServoNickRefresh = iniparser_getint(d,"Camera:ServoNickRefreshRate",50);
       
        initSerial(argc[3]);

        SendOutData('l'+(atoi(argc[2])-1), 1,  &Param, sizeof(Param));
       
        iniparser_freedict(d);
        return EXIT_SUCCESS;
}