From badb9cf4e9f0afee1a25254ddb0f0178a624cb10 Mon Sep 17 00:00:00 2001 From: Andy Green Date: Sun, 14 Oct 2012 12:56:57 +0800 Subject: config allow virtual summing supplies in config Signed-off-by: Andy Green --- arm-probe/arm-probe.c | 4 +- config | 21 ++++---- libarmep/configuration.c | 135 +++++++++++++++++++++++++++-------------------- libarmep/libarmep.h | 14 +++-- libarmep/service.c | 9 +++- 5 files changed, 109 insertions(+), 74 deletions(-) diff --git a/arm-probe/arm-probe.c b/arm-probe/arm-probe.c index 23816a3..73eee51 100644 --- a/arm-probe/arm-probe.c +++ b/arm-probe/arm-probe.c @@ -278,7 +278,7 @@ int main(int argc, char *argv[]) } } - configure(&aep_context, NULL, "xx", aep_context.config_filepath, NULL); + configure(&aep_context, NULL, "/virtual", aep_context.config_filepath, NULL); /* * fork off the AEP service process @@ -328,7 +328,7 @@ int main(int argc, char *argv[]) if (first) { first = 0; - for (n = 0; n < aep_context.aep_shared->chans; n++) + for (n = 0; n < aep_context.aep_shared->chans + aep_context.aep_shared->vchans; n++) printf("# %s\t%s\t%s\t%s\t%s\n", aep_context.aep_shared->channel_name[n], aep_context.aep_shared->channel_name_pretty[n], diff --git a/config b/config index 41f4e92..793eb34 100644 --- a/config +++ b/config @@ -5,22 +5,25 @@ PandaBoardES-B1-ANDY # /dev/ttyACM0 - VDD_VCORE1 0.220000 -14.500000 -0.019856 0.011774 -0.000311 0.000943 0 SoCVCORE1/MPU DC_IN #8B4567 SoC - VDD_VCORE2 0.470000 -45.000000 -0.015710 0.007876 -0.002165 0.000874 0 SoCVCORE2/IVA\\_AUDIO DC_IN #7B23C6 SoC - VDD_VCORE3 0.470000 -27.500000 -0.016074 0.002175 -0.000272 0.000625 0 SoCVCORE3/CORE DC_IN #3C9869 SoC + VDD_VCORE1 0.220000 -14.500000 -0.019856 0.011774 -0.000311 0.000943 0 SoCVCORE1/MPU VBAT #ff0000 SoC + VDD_VCORE2 0.470000 -45.000000 -0.015710 0.007876 -0.002165 0.000874 0 SoCVCORE2/IVA\\_AUDIO VBAT #c00000 SoC + VDD_VCORE3 0.470000 -27.500000 -0.016074 0.002175 -0.000272 0.000625 0 SoCVCORE3/CORE VBAT #a00000 SoC /dev/ttyACM1 - VDD_1V8 0.470000 -8.000000 -0.004642 0.006818 -0.000242 0.000600 0 SoCVIO\\_1V8 DC_IN #334873 SoC - VDD_V2V1 0.470000 -38.000000 -0.016012 0.005433 -0.000305 0.000400 0 SoCVDD\\_V2V1/AUDIO DC_IN #B0DC51 SoC - VDD_V1V29 0.470000 -38.000000 -0.016701 0.005867 -0.000262 0.000367 0 SoCV1V29/LPDDR2 DC_IN #495CFF SoC + VDD_1V8 0.470000 -8.000000 -0.004642 0.006818 -0.000242 0.000600 0 SoCVIO\\_1V8 VBAT #a0c0e0 SoC + VDD_V2V1 0.470000 -38.000000 -0.016012 0.005433 -0.000305 0.000400 0 SoCVDD\\_V2V1/AUDIO VBAT #0000c0 SoC + VDD_V1V29 0.470000 -38.000000 -0.016701 0.005867 -0.000262 0.000367 0 SoCV1V29/LPDDR2 VBAT #e0e000 SoC /dev/ttyACM2 - DC_IN 0.100000 -19.500000 -0.001628 0.003839 -0.000118 0.000288 0 DC\\_IN none #E8944A - - USBHUB 0.470000 -39.000000 -0.017226 0.003700 -0.000432 0.000263 0 USBHUB DC_IN #5558EC - - VDD_3V3 0.470000 -51.000000 -0.018237 0.006000 -0.000625 0.000433 0 VDD\\_3V3 DC_IN #8E1F29 - + DC_IN 0.100000 -19.500000 -0.001628 0.003839 -0.000118 0.000288 0 DC\\_IN none #000000 - + USBHUB 0.470000 -39.000000 -0.017226 0.003700 -0.000432 0.000263 0 USBHUB VBAT #e000e0 - + VDD_3V3 0.470000 -51.000000 -0.018237 0.006000 -0.000625 0.000433 0 VDD\\_3V3 VBAT #0000ff - #/dev/ttyACM3 # ch10 0.470000 -29.000000 -0.016016 0.004660 -0.000393 0.000545 0 ch10 # ch11 0.470000 -57.000000 -0.016359 0.006300 -0.000300 0.000367 0 ch11 # ch12 0.470000 -21.000000 -0.017112 0.004148 -0.000284 0.000333 0 ch12 +/virtual + VBAT 1 0 0 0 0 0 0 VBAT DC_IN #555555 virtual + 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; diff --git a/libarmep/libarmep.h b/libarmep/libarmep.h index 49e0b31..4377b0a 100644 --- a/libarmep/libarmep.h +++ b/libarmep/libarmep.h @@ -60,6 +60,7 @@ #define IGNORE_NEG_PRIOR_TO_SAMPLES 500 #define NEGATIVE_ADJUST_SCALING_FACTOR 0.1 +#define MAX_VIRTUAL_CHANNELS 8 struct avg_mean_us { unsigned short *ring; @@ -237,12 +238,13 @@ struct aep_shared { int head; int tail; struct aep_result aep_result[1000]; - char channel_name[MAX_PROBES * CHANNELS_PER_PROBE][64]; - 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]; + char channel_name[MAX_VIRTUAL_CHANNELS + MAX_PROBES * CHANNELS_PER_PROBE][64]; + char channel_name_pretty[MAX_VIRTUAL_CHANNELS + MAX_PROBES * CHANNELS_PER_PROBE][64]; + char supply[MAX_VIRTUAL_CHANNELS + MAX_PROBES * CHANNELS_PER_PROBE][64]; + char colour[MAX_VIRTUAL_CHANNELS + MAX_PROBES * CHANNELS_PER_PROBE][16]; + char class[MAX_VIRTUAL_CHANNELS + MAX_PROBES * CHANNELS_PER_PROBE][16]; int chans; + int vchans; /* appear after probed physical channels in the arrays*/ int finished; double averages[MAX_PROBES * CHANNELS_PER_PROBE][3]; double min[MAX_PROBES * CHANNELS_PER_PROBE][3]; @@ -252,6 +254,8 @@ struct aep_shared { struct aep_context { struct aep aeps[MAX_PROBES]; + struct aep_channel vch[MAX_VIRTUAL_CHANNELS]; + int count_virtual_channels; int auto_zero; char config_filepath[256]; char configuration_name[64]; diff --git a/libarmep/service.c b/libarmep/service.c index 77683e5..c8d0208 100644 --- a/libarmep/service.c +++ b/libarmep/service.c @@ -149,7 +149,7 @@ 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) +static void copy_public_ch_info_to_shared(struct aep_shared *aep_shared, int chan, 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'; @@ -373,7 +373,7 @@ bail: if (!ch->requested) continue; - copy_public_ch_info_to_shared(aep_context->aep_shared, ch); + copy_public_ch_info_to_shared(aep_context->aep_shared, chan, ch); chan++; aep_context->aep_shared->chans = chan; @@ -384,6 +384,11 @@ bail: aep_context->aeps[m].sec_last_traffic = tv.tv_sec; } + for (m = 0; m < aep_context->count_virtual_channels; m++) { + copy_public_ch_info_to_shared(aep_context->aep_shared, chan++, &aep_context->vch[m]); + aep_context->aep_shared->vchans++; + } + } post_start: -- cgit v1.2.3