aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--arm-probe.c78
-rw-r--r--arm-probe.h3
-rw-r--r--configuration.c11
-rw-r--r--interpolation.c5
-rw-r--r--sample.c1
5 files changed, 65 insertions, 33 deletions
diff --git a/arm-probe.c b/arm-probe.c
index 962f8f9..b34f6f7 100644
--- a/arm-probe.c
+++ b/arm-probe.c
@@ -29,7 +29,8 @@ int stdinpos = 0;
int stdinlen = 0;
double do_average = 0;
-static void issue_samples(enum samples_actions sa, struct aep_channel *ch, double voltage, double current);
+static void issue_samples(enum samples_actions sa, struct aep_channel *ch,
+ double voltage, double current);
struct aep_context aep_context = {
@@ -84,33 +85,42 @@ int get_stdin_line(char *buf, int maxlen)
* this is the callback where the results appear
*/
-static void issue_samples(enum samples_actions sa, struct aep_channel *ch, double voltage, double current)
+static void issue_samples(enum samples_actions sa, struct aep_channel *ch,
+ double voltage, double current)
{
static int periodic;
+ static char titles[4096];
+ static int pos;
switch (sa) {
case AEPSA_DATA_STARTING:
- if (stdinline[0]) {
- printf("%s", stdinline);
- get_stdin_line(stdinline, sizeof stdinline);
- } else
- printf("sample");
- break;
+ printf("#\n");
+ pos = 0;
+ if (!stdinline[0])
+ break;
+ printf("%s", stdinline);
+ get_stdin_line(stdinline, sizeof stdinline);
+ break;
case AEPSA_DATA_STARTING_CHANNELS:
+
+ printf("# %s\t%s\t%s\n",
+ ch->channel_name, ch->channel_name_pretty, ch->supply);
+
if (just_power)
- printf(" %s(W)",
+ pos += sprintf(&titles[pos], " %s(W)",
ch->channel_name_pretty);
else
- printf(" %s(V) %s(A) %s(W)",
+ pos += sprintf(&titles[pos]," %s(V) %s(A) %s(W)",
ch->channel_name_pretty,
ch->channel_name_pretty,
ch->channel_name_pretty);
break;
case AEPSA_DATA_STARTING_DONE:
- printf("\n");
+ printf("#\nsample");
+ puts(titles);
break;
case AEPSA_START_PRE:
@@ -125,7 +135,8 @@ static void issue_samples(enum samples_actions sa, struct aep_channel *ch, doubl
if (just_power)
fprintf(stderr, " %.5f", voltage * current);
else
- fprintf(stderr, " %.2f %.4f %.5f", voltage, current, voltage * current);
+ fprintf(stderr, " %.2f %.4f %.5f",
+ voltage, current, voltage * current);
break;
case AEPSA_END_PRE:
if (periodic & 0x1ff)
@@ -149,13 +160,15 @@ static void issue_samples(enum samples_actions sa, struct aep_channel *ch, doubl
if (just_power)
printf(" %.5f", voltage * current);
else
- printf(" %.2f %.4f %.5f", voltage, current, voltage * current);
+ printf(" %.2f %.4f %.5f",
+ voltage, current, voltage * current);
if (periodic & 0x1ff)
break;
if (just_power)
fprintf(stderr, " %.5f", voltage * current);
else
- fprintf(stderr, " %.2f %.4f %.5f", voltage, current, voltage * current);
+ fprintf(stderr, " %.2f %.4f %.5f",
+ voltage, current, voltage * current);
break;
case AEPSA_END:
printf("\n");
@@ -257,15 +270,17 @@ int main(int argc, char *argv[])
case 'w':
aep_context.mw_min = atoi(optarg);
if (aep_context.mw_min)
- aep_context.mw_min_plus_hyst = aep_context.mw_min + (aep_context.mw_min / 10);
+ aep_context.mw_min_plus_hyst =
+ aep_context.mw_min + (aep_context.mw_min / 10);
break;
case 'j':
just_power = 1;
break;
case 'C':
strncpy(aep_context.config_filepath, optarg,
- sizeof aep_context.config_filepath - 1);
- aep_context.config_filepath[sizeof aep_context.config_filepath - 1] = '\0';
+ sizeof aep_context.config_filepath - 1);
+ aep_context.config_filepath[
+ sizeof aep_context.config_filepath - 1] = '\0';
break;
case 't':
aep_context.ms_holdoff = atoi(optarg);
@@ -330,7 +345,8 @@ int main(int argc, char *argv[])
"result as zero offset\n"
" [--average -a <float>] at the end of the "
"capture, add a simple mean average "
- "to the \n stdout dataset, starting at "
+ "to the \n"
+ " stdout dataset, starting at "
"<float> seconds\n"
);
exit(1);
@@ -401,7 +417,8 @@ int main(int argc, char *argv[])
* append simple average to results if requested
*/
- if (aep_context.awaiting_capture == 0 && aep_context.exit_after_capture && do_average) {
+ if (aep_context.awaiting_capture == 0 &&
+ aep_context.exit_after_capture && do_average) {
tt = do_average;
@@ -447,18 +464,23 @@ int main(int argc, char *argv[])
for (i = 0; i < CHANNELS_PER_PROBE; i++) {
ch = &aep_context.aeps[m].ch[i];
- if (configure(&aep_context, &aep_context.aeps[m], aep_context.aeps[m].dev_filepath, aep_context.config_filepath,
- ch) < 0)
- fprintf(stderr, "adaptive: failed to update config\n");
+ if (configure(&aep_context, &aep_context.aeps[m],
+ aep_context.aeps[m].dev_filepath,
+ aep_context.config_filepath, ch) < 0)
+ fprintf(stderr, "failed to update config\n");
+
+ if (ch->min[0] == 999)
+ continue;
- if (ch->min[0] != 999)
- fprintf(stderr, "%12s: %4.2fV < %4.3fVavg < %4.2fV, "
+ fprintf(stderr, "%12s: %4.2fV < %4.3fVavg < %4.2fV, "
"%6.4fA < %6.5fAavg < %6.4fA, "
"%9.6fW < %9.6fWavg < %9.6fW\n",
- ch->channel_name,
- ch->min[0], ch->simple_avg[0] / ch->avg_count, ch->max[0],
- ch->min[1], ch->simple_avg[1] / ch->avg_count, ch->max[1],
- ch->min[2], ch->simple_avg[2] / ch->avg_count, ch->max[2]);
+ ch->channel_name, ch->min[0],
+ ch->simple_avg[0] / ch->avg_count, ch->max[0],
+ ch->min[1],
+ ch->simple_avg[1] / ch->avg_count, ch->max[1],
+ ch->min[2],
+ ch->simple_avg[2] / ch->avg_count, ch->max[2]);
}
probe_close(&aep_context.aeps[m]);
}
diff --git a/arm-probe.h b/arm-probe.h
index 8c1ffe2..e48e9bd 100644
--- a/arm-probe.h
+++ b/arm-probe.h
@@ -141,6 +141,7 @@ struct aep_channel {
struct aep *aep;
char channel_name[64];
char channel_name_pretty[64];
+ char supply[64]; /* parent channel name */
int pretrigger_ms;
int pretrigger_samples_taken;
double rshunt;
@@ -265,8 +266,6 @@ struct interp {
double raw;
};
-#define BRACKET 10
-
extern struct interp_tables interp_tables[3];
extern double correct(int no_correction, double common_mode, double in, struct interp *map, int map_len);
diff --git a/configuration.c b/configuration.c
index 347f1cf..7949309 100644
--- a/configuration.c
+++ b/configuration.c
@@ -38,6 +38,7 @@ enum fields {
AEPC_FIELD_ZERO_NOISE_V2,
AEPC_FIELD_RELATIVE_PRETRIG,
AEPC_FIELD_PRETTY_NAME,
+ AEPC_FIELD_SUPPLY,
/* always last */
FIELDS_PER_CHANNEL
@@ -207,7 +208,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\n",
+ " %s\t%f\t%f\t%f\t%f\t%f\t%f\t%d\t%s\t%s\n",
ch->channel_name,
ch->rshunt,
ch->percentage_error_ref,
@@ -216,7 +217,8 @@ int configure(struct aep_context *aep_context, struct aep *aep, const char *dev_
ch->voffset[1],
ch->vnoise[1],
ch->pretrigger_ms,
- ch->channel_name_pretty);
+ ch->channel_name_pretty,
+ ch->supply);
if (aep->aep_context->verbose)
fprintf(stderr, "Updating config "
"with \"%s\"\n", linebuf);
@@ -255,6 +257,7 @@ int configure(struct aep_context *aep_context, struct aep *aep, const char *dev_
case AEPC_FIELD_ZERO_OFFSET_V2:
case AEPC_FIELD_ZERO_NOISE_V2:
case AEPC_FIELD_RELATIVE_PRETRIG:
+ case AEPC_FIELD_SUPPLY:
if (copy_pos >= sizeof marshall - 1)
break;
marshall[copy_pos++] = c;
@@ -290,6 +293,10 @@ int configure(struct aep_context *aep_context, struct aep *aep, const char *dev_
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;
default:
break;
}
diff --git a/interpolation.c b/interpolation.c
index 2512b5d..82c3aa1 100644
--- a/interpolation.c
+++ b/interpolation.c
@@ -14,7 +14,10 @@
* nearest known-good measurements
*/
-extern int no_correction;
+
+/* how far +/- it looks for better match from common-mode starting point */
+
+#define BRACKET 10
struct interp map1[] = {
{ 0.63, 0.003887, 0.001930 },
diff --git a/sample.c b/sample.c
index 66692d8..3eaedb1 100644
--- a/sample.c
+++ b/sample.c
@@ -787,6 +787,7 @@ static void init_aep(struct aep_context *aep_context, struct aep *aep, const cha
ch->simple_avg[2] = 0.0;
ch->avg_count = 0;
ch->samples = 0;
+ strcpy(ch->supply, "none");
}
}