Im Simu-Mode Bedienung über Tastatur
This commit is contained in:
@@ -23,6 +23,12 @@ void Settings_InitDefaultValues()
|
||||
settings.iMotorPwrMaxRaw = 250;
|
||||
settings.iMotorPwrStepCount = 7;
|
||||
|
||||
settings.iShellySupplyCount = 0;
|
||||
for (int i=0; i<MAX_SHELLIES_COUNT; i++)
|
||||
{
|
||||
settings.sShellySupplyTopic[i][0] = '\0';
|
||||
}
|
||||
|
||||
// Get path of the executable itself
|
||||
ssize_t length = readlink("/proc/self/exe", settings.sExePath, sizeof(settings.sExePath) - 1);
|
||||
if (length >= 0)
|
||||
@@ -74,12 +80,12 @@ void Settings_ReadConfFile()
|
||||
//const char *filename = "/etc/CanRtDriver.conf";
|
||||
|
||||
char filename[MAX_PATH + 50];
|
||||
sprintf(filename, "%s.conf", settings.sExePath);
|
||||
sprintf(filename, "/etc/CanRtDriver.conf");
|
||||
FILE *file = fopen(filename, "r");
|
||||
if (file == NULL)
|
||||
{
|
||||
mylog(LOG_INFO, "SETTINGS: File %s noch found", filename);
|
||||
sprintf(filename, "/etc/CanRtDriver.conf");
|
||||
sprintf(filename, "%s.conf", settings.sExePath);
|
||||
file = fopen(filename, "r");
|
||||
if (file == NULL)
|
||||
{
|
||||
@@ -108,43 +114,53 @@ void Settings_ReadConfFile()
|
||||
|
||||
if ((key != NULL) && (value != NULL))
|
||||
{
|
||||
//mylog(LOG_INFO, "SETTINGS: Found key: '%s' | value: '%s'", key, value);
|
||||
|
||||
if (strcmp(key, "DebugLevel") == 0)
|
||||
{
|
||||
// how many log messages we want to see
|
||||
settings.iDebugLevel = atoi(value);
|
||||
mylog(LOG_DEBUG, "SETTINGS: %s = %d", key, settings.iDebugLevel);
|
||||
}
|
||||
else if (strcmp(key, "CanSimu") == 0)
|
||||
{
|
||||
// shall we do simulation
|
||||
settings.iCanSimu = atoi(value);
|
||||
mylog(LOG_DEBUG, "SETTINGS: %s = %d", key, settings.iCanSimu);
|
||||
}
|
||||
else if (strcmp(key, "MotorPowerMinRaw") == 0)
|
||||
{
|
||||
// Minimum power value for the motors
|
||||
settings.iMotorPwrMinRaw = atoi(value);
|
||||
mylog(LOG_DEBUG, "SETTINGS: %s = %d", key, settings.iMotorPwrMinRaw);
|
||||
}
|
||||
else if (strcmp(key, "MotorPowerMaxRaw") == 0)
|
||||
{
|
||||
// Maximum power value for the motors
|
||||
settings.iMotorPwrMaxRaw = atoi(value);
|
||||
mylog(LOG_DEBUG, "SETTINGS: %s = %d", key, settings.iMotorPwrMaxRaw);
|
||||
}
|
||||
else if (strcmp(key, "MotorPowerStepCount") == 0)
|
||||
{
|
||||
// How many steps do we want to have switching the power
|
||||
settings.iMotorPwrStepCount = atoi(value);
|
||||
mylog(LOG_DEBUG, "SETTINGS: %s = %d", key, settings.iMotorPwrStepCount);
|
||||
}
|
||||
else if (strcmp(key, "SupplyShellyMqttTopic") == 0)
|
||||
{
|
||||
// MQTT topic for switching power supply
|
||||
if (settings.iShellySupplyCount < MAX_SHELLIES_COUNT)
|
||||
{
|
||||
strcpy(settings.sShellySupplyTopic[settings.iShellySupplyCount], value);
|
||||
settings.iShellySupplyCount++;
|
||||
}
|
||||
else
|
||||
{
|
||||
mylog(LOG_WARNING, "SETTINGS: Too many SupplyShellyMqttTopic!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
mylog(LOG_WARNING, "SETTING: Unknown key: %s", key);
|
||||
}
|
||||
// // Beispiel: Wert verarbeiten
|
||||
// if (strcmp(key, "port") == 0)
|
||||
// {
|
||||
// int port = atoi(value);
|
||||
// printf(" [System] Port auf %d gesetzt.\n", port);
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user