#include "conf.h"
#include "debug_print.h"
+// ミューテックス
+static pthread_mutex_t mutex_conf = PTHREAD_MUTEX_INITIALIZER;
+
//
-/**** Station ID ***************************************************
+/**** 記録周波数 ***************************************************
*/
-#define SID_MAX 16
-static char gsid[SID_MAX + 1];
-// ミューテックス
-static pthread_mutex_t mutex_sid = PTHREAD_MUTEX_INITIALIZER;
+static int freq;
-void sid_set(char *s)
+void conf_freq_set(int f)
{
-pthread_mutex_lock(&mutex_sid);
- strncpy(gsid, s, SID_MAX);
- gsid[SID_MAX] = 0;
-pthread_mutex_unlock(&mutex_sid);
+pthread_mutex_lock(&mutex_conf);
+ freq = f;
+pthread_mutex_unlock(&mutex_conf);
}
-void sid_get(char *s)
+int conf_freq_get(void)
{
-pthread_mutex_lock(&mutex_sid);
- strncpy(s, gsid, SID_MAX);
- s[SID_MAX] = 0;
-pthread_mutex_unlock(&mutex_sid);
+ int f;
+pthread_mutex_lock(&mutex_conf);
+ f = freq;
+pthread_mutex_unlock(&mutex_conf);
+ return f;
}
-char *sid_getp(void)
+//
+/**** Gain ***************************************************
+*/
+/*
+ 0=1/8, 1=1/4, 2=1/2, 3=1, 4=2, 5=4
+ 6=8, 7=16, 8=32, 9=64, 10=128
+*/
+static int gain;
+
+void conf_gain_set(int f)
+{
+pthread_mutex_lock(&mutex_conf);
+ gain = f;
+pthread_mutex_unlock(&mutex_conf);
+}
+int conf_gain_get(void)
{
- return gsid;
+ int f;
+pthread_mutex_lock(&mutex_conf);
+ f = gain;
+pthread_mutex_unlock(&mutex_conf);
+ return f;
}
//
{
FILE *fp;
char buf[256];
- char buf2[256];
-
+// char buf2[256];
+ int f;
+
fp = fopen(CONF_FILE, "rt");
if (fp == NULL) {
syslog(LOG_ERR, "conf_read(): conf file not found. %s", CONF_FILE);
trim_space(buf);
PDEBUG(buf);
PDEBUG("\n");
- // Station ID
- if (sscanf(buf, "sid = %s", buf2) == 1) {
- sid_set(buf2);
- syslog(LOG_INFO, "sid=%s", sid_getp());
+ // 記録周波数
+ if (sscanf(buf, "freq = %d", &f) == 1) {
+ conf_freq_set(f);
+ syslog(LOG_INFO, "freq=%d", conf_freq_get());
+ }
+ // Gain
+ if (sscanf(buf, "gain = %d", &f) == 1) {
+ conf_gain_set(f);
+ syslog(LOG_INFO, "gain=%d", conf_gain_get());
}
}
fclose(fp);