aboutsummaryrefslogtreecommitdiff
path: root/libarmep/configuration.c
diff options
context:
space:
mode:
authorAndy Green <andy.green@linaro.org>2012-10-14 12:56:57 +0800
committerAndy Green <andy.green@linaro.org>2012-10-14 13:40:56 +0800
commitbadb9cf4e9f0afee1a25254ddb0f0178a624cb10 (patch)
tree561993d498566a2ae417eae70d8f50efdbe62970 /libarmep/configuration.c
parent93a3d0724c9bc593d6759d80fdbc430151afab36 (diff)
config allow virtual summing supplies in config
Signed-off-by: Andy Green <andy.green@linaro.org>
Diffstat (limited to 'libarmep/configuration.c')
-rw-r--r--libarmep/configuration.c135
1 files changed, 79 insertions, 56 deletions
diff --git a/libarmep/configuration.c b/libarmep/configuration.c
index 3da36cf..67752ca 100644
--- a/libarmep/configuration.c
+++ b/libarmep/configuration.c
@@ -46,6 +46,61 @@ enum fields {
FIELDS_PER_CHANNEL
};
+static void process_token(struct aep_channel *ch, char *marshall, enum fields field)
+{
+
+ switch (field) {
+ case AEPC_FIELD_RSHUNT:
+ ch->rshunt = atof(marshall);
+ if (!ch->rshunt)
+ fprintf(stderr, "**** channel cannot have 0R shunt\n");
+ break;
+ case AEPC_FIELD_INTERCHANNEL_ERROR_ESTIMATE:
+ ch->percentage_error_ref = atof(marshall);
+ break;
+ case AEPC_FIELD_ZERO_OFFSET_V1:
+ ch->voffset[0] = atof(marshall);
+ break;
+ case AEPC_FIELD_ZERO_NOISE_V1:
+ ch->vnoise[0] = atof(marshall);
+ break;
+ case AEPC_FIELD_ZERO_OFFSET_V2:
+ ch->voffset[1] = atof(marshall);
+ break;
+ case AEPC_FIELD_ZERO_NOISE_V2:
+ ch->vnoise[1] = atof(marshall);
+ break;
+ case AEPC_FIELD_RELATIVE_PRETRIG:
+ ch->pretrigger_ms = atoi(marshall);
+ if (ch->aep) {
+ ch->ring_samples = (ch->pretrigger_ms +
+ ch->aep->aep_context->ms_pretrigger) * 10;
+ ch->pretrig_ring = NULL;
+ ch->head = 0;
+ ch->tail = 0;
+ if (ch->ring_samples)
+ ch->pretrig_ring = malloc (
+ sizeof(struct samples) *
+ ch->ring_samples);
+ }
+ break;
+ case AEPC_FIELD_SUPPLY:
+ strncpy(ch->supply, marshall, sizeof(ch->supply) - 1);
+ ch->supply[sizeof(ch->supply) - 1] = '\0';
+ break;
+ case AEPC_FIELD_COLOUR:
+ strncpy(ch->colour, marshall, sizeof(ch->colour) - 1);
+ ch->colour[sizeof(ch->colour) - 1] = '\0';
+ break;
+ case AEPC_FIELD_CLASS:
+ strncpy(ch->class, marshall, sizeof(ch->class) - 1);
+ ch->class[sizeof(ch->class) - 1] = '\0';
+ break;
+ default:
+ break;
+ }
+}
+
int configure(struct aep_context *aep_context, struct aep *aep, const char *dev_filepath,
const char *config_filepath, struct aep_channel *wch)
{
@@ -96,6 +151,11 @@ int configure(struct aep_context *aep_context, struct aep *aep, const char *dev_
if (aep)
ch = &aep->ch[0];
+ else {
+ if (aep_context->count_virtual_channels >= MAX_VIRTUAL_CHANNELS)
+ return -1;
+ ch = &aep_context->vch[aep_context->count_virtual_channels];
+ }
if (fd < 0) {
fprintf(stderr, "unable to open config file %s\n",
@@ -155,8 +215,8 @@ int configure(struct aep_context *aep_context, struct aep *aep, const char *dev_
aep_context->configuration_name[copy_pos] = '\0';
copy_pos = 0;
actions = APCA_CHECK_DEVPATH;
- if (aep == NULL)
- return 0;
+// if (aep == NULL)
+// return 0;
} else
if (copy_pos < (sizeof aep_context->configuration_name) - 1)
aep_context->configuration_name[copy_pos++] = c;
@@ -207,6 +267,9 @@ int configure(struct aep_context *aep_context, struct aep *aep, const char *dev_
}
if (parser == ACPP_FIRST) {
+ if (ch != wch)
+ process_token(ch, marshall, field);
+
index++;
if (ch == wch) {
sprintf(linebuf,
@@ -231,66 +294,26 @@ int configure(struct aep_context *aep_context, struct aep *aep, const char *dev_
}
ch++;
- if (index == CHANNELS_PER_PROBE) {
- more = 0;
- continue;
+ if (aep) {
+ if (index == CHANNELS_PER_PROBE) {
+ more = 0;
+ continue;
+ }
+ } else {
+ aep_context->count_virtual_channels++;
+ if (aep_context->count_virtual_channels >= MAX_VIRTUAL_CHANNELS) {
+ more = 0;
+ continue;
+ }
}
no_copy = ch == wch;
}
if (c == '\t' || c == ' ' || c == '\0') {
- if (ch != wch) {
-
- switch (field) {
- case AEPC_FIELD_RSHUNT:
- ch->rshunt = atof(marshall);
- if (!ch->rshunt)
- fprintf(stderr, "**** channel cannot have 0R shunt\n");
- break;
- case AEPC_FIELD_INTERCHANNEL_ERROR_ESTIMATE:
- ch->percentage_error_ref = atof(marshall);
- break;
- case AEPC_FIELD_ZERO_OFFSET_V1:
- ch->voffset[0] = atof(marshall);
- break;
- case AEPC_FIELD_ZERO_NOISE_V1:
- ch->vnoise[0] = atof(marshall);
- break;
- case AEPC_FIELD_ZERO_OFFSET_V2:
- ch->voffset[1] = atof(marshall);
- break;
- case AEPC_FIELD_ZERO_NOISE_V2:
- ch->vnoise[1] = atof(marshall);
- break;
- case AEPC_FIELD_RELATIVE_PRETRIG:
- ch->pretrigger_ms = atoi(marshall);
- ch->ring_samples = (ch->pretrigger_ms +
- ch->aep->aep_context->ms_pretrigger) * 10;
- ch->pretrig_ring = NULL;
- ch->head = 0;
- ch->tail = 0;
- if (ch->ring_samples)
- ch->pretrig_ring = malloc (
- sizeof(struct samples) *
- ch->ring_samples);
- break;
- case AEPC_FIELD_SUPPLY:
- strncpy(ch->supply, marshall, sizeof(ch->supply) - 1);
- ch->supply[sizeof(ch->supply) - 1] = '\0';
- break;
- case AEPC_FIELD_COLOUR:
- strncpy(ch->colour, marshall, sizeof(ch->colour) - 1);
- ch->colour[sizeof(ch->colour) - 1] = '\0';
- break;
- case AEPC_FIELD_CLASS:
- strncpy(ch->class, marshall, sizeof(ch->class) - 1);
- ch->class[sizeof(ch->class) - 1] = '\0';
- break;
- default:
- break;
- }
- }
+ if (ch != wch)
+ process_token(ch, marshall, field);
+
field++;
parser = ACPP_SWALLOW_WHITE;
copy_pos = 0;