forked from osmocom/wireshark
synphasor: General cleanup
- col_...() shouldn't be under 'if (tree)'; - remove dead initializers; - use proto_tree_add_subtree() in place of ..._add_text()/...add_subtree() in one more instance; - tvb_length() --> tvb_reported_length(); - use 'proto tree *' variable instead of incorrect 'proto_item *' var in one instance; - use SYNP_... for a few macro names to prevent any possible namespace collisions; - fix some long-lines, indentation and whitespace. Change-Id: I4e0a2e5d0b5e13b72a14ec6dd3779a7104534445 Reviewed-on: https://code.wireshark.org/review/6720 Reviewed-by: Bill Meier <wmeier@newsguy.com>
This commit is contained in:
parent
009ca9fa5e
commit
32ab59f8e9
1 changed files with 101 additions and 92 deletions
|
@ -441,7 +441,7 @@ static int dissect_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, v
|
||||||
{
|
{
|
||||||
guint8 frame_type;
|
guint8 frame_type;
|
||||||
guint16 crc;
|
guint16 crc;
|
||||||
guint tvbsize = tvb_length(tvb);
|
guint tvbsize = tvb_reported_length(tvb);
|
||||||
|
|
||||||
/* some heuristics */
|
/* some heuristics */
|
||||||
if (tvbsize < 17 /* 17 bytes = header frame with only a
|
if (tvbsize < 17 /* 17 bytes = header frame with only a
|
||||||
|
@ -471,7 +471,7 @@ static int dissect_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, v
|
||||||
config_frame *frame = config_frame_fast(tvb);
|
config_frame *frame = config_frame_fast(tvb);
|
||||||
frame->fnum = pinfo->fd->num;
|
frame->fnum = pinfo->fd->num;
|
||||||
|
|
||||||
/* find a conversation, create a new if no one exists */
|
/* find a conversation, create a new one if none exists */
|
||||||
conversation = find_or_create_conversation(pinfo);
|
conversation = find_or_create_conversation(pinfo);
|
||||||
|
|
||||||
/* remove data from a previous CFG-2 frame, only
|
/* remove data from a previous CFG-2 frame, only
|
||||||
|
@ -496,10 +496,10 @@ static int dissect_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, v
|
||||||
}
|
}
|
||||||
} /* if (!visited) */
|
} /* if (!visited) */
|
||||||
|
|
||||||
if (tree) { /* we are being asked for details */
|
{
|
||||||
proto_tree *synphasor_tree = NULL;
|
proto_tree *synphasor_tree;
|
||||||
proto_item *temp_item = NULL;
|
proto_item *temp_item;
|
||||||
proto_item *sub_item = NULL;
|
proto_item *sub_item;
|
||||||
|
|
||||||
gint offset;
|
gint offset;
|
||||||
guint16 framesize;
|
guint16 framesize;
|
||||||
|
@ -550,9 +550,9 @@ static int dissect_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, v
|
||||||
}
|
}
|
||||||
|
|
||||||
/*offset += 2;*/ /* CRC */
|
/*offset += 2;*/ /* CRC */
|
||||||
} /* if (tree) */
|
}
|
||||||
|
|
||||||
return tvb_length(tvb);
|
return tvb_reported_length(tvb);
|
||||||
} /* dissect_synphasor() */
|
} /* dissect_synphasor() */
|
||||||
|
|
||||||
/* called for synchrophasors over UDP */
|
/* called for synchrophasors over UDP */
|
||||||
|
@ -571,7 +571,7 @@ static int dissect_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void
|
||||||
{
|
{
|
||||||
tcp_dissect_pdus(tvb, pinfo, tree, TRUE, 4, get_pdu_length, dissect_common, data);
|
tcp_dissect_pdus(tvb, pinfo, tree, TRUE, 4, get_pdu_length, dissect_common, data);
|
||||||
|
|
||||||
return tvb_length(tvb);
|
return tvb_reported_length(tvb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -609,8 +609,7 @@ static gint dissect_header(tvbuff_t *tvb, proto_tree *tree)
|
||||||
|
|
||||||
/* FRACSEC */
|
/* FRACSEC */
|
||||||
/* time quality flags */
|
/* time quality flags */
|
||||||
temp_item = proto_tree_add_text(tree, tvb, offset, 1, "Time quality flags");
|
temp_tree = proto_tree_add_subtree(tree, tvb, offset, 1, ett_timequal, NULL, "Time quality flags");
|
||||||
temp_tree = proto_item_add_subtree(temp_item, ett_timequal);
|
|
||||||
proto_tree_add_item(temp_tree, hf_timeqal_lsdir, tvb, offset, 1, ENC_BIG_ENDIAN);
|
proto_tree_add_item(temp_tree, hf_timeqal_lsdir, tvb, offset, 1, ENC_BIG_ENDIAN);
|
||||||
proto_tree_add_item(temp_tree, hf_timeqal_lsocc, tvb, offset, 1, ENC_BIG_ENDIAN);
|
proto_tree_add_item(temp_tree, hf_timeqal_lsocc, tvb, offset, 1, ENC_BIG_ENDIAN);
|
||||||
proto_tree_add_item(temp_tree, hf_timeqal_lspend, tvb, offset, 1, ENC_BIG_ENDIAN);
|
proto_tree_add_item(temp_tree, hf_timeqal_lspend, tvb, offset, 1, ENC_BIG_ENDIAN);
|
||||||
|
@ -632,9 +631,7 @@ static gint dissect_DIGUNIT(tvbuff_t *tvb, proto_tree *tree, gint offset, gint c
|
||||||
/* dissects a configuration frame (type 1 and 2) and adds fields to 'config_item' */
|
/* dissects a configuration frame (type 1 and 2) and adds fields to 'config_item' */
|
||||||
static int dissect_config_frame(tvbuff_t *tvb, proto_item *config_item)
|
static int dissect_config_frame(tvbuff_t *tvb, proto_item *config_item)
|
||||||
{
|
{
|
||||||
proto_tree *config_tree = NULL;
|
proto_tree *config_tree;
|
||||||
proto_item *temp_item = NULL;
|
|
||||||
proto_tree *temp_tree = NULL;
|
|
||||||
gint offset = 0, j;
|
gint offset = 0, j;
|
||||||
guint16 num_pmu;
|
guint16 num_pmu;
|
||||||
|
|
||||||
|
@ -652,8 +649,9 @@ static int dissect_config_frame(tvbuff_t *tvb, proto_item *config_item)
|
||||||
/* dissect the repeating PMU blocks */
|
/* dissect the repeating PMU blocks */
|
||||||
for (j = 0; j < num_pmu; j++) {
|
for (j = 0; j < num_pmu; j++) {
|
||||||
guint16 num_ph, num_an, num_dg;
|
guint16 num_ph, num_an, num_dg;
|
||||||
proto_item *station_item = NULL;
|
proto_item *station_item;
|
||||||
proto_tree *station_tree = NULL;
|
proto_tree *station_tree;
|
||||||
|
proto_tree *temp_tree;
|
||||||
char *str;
|
char *str;
|
||||||
|
|
||||||
gint oldoffset = offset; /* to calculate the length of the whole PMU block later */
|
gint oldoffset = offset; /* to calculate the length of the whole PMU block later */
|
||||||
|
@ -661,15 +659,16 @@ static int dissect_config_frame(tvbuff_t *tvb, proto_item *config_item)
|
||||||
/* STN with new tree to add the rest of the PMU block */
|
/* STN with new tree to add the rest of the PMU block */
|
||||||
str = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, CHNAM_LEN, ENC_ASCII);
|
str = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, CHNAM_LEN, ENC_ASCII);
|
||||||
station_tree = proto_tree_add_subtree_format(config_tree, tvb, offset, CHNAM_LEN,
|
station_tree = proto_tree_add_subtree_format(config_tree, tvb, offset, CHNAM_LEN,
|
||||||
ett_conf_station, &station_item, "Station #%i: \"%s\"", j + 1, str);
|
ett_conf_station, &station_item,
|
||||||
|
"Station #%i: \"%s\"", j + 1, str);
|
||||||
offset += CHNAM_LEN;
|
offset += CHNAM_LEN;
|
||||||
|
|
||||||
/* IDCODE */
|
/* IDCODE */
|
||||||
proto_tree_add_item(station_tree, hf_idcode, tvb, offset, 2, ENC_BIG_ENDIAN); offset += 2;
|
proto_tree_add_item(station_tree, hf_idcode, tvb, offset, 2, ENC_BIG_ENDIAN); offset += 2;
|
||||||
|
|
||||||
/* FORMAT */
|
/* FORMAT */
|
||||||
temp_item = proto_tree_add_text(station_tree, tvb, offset, 2, "Data format in data frame");
|
temp_tree = proto_tree_add_subtree(station_tree, tvb, offset, 2, ett_conf_format, NULL,
|
||||||
temp_tree = proto_item_add_subtree(temp_item, ett_conf_format);
|
"Data format in data frame");
|
||||||
proto_tree_add_item(temp_tree, hf_conf_formatb3, tvb, offset, 2, ENC_BIG_ENDIAN);
|
proto_tree_add_item(temp_tree, hf_conf_formatb3, tvb, offset, 2, ENC_BIG_ENDIAN);
|
||||||
proto_tree_add_item(temp_tree, hf_conf_formatb2, tvb, offset, 2, ENC_BIG_ENDIAN);
|
proto_tree_add_item(temp_tree, hf_conf_formatb2, tvb, offset, 2, ENC_BIG_ENDIAN);
|
||||||
proto_tree_add_item(temp_tree, hf_conf_formatb1, tvb, offset, 2, ENC_BIG_ENDIAN);
|
proto_tree_add_item(temp_tree, hf_conf_formatb1, tvb, offset, 2, ENC_BIG_ENDIAN);
|
||||||
|
@ -705,6 +704,7 @@ static int dissect_config_frame(tvbuff_t *tvb, proto_item *config_item)
|
||||||
|
|
||||||
/* DATA_RATE */
|
/* DATA_RATE */
|
||||||
{
|
{
|
||||||
|
proto_item *temp_item;
|
||||||
gint16 tmp = tvb_get_ntohs(tvb, offset);
|
gint16 tmp = tvb_get_ntohs(tvb, offset);
|
||||||
temp_item = proto_tree_add_text(config_tree, tvb, offset, 2, "Rate of transmission: "); offset += 2;
|
temp_item = proto_tree_add_text(config_tree, tvb, offset, 2, "Rate of transmission: "); offset += 2;
|
||||||
if (tmp > 0)
|
if (tmp > 0)
|
||||||
|
@ -721,8 +721,9 @@ static gint dissect_PHASORS(tvbuff_t *tvb, proto_tree *tree, config_block *block
|
||||||
static gint dissect_DFREQ (tvbuff_t *tvb, proto_tree *tree, config_block *block, gint offset);
|
static gint dissect_DFREQ (tvbuff_t *tvb, proto_tree *tree, config_block *block, gint offset);
|
||||||
static gint dissect_ANALOG (tvbuff_t *tvb, proto_tree *tree, config_block *block, gint offset);
|
static gint dissect_ANALOG (tvbuff_t *tvb, proto_tree *tree, config_block *block, gint offset);
|
||||||
static gint dissect_DIGITAL(tvbuff_t *tvb, proto_tree *tree, config_block *block, gint offset);
|
static gint dissect_DIGITAL(tvbuff_t *tvb, proto_tree *tree, config_block *block, gint offset);
|
||||||
|
|
||||||
/* calculates the size (in bytes) of a data frame that the config_block describes */
|
/* calculates the size (in bytes) of a data frame that the config_block describes */
|
||||||
#define BLOCKSIZE(x) (2 /* STAT */ \
|
#define SYNP_BLOCKSIZE(x) (2 /* STAT */ \
|
||||||
+ wmem_array_get_count((x).phasors) * (integer == (x).format_ph ? 4 : 8) /* PHASORS */ \
|
+ wmem_array_get_count((x).phasors) * (integer == (x).format_ph ? 4 : 8) /* PHASORS */ \
|
||||||
+ (integer == (x).format_fr ? 4 : 8) /* (D)FREQ */ \
|
+ (integer == (x).format_fr ? 4 : 8) /* (D)FREQ */ \
|
||||||
+ wmem_array_get_count((x).analogs) * (integer == (x).format_an ? 2 : 4) /* ANALOG */ \
|
+ wmem_array_get_count((x).analogs) * (integer == (x).format_an ? 2 : 4) /* ANALOG */ \
|
||||||
|
@ -733,7 +734,7 @@ static int dissect_data_frame(tvbuff_t *tvb,
|
||||||
proto_item *data_item, /* all items are placed beneath this item */
|
proto_item *data_item, /* all items are placed beneath this item */
|
||||||
packet_info *pinfo) /* used to find the data from a CFG-2 frame */
|
packet_info *pinfo) /* used to find the data from a CFG-2 frame */
|
||||||
{
|
{
|
||||||
proto_tree *data_tree = NULL;
|
proto_tree *data_tree;
|
||||||
gint offset = 0;
|
gint offset = 0;
|
||||||
guint i;
|
guint i;
|
||||||
config_frame *conf;
|
config_frame *conf;
|
||||||
|
@ -752,10 +753,10 @@ static int dissect_data_frame(tvbuff_t *tvb,
|
||||||
size_t reported_size = 0;
|
size_t reported_size = 0;
|
||||||
for (i = 0; i < wmem_array_get_count(conf->config_blocks); i++) {
|
for (i = 0; i < wmem_array_get_count(conf->config_blocks); i++) {
|
||||||
config_block *block = (config_block*)wmem_array_index(conf->config_blocks, i);
|
config_block *block = (config_block*)wmem_array_index(conf->config_blocks, i);
|
||||||
reported_size += BLOCKSIZE(*block);
|
reported_size += SYNP_BLOCKSIZE(*block);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tvb_length(tvb) == reported_size) {
|
if (tvb_reported_length(tvb) == reported_size) {
|
||||||
proto_item_append_text(data_item, ", using frame number %"G_GUINT32_FORMAT" as configuration frame",
|
proto_item_append_text(data_item, ", using frame number %"G_GUINT32_FORMAT" as configuration frame",
|
||||||
conf->fnum);
|
conf->fnum);
|
||||||
config_found = TRUE;
|
config_found = TRUE;
|
||||||
|
@ -772,13 +773,13 @@ static int dissect_data_frame(tvbuff_t *tvb,
|
||||||
for (i = 0; i < wmem_array_get_count(conf->config_blocks); i++) {
|
for (i = 0; i < wmem_array_get_count(conf->config_blocks); i++) {
|
||||||
config_block *block = (config_block*)wmem_array_index(conf->config_blocks, i);
|
config_block *block = (config_block*)wmem_array_index(conf->config_blocks, i);
|
||||||
|
|
||||||
proto_item *block_item;
|
proto_tree *block_tree = proto_tree_add_subtree_format(data_tree, tvb, offset, SYNP_BLOCKSIZE(*block),
|
||||||
proto_tree *block_tree = proto_tree_add_subtree_format(data_tree, tvb, offset, BLOCKSIZE(*block),
|
ett_data_block, NULL,
|
||||||
ett_data_block, &block_item, "Station: \"%s\"", block->name);
|
"Station: \"%s\"", block->name);
|
||||||
|
|
||||||
/* STAT */
|
/* STAT */
|
||||||
proto_item *temp_item = proto_tree_add_text(block_tree, tvb, offset, 2, "Flags");
|
proto_tree *temp_tree = proto_tree_add_subtree(block_tree, tvb, offset, 2, ett_data_stat, NULL, "Flags");
|
||||||
proto_tree *temp_tree = proto_item_add_subtree(temp_item, ett_data_stat);
|
|
||||||
proto_tree_add_item(temp_tree, hf_data_statb15, tvb, offset, 2, ENC_BIG_ENDIAN);
|
proto_tree_add_item(temp_tree, hf_data_statb15, tvb, offset, 2, ENC_BIG_ENDIAN);
|
||||||
proto_tree_add_item(temp_tree, hf_data_statb14, tvb, offset, 2, ENC_BIG_ENDIAN);
|
proto_tree_add_item(temp_tree, hf_data_statb14, tvb, offset, 2, ENC_BIG_ENDIAN);
|
||||||
proto_tree_add_item(temp_tree, hf_data_statb13, tvb, offset, 2, ENC_BIG_ENDIAN);
|
proto_tree_add_item(temp_tree, hf_data_statb13, tvb, offset, 2, ENC_BIG_ENDIAN);
|
||||||
|
@ -790,10 +791,10 @@ static int dissect_data_frame(tvbuff_t *tvb,
|
||||||
offset += 2;
|
offset += 2;
|
||||||
|
|
||||||
/* PHASORS, (D)FREQ, ANALOG, and DIGITAL */
|
/* PHASORS, (D)FREQ, ANALOG, and DIGITAL */
|
||||||
offset = dissect_PHASORS(tvb, block_item, block, offset);
|
offset = dissect_PHASORS(tvb, block_tree, block, offset);
|
||||||
offset = dissect_DFREQ (tvb, block_item, block, offset);
|
offset = dissect_DFREQ (tvb, block_tree, block, offset);
|
||||||
offset = dissect_ANALOG (tvb, block_item, block, offset);
|
offset = dissect_ANALOG (tvb, block_tree, block, offset);
|
||||||
offset = dissect_DIGITAL(tvb, block_item, block, offset);
|
offset = dissect_DIGITAL(tvb, block_tree, block, offset);
|
||||||
}
|
}
|
||||||
return offset;
|
return offset;
|
||||||
} /* dissect_data_frame() */
|
} /* dissect_data_frame() */
|
||||||
|
@ -807,8 +808,8 @@ static int dissect_command_frame(tvbuff_t *tvb,
|
||||||
proto_item *command_item,
|
proto_item *command_item,
|
||||||
packet_info *pinfo)
|
packet_info *pinfo)
|
||||||
{
|
{
|
||||||
proto_tree *command_tree = NULL;
|
proto_tree *command_tree;
|
||||||
guint tvbsize = tvb_length(tvb);
|
guint tvbsize = tvb_reported_length(tvb);
|
||||||
const char *s;
|
const char *s;
|
||||||
|
|
||||||
proto_item_set_text(command_item, "Command data");
|
proto_item_set_text(command_item, "Command data");
|
||||||
|
@ -824,9 +825,9 @@ static int dissect_command_frame(tvbuff_t *tvb,
|
||||||
if (tvbsize > 2) {
|
if (tvbsize > 2) {
|
||||||
if (tvb_get_ntohs(tvb, 0) == 0x0008) {
|
if (tvb_get_ntohs(tvb, 0) == 0x0008) {
|
||||||
/* Command: Extended Frame, the extra data is ok */
|
/* Command: Extended Frame, the extra data is ok */
|
||||||
proto_item* i = proto_tree_add_text(command_tree, tvb, 2, tvbsize - 2, "Extended frame data");
|
proto_item *ti = proto_tree_add_text(command_tree, tvb, 2, tvbsize - 2, "Extended frame data");
|
||||||
if (tvbsize % 2)
|
if (tvbsize % 2)
|
||||||
proto_item_append_text(i, ", but size not multiple of 16-bit word");
|
proto_item_append_text(ti, ", but size not multiple of 16-bit word");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
proto_tree_add_text(command_tree, tvb, 2, tvbsize - 2, "Unknown data");
|
proto_tree_add_text(command_tree, tvb, 2, tvbsize - 2, "Unknown data");
|
||||||
|
@ -885,20 +886,21 @@ static int dissect_single_phasor(tvbuff_t *tvb, int offset,
|
||||||
/* used by 'dissect_data_frame()' to dissect the PHASORS field */
|
/* used by 'dissect_data_frame()' to dissect the PHASORS field */
|
||||||
static gint dissect_PHASORS(tvbuff_t *tvb, proto_tree *tree, config_block *block, gint offset)
|
static gint dissect_PHASORS(tvbuff_t *tvb, proto_tree *tree, config_block *block, gint offset)
|
||||||
{
|
{
|
||||||
proto_item *temp_item = NULL;
|
proto_tree *phasor_tree;
|
||||||
proto_tree *phasor_tree = NULL;
|
|
||||||
guint length;
|
guint length;
|
||||||
gint j,
|
gint j;
|
||||||
cnt = wmem_array_get_count(block->phasors); /* number of phasors to dissect */
|
gint cnt = wmem_array_get_count(block->phasors); /* number of phasors to dissect */
|
||||||
|
|
||||||
if (0 == cnt)
|
if (0 == cnt)
|
||||||
return offset;
|
return offset;
|
||||||
|
|
||||||
length = wmem_array_get_count(block->phasors) * (floating_point == block->format_ph ? 8 : 4);
|
length = wmem_array_get_count(block->phasors) * (floating_point == block->format_ph ? 8 : 4);
|
||||||
phasor_tree = proto_tree_add_subtree_format(tree, tvb, offset, length, ett_data_phasors, NULL, "Phasors (%u)", cnt);
|
phasor_tree = proto_tree_add_subtree_format(tree, tvb, offset, length, ett_data_phasors, NULL,
|
||||||
|
"Phasors (%u)", cnt);
|
||||||
|
|
||||||
/* dissect a phasor for every phasor_info saved in the config_block */
|
/* dissect a phasor for every phasor_info saved in the config_block */
|
||||||
for (j = 0; j < cnt; j++) {
|
for (j = 0; j < cnt; j++) {
|
||||||
|
proto_item *temp_item;
|
||||||
double mag, phase;
|
double mag, phase;
|
||||||
phasor_info *pi;
|
phasor_info *pi;
|
||||||
|
|
||||||
|
@ -916,15 +918,15 @@ static gint dissect_PHASORS(tvbuff_t *tvb, proto_tree *tree, config_block *block
|
||||||
if (integer == block->format_ph)
|
if (integer == block->format_ph)
|
||||||
mag = (mag * pi->conv) * 0.00001;
|
mag = (mag * pi->conv) * 0.00001;
|
||||||
|
|
||||||
#define ANGLE "/_"
|
#define SYNP_ANGLE "/_"
|
||||||
#define DEGREE "\xC2\xB0" /* DEGREE signs in UTF-8 */
|
#define SYNP_DEGREE "\xC2\xB0" /* DEGREE signs in UTF-8 */
|
||||||
|
|
||||||
proto_item_append_text(temp_item, ", %10.2f%c" ANGLE "%7.2f" DEGREE,
|
proto_item_append_text(temp_item, ", %10.2f%c" SYNP_ANGLE "%7.2f" SYNP_DEGREE,
|
||||||
mag,
|
mag,
|
||||||
V == pi->unit ? 'V' : 'A',
|
V == pi->unit ? 'V' : 'A',
|
||||||
phase *180.0/G_PI);
|
phase *180.0/G_PI);
|
||||||
#undef ANGLE
|
#undef SYNP_ANGLE
|
||||||
#undef DEGREE
|
#undef SYNP_DEGREE
|
||||||
}
|
}
|
||||||
return offset;
|
return offset;
|
||||||
}
|
}
|
||||||
|
@ -963,19 +965,20 @@ static gint dissect_DFREQ(tvbuff_t *tvb, proto_tree *tree, config_block *block,
|
||||||
/* used by 'dissect_data_frame()' to dissect the ANALOG field */
|
/* used by 'dissect_data_frame()' to dissect the ANALOG field */
|
||||||
static gint dissect_ANALOG(tvbuff_t *tvb, proto_tree *tree, config_block *block, gint offset)
|
static gint dissect_ANALOG(tvbuff_t *tvb, proto_tree *tree, config_block *block, gint offset)
|
||||||
{
|
{
|
||||||
proto_tree *analog_tree = NULL;
|
proto_tree *analog_tree;
|
||||||
proto_item *temp_item = NULL;
|
|
||||||
guint length;
|
guint length;
|
||||||
gint j,
|
gint j;
|
||||||
cnt = wmem_array_get_count(block->analogs); /* number of analog values to dissect */
|
gint cnt = wmem_array_get_count(block->analogs); /* number of analog values to dissect */
|
||||||
|
|
||||||
if (0 == cnt)
|
if (0 == cnt)
|
||||||
return offset;
|
return offset;
|
||||||
|
|
||||||
length = wmem_array_get_count(block->analogs) * (floating_point == block->format_an ? 4 : 2);
|
length = wmem_array_get_count(block->analogs) * (floating_point == block->format_an ? 4 : 2);
|
||||||
analog_tree = proto_tree_add_subtree_format(tree, tvb, offset, length, ett_data_analog, NULL, "Analog values (%u)", cnt);
|
analog_tree = proto_tree_add_subtree_format(tree, tvb, offset, length, ett_data_analog, NULL,
|
||||||
|
"Analog values (%u)", cnt);
|
||||||
|
|
||||||
for (j = 0; j < cnt; j++) {
|
for (j = 0; j < cnt; j++) {
|
||||||
|
proto_item *temp_item;
|
||||||
analog_info *ai = (analog_info *)wmem_array_index(block->analogs, j);
|
analog_info *ai = (analog_info *)wmem_array_index(block->analogs, j);
|
||||||
|
|
||||||
temp_item = proto_tree_add_text(analog_tree, tvb, offset,
|
temp_item = proto_tree_add_text(analog_tree, tvb, offset,
|
||||||
|
@ -988,7 +991,7 @@ static gint dissect_ANALOG(tvbuff_t *tvb, proto_tree *tree, config_block *block,
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* the "standard" doesn't say if this is signed or unsigned,
|
/* the "standard" doesn't say if this is signed or unsigned,
|
||||||
* so I just use gint16, the scaling of the conversation factor
|
* so I just use gint16; the scaling of the conversation factor
|
||||||
* is also "user defined", so I just write it after the analog value */
|
* is also "user defined", so I just write it after the analog value */
|
||||||
gint16 tmp = tvb_get_ntohs(tvb, offset); offset += 2;
|
gint16 tmp = tvb_get_ntohs(tvb, offset); offset += 2;
|
||||||
proto_item_append_text(temp_item, ", %" G_GINT16_FORMAT " (conversation factor: %#06x)",
|
proto_item_append_text(temp_item, ", %" G_GINT16_FORMAT " (conversation factor: %#06x)",
|
||||||
|
@ -1001,13 +1004,14 @@ static gint dissect_ANALOG(tvbuff_t *tvb, proto_tree *tree, config_block *block,
|
||||||
/* used by 'dissect_data_frame()' to dissect the DIGITAL field */
|
/* used by 'dissect_data_frame()' to dissect the DIGITAL field */
|
||||||
static gint dissect_DIGITAL(tvbuff_t *tvb, proto_tree *tree, config_block *block, gint offset)
|
static gint dissect_DIGITAL(tvbuff_t *tvb, proto_tree *tree, config_block *block, gint offset)
|
||||||
{
|
{
|
||||||
gint j,
|
gint j;
|
||||||
cnt = block->num_dg; /* number of digital status words to dissect */
|
gint cnt = block->num_dg; /* number of digital status words to dissect */
|
||||||
|
|
||||||
if (0 == cnt)
|
if (0 == cnt)
|
||||||
return offset;
|
return offset;
|
||||||
|
|
||||||
tree = proto_tree_add_subtree_format(tree, tvb, offset, cnt * 2, ett_data_digital, NULL, "Digital status words (%u)", cnt);
|
tree = proto_tree_add_subtree_format(tree, tvb, offset, cnt * 2, ett_data_digital, NULL,
|
||||||
|
"Digital status words (%u)", cnt);
|
||||||
|
|
||||||
for (j = 0; j < cnt; j++) {
|
for (j = 0; j < cnt; j++) {
|
||||||
guint16 tmp = tvb_get_ntohs(tvb, offset);
|
guint16 tmp = tvb_get_ntohs(tvb, offset);
|
||||||
|
@ -1030,7 +1034,8 @@ static gint dissect_PHUNIT(tvbuff_t *tvb, proto_tree *tree, gint offset, gint cn
|
||||||
if (0 == cnt)
|
if (0 == cnt)
|
||||||
return offset;
|
return offset;
|
||||||
|
|
||||||
temp_tree = proto_tree_add_subtree_format(tree, tvb, offset, 4 * cnt, ett_conf_phconv, NULL, "Phasor conversation factors (%u)", cnt);
|
temp_tree = proto_tree_add_subtree_format(tree, tvb, offset, 4 * cnt, ett_conf_phconv, NULL,
|
||||||
|
"Phasor conversation factors (%u)", cnt);
|
||||||
|
|
||||||
/* Conversion factor for phasor channels. Four bytes for each phasor.
|
/* Conversion factor for phasor channels. Four bytes for each phasor.
|
||||||
* MSB: 0 = voltage, 1 = current
|
* MSB: 0 = voltage, 1 = current
|
||||||
|
@ -1059,7 +1064,8 @@ static gint dissect_ANUNIT(tvbuff_t *tvb, proto_tree *tree, gint offset, gint cn
|
||||||
if (0 == cnt)
|
if (0 == cnt)
|
||||||
return offset;
|
return offset;
|
||||||
|
|
||||||
temp_tree = proto_tree_add_subtree_format(tree, tvb, offset, 4 * cnt, ett_conf_anconv, NULL, "Analog values conversation factors (%u)", cnt);
|
temp_tree = proto_tree_add_subtree_format(tree, tvb, offset, 4 * cnt, ett_conf_anconv, NULL,
|
||||||
|
"Analog values conversation factors (%u)", cnt);
|
||||||
|
|
||||||
/* Conversation factor for analog channels. Four bytes for each analog value.
|
/* Conversation factor for analog channels. Four bytes for each analog value.
|
||||||
* MSB: see 'synphasor_conf_anconvnames' in 'synphasor_strings.c'
|
* MSB: see 'synphasor_conf_anconvnames' in 'synphasor_strings.c'
|
||||||
|
@ -1094,7 +1100,8 @@ static gint dissect_DIGUNIT(tvbuff_t *tvb, proto_tree *tree, gint offset, gint c
|
||||||
if (0 == cnt)
|
if (0 == cnt)
|
||||||
return offset;
|
return offset;
|
||||||
|
|
||||||
temp_tree = proto_tree_add_subtree_format(tree, tvb, offset, 4 * cnt, ett_conf_dgmask, NULL, "Masks for digital status words (%u)", cnt);
|
temp_tree = proto_tree_add_subtree_format(tree, tvb, offset, 4 * cnt, ett_conf_dgmask, NULL,
|
||||||
|
"Masks for digital status words (%u)", cnt);
|
||||||
|
|
||||||
/* Mask words for digital status words. Two 16-bit words for each digital word. The first
|
/* Mask words for digital status words. Two 16-bit words for each digital word. The first
|
||||||
* inidcates the normal status of the inputs, the second indicated the valid bits in
|
* inidcates the normal status of the inputs, the second indicated the valid bits in
|
||||||
|
@ -1122,7 +1129,8 @@ static gint dissect_CHNAM(tvbuff_t *tvb, proto_tree *tree, gint offset, gint cnt
|
||||||
if (0 == cnt)
|
if (0 == cnt)
|
||||||
return offset;
|
return offset;
|
||||||
|
|
||||||
temp_tree = proto_tree_add_subtree_format(tree, tvb, offset, CHNAM_LEN * cnt, ett_conf_phnam, NULL, "%ss (%u)", prefix, cnt);
|
temp_tree = proto_tree_add_subtree_format(tree, tvb, offset, CHNAM_LEN * cnt, ett_conf_phnam, NULL,
|
||||||
|
"%ss (%u)", prefix, cnt);
|
||||||
|
|
||||||
/* dissect the 'cnt' channel names */
|
/* dissect the 'cnt' channel names */
|
||||||
for (i = 0; i < cnt; i++) {
|
for (i = 0; i < cnt; i++) {
|
||||||
|
@ -1143,6 +1151,7 @@ void proto_register_synphasor(void)
|
||||||
{ &hf_sync,
|
{ &hf_sync,
|
||||||
{ "Synchronization word", "synphasor.sync", FT_UINT16, BASE_HEX,
|
{ "Synchronization word", "synphasor.sync", FT_UINT16, BASE_HEX,
|
||||||
NULL, 0x0, NULL, HFILL }},
|
NULL, 0x0, NULL, HFILL }},
|
||||||
|
|
||||||
/* Flags in the Sync word */
|
/* Flags in the Sync word */
|
||||||
{ &hf_sync_frtype,
|
{ &hf_sync_frtype,
|
||||||
{ "Frame Type", "synphasor.frtype", FT_UINT16, BASE_HEX,
|
{ "Frame Type", "synphasor.frtype", FT_UINT16, BASE_HEX,
|
||||||
|
|
Loading…
Reference in a new issue