Subversion Repositories FlightCtrl

Rev

Rev 64 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
56 elmo 1
/* First version by Bjoern Biesenbach <bjoern@bjoern-b.de> */
2
 
3
#include <stdio.h>
64 elmo 4
#include <stdlib.h>
56 elmo 5
#include "iniparser/src/iniparser.h"
64 elmo 6
#include "iniparser/src/dictionary.h"
56 elmo 7
#include "paramSet.h"
8
#include "main.h"
9
#include "serial.h"
10
 
11
int main(int argv, char *argc[])
12
{
65 elmo 13
        dictionary *d;
56 elmo 14
        if(argv != 4)
15
        {      
60 elmo 16
                printf("\nUsage: ./mkset <setting_file> <setting> <serial_port>\n\n\n");
17
                printf("\t Example: ./mkset Default.mkp 1 /dev/ttyS0\n\n");
56 elmo 18
                exit(2);
19
        }
20
 
21
        d = iniparser_load(argc[1]);
22
 
23
        strcpy(Param.Name, (iniparser_getstr(d,"Setup:Name")));
24
        if(Param.Name=="")
25
                strcpy(Param.Name,"<unnamed>");
26
        Param.Kanalbelegung[0] = iniparser_getint(d,"Channels:Gas", 3);
27
        Param.Kanalbelegung[1] = iniparser_getint(d,"Channels:Gier", 4);
28
        Param.Kanalbelegung[2] = iniparser_getint(d,"Channels:Nick", 1);
29
        Param.Kanalbelegung[3] = iniparser_getint(d,"Channels:Roll", 2);
30
        Param.Kanalbelegung[4] = iniparser_getint(d,"Channels:Poti_1", 5);
31
        Param.Kanalbelegung[5] = iniparser_getint(d,"Channels:Poti_2", 6);
32
        Param.Kanalbelegung[6] = iniparser_getint(d,"Channels:Poti_3", 7);
33
        Param.Kanalbelegung[7] = iniparser_getint(d,"Channels:Poti_4", 8);
34
 
35
        Param.GlobalConfig = iniparser_getint(d,"Setup:GlobalConfig", 0);
36
 
37
        Param.Stick_P = iniparser_getint(d,"Stick:Nick_Roll-P", 4);
38
        Param.Stick_D = iniparser_getint(d,"Stick:Nick_Roll-D", 8);
39
        Param.Gier_P = iniparser_getint(d,"Stick:Gier-P", 16);
40
 
41
        Param.MaxHoehe = iniparser_getint(d,"Altitude:Setpoint", 251);
42
        Param.Hoehe_MinGas = iniparser_getint(d,"Altitude:MinGas", 30);
43
        Param.Hoehe_P = iniparser_getint(d,"Altitude:P", 10);
44
        Param.Luftdruck_D = iniparser_getint(d,"Altitude:Barometric-D", 90);
45
        Param.Hoehe_ACC_Wirkung = iniparser_getint(d,"Altitude:Z-ACC-Effect",15);
46
        Param.Hoehe_Verstaerkung = iniparser_getint(d,"Altitude:Gain", 2);
47
 
48
        Param.Gyro_P = iniparser_getint(d,"Gyro:P", 120);
49
        Param.Gyro_I = iniparser_getint(d,"Gyro:I", 150);
50
        Param.GyroAccFaktor = iniparser_getint(d,"Gyro:ACC_Gyro-Factor", 26);
51
 
52
        Param.I_Faktor = iniparser_getint(d,"Gyro:Main-I", 5);
53
 
54
        Param.Gas_Min = iniparser_getint(d,"Others:MinGas",15);
55
        Param.Gas_Max = iniparser_getint(d,"Others:MaxGas",250);
56
        Param.KompassWirkung = iniparser_getint(d,"Others:Compass-Effect",128);
57
        Param.UnterspannungsWarnung = iniparser_getint(d,"Others:UnderVoltage",90);
58
 
59
        Param.NotGas = iniparser_getint(d,"Others:NotGas",35);
60
        Param.NotGasZeit = iniparser_getint(d,"Others:NotGasTime",20);
61
 
62
        Param.UserParam1 = iniparser_getint(d,"User:Parameter_1",0);
63
        Param.UserParam2 = iniparser_getint(d,"User:Parameter_2",0);
64
        Param.UserParam3 = iniparser_getint(d,"User:Parameter_3",0);
65
        Param.UserParam4 = iniparser_getint(d,"User:Parameter_4",0);
66
 
67
        Param.ServoNickControl = iniparser_getint(d,"Camera:ServoNickControl",252);
68
        Param.ServoNickComp = iniparser_getint(d,"Camera:ServoNickCompensation",100);
69
        Param.ServoNickCompInvert = iniparser_getboolean(d,"Camera:ServoNickInvert",0);
70
        Param.ServoNickMin = iniparser_getint(d,"Camera:ServoNickMin",0);
71
        Param.ServoNickMax = iniparser_getint(d,"Camera:ServoNickMax",250);
72
        Param.ServoNickRefresh = iniparser_getint(d,"Camera:ServoNickRefreshRate",50);
73
 
74
        initSerial(argc[3]);
75
 
76
        SendOutData('l'+(atoi(argc[2])-1), 1,  &Param, sizeof(Param));
77
 
78
        iniparser_freedict(d);
79
        return EXIT_SUCCESS;
80
}
81
 
82