aboutsummaryrefslogtreecommitdiff
path: root/libarmep
diff options
context:
space:
mode:
authorAndy Green <andy.green@linaro.org>2012-10-14 12:42:48 +0800
committerAndy Green <andy.green@linaro.org>2012-10-14 12:42:48 +0800
commit93a3d0724c9bc593d6759d80fdbc430151afab36 (patch)
tree2891b9a258a621914d148d3976cb8a49ff76488c /libarmep
parent7e79599d0e1ec600c9f670cf1d94f11bdafb1c46 (diff)
config add channel class field
Signed-off-by: Andy Green <andy.green@linaro.org>
Diffstat (limited to 'libarmep')
-rw-r--r--libarmep/configuration.c32
-rw-r--r--libarmep/libarmep.h2
-rw-r--r--libarmep/service.c25
3 files changed, 32 insertions, 27 deletions
diff --git a/libarmep/configuration.c b/libarmep/configuration.c
index 81a391f..3da36cf 100644
--- a/libarmep/configuration.c
+++ b/libarmep/configuration.c
@@ -40,6 +40,7 @@ enum fields {
AEPC_FIELD_PRETTY_NAME,
AEPC_FIELD_SUPPLY,
AEPC_FIELD_COLOUR,
+ AEPC_FIELD_CLASS,
/* always last */
FIELDS_PER_CHANNEL
@@ -209,7 +210,7 @@ int configure(struct aep_context *aep_context, struct aep *aep, const char *dev_
index++;
if (ch == wch) {
sprintf(linebuf,
- " %s\t%f\t%f\t%f\t%f\t%f\t%f\t%d\t%s\t%s\t%s\n",
+ " %s\t%f\t%f\t%f\t%f\t%f\t%f\t%d\t%s\t%s\t%s\t%s\n",
ch->channel_name,
ch->rshunt,
ch->percentage_error_ref,
@@ -220,7 +221,8 @@ int configure(struct aep_context *aep_context, struct aep *aep, const char *dev_
ch->pretrigger_ms,
ch->channel_name_pretty,
ch->supply,
- ch->colour
+ ch->colour,
+ ch->class
);
if (aep->aep_context->verbose)
fprintf(stderr, "Updating config "
@@ -281,6 +283,10 @@ int configure(struct aep_context *aep_context, struct aep *aep, const char *dev_
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;
}
@@ -301,20 +307,6 @@ int configure(struct aep_context *aep_context, struct aep *aep, const char *dev_
ch->channel_name[copy_pos++] = c;
ch->channel_name[copy_pos] = '\0';
break;
- case AEPC_FIELD_RSHUNT:
- case AEPC_FIELD_INTERCHANNEL_ERROR_ESTIMATE:
- case AEPC_FIELD_ZERO_OFFSET_V1:
- case AEPC_FIELD_ZERO_NOISE_V1:
- case AEPC_FIELD_ZERO_OFFSET_V2:
- case AEPC_FIELD_ZERO_NOISE_V2:
- case AEPC_FIELD_RELATIVE_PRETRIG:
- case AEPC_FIELD_SUPPLY:
- case AEPC_FIELD_COLOUR:
- if (copy_pos >= sizeof marshall - 1)
- break;
- marshall[copy_pos++] = c;
- marshall[copy_pos] = '\0';
- break;
case AEPC_FIELD_PRETTY_NAME:
if (copy_pos >=
sizeof ch->channel_name_pretty - 1)
@@ -323,9 +315,11 @@ int configure(struct aep_context *aep_context, struct aep *aep, const char *dev_
ch->channel_name_pretty[copy_pos] = '\0';
break;
default:
- fprintf(stderr, "Unable to parse config\n");
- close(fd);
- return -1;
+ if (copy_pos >= sizeof marshall - 1)
+ break;
+ marshall[copy_pos++] = c;
+ marshall[copy_pos] = '\0';
+ break;
}
break;
}
diff --git a/libarmep/libarmep.h b/libarmep/libarmep.h
index 7a686a9..49e0b31 100644
--- a/libarmep/libarmep.h
+++ b/libarmep/libarmep.h
@@ -153,6 +153,7 @@ struct aep_channel {
char channel_name_pretty[64];
char supply[64]; /* parent channel name */
char colour[16]; /* #xxxxxx HTML-style colour */
+ char class[16]; /* optional class of power, eg, Soc */
int pretrigger_ms;
int pretrigger_samples_taken;
double rshunt;
@@ -240,6 +241,7 @@ struct aep_shared {
char channel_name_pretty[MAX_PROBES * CHANNELS_PER_PROBE][64];
char supply[MAX_PROBES * CHANNELS_PER_PROBE][64];
char colour[MAX_PROBES * CHANNELS_PER_PROBE][16];
+ char class[MAX_PROBES * CHANNELS_PER_PROBE][16];
int chans;
int finished;
double averages[MAX_PROBES * CHANNELS_PER_PROBE][3];
diff --git a/libarmep/service.c b/libarmep/service.c
index a57b2f2..77683e5 100644
--- a/libarmep/service.c
+++ b/libarmep/service.c
@@ -99,6 +99,7 @@ static void init_aep(struct aep_context *aep_context, struct aep *aep, const cha
ch->samples = 0;
strcpy(ch->supply, "none");
sprintf(ch->colour, "#%06X", rand() & 0xffffff);
+ strcpy(ch->class, "-");
}
}
@@ -148,6 +149,21 @@ void probe_close(struct aep *aep)
close(aep->fd);
}
+static void copy_public_ch_info_to_shared(struct aep_shared *aep_shared, struct aep_channel *ch)
+{
+ strncpy(aep_shared->channel_name[chan], ch->channel_name, sizeof(aep_shared->channel_name[0]));
+ aep_shared->channel_name[chan][sizeof(aep_shared->channel_name[0]) - 1] = '\0';
+ strncpy(aep_shared->channel_name_pretty[chan], ch->channel_name_pretty, sizeof(aep_shared->channel_name_pretty[0]));
+ aep_shared->channel_name_pretty[chan][sizeof(aep_shared->channel_name_pretty[0]) - 1] = '\0';
+ strncpy(aep_shared->supply[chan], ch->supply, sizeof(aep_shared->supply[0]));
+ aep_shared->supply[chan][sizeof(aep_shared->supply[0]) - 1] = '\0';
+ strncpy(aep_shared->colour[chan], ch->colour, sizeof(aep_shared->colour[0]));
+ aep_shared->colour[chan][sizeof(aep_shared->colour[0]) - 1] = '\0';
+ strncpy(aep_shared->class[chan], ch->class, sizeof(aep_shared->class[0]));
+ aep_shared->class[chan][sizeof(aep_shared->class[0]) - 1] = '\0';
+
+}
+
int service_aeps(struct aep_context *aep_context, int fd_with_rx)
{
static unsigned char zero[8] = { 0, 0, 0, 0, 0, 0, 0, 0, };
@@ -357,14 +373,7 @@ bail:
if (!ch->requested)
continue;
- strncpy(aep_context->aep_shared->channel_name[chan], ch->channel_name, sizeof(aep_context->aep_shared->channel_name[0]));
- aep_context->aep_shared->channel_name[chan][sizeof(aep_context->aep_shared->channel_name[0]) - 1] = '\0';
- strncpy(aep_context->aep_shared->channel_name_pretty[chan], ch->channel_name_pretty, sizeof(aep_context->aep_shared->channel_name_pretty[0]));
- aep_context->aep_shared->channel_name_pretty[chan][sizeof(aep_context->aep_shared->channel_name_pretty[0]) - 1] = '\0';
- strncpy(aep_context->aep_shared->supply[chan], ch->supply, sizeof(aep_context->aep_shared->supply[0]));
- aep_context->aep_shared->supply[chan][sizeof(aep_context->aep_shared->supply[0]) - 1] = '\0';
- strncpy(aep_context->aep_shared->colour[chan], ch->colour, sizeof(aep_context->aep_shared->colour[0]));
- aep_context->aep_shared->colour[chan][sizeof(aep_context->aep_shared->colour[0]) - 1] = '\0';
+ copy_public_ch_info_to_shared(aep_context->aep_shared, ch);
chan++;
aep_context->aep_shared->chans = chan;