Add decode_dm flex option (closes #2241)
This commit is contained in:
parent
e67a9f586b
commit
70cb2386b0
3 changed files with 24 additions and 4 deletions
|
@ -379,6 +379,7 @@ Available options are:
|
|||
invert : invert all bits
|
||||
reflect : reflect each byte (MSB first to MSB last)
|
||||
decode_uart : UART 8n1 (10-to-8) decode
|
||||
decode_dm : Differential Manchester decode
|
||||
match=<bits> : only match if the <bits> are found
|
||||
preamble=<bits> : match and align at the <bits> preamble
|
||||
<bits> is a row spec of {<bit count>}<bits as hex number>
|
||||
|
@ -415,14 +416,14 @@ E.g. -X "n=doorbell,m=OOK_PWM,s=400,l=800,r=7000,g=1000,match={24}0xa9878c,repea
|
|||
[-M time[:<options>]|protocol|level|noise[:<secs>]|stats|bits] Add various metadata to every output line.
|
||||
Use "time" to add current date and time meta data (preset for live inputs).
|
||||
Use "time:rel" to add sample position meta data (preset for read-file and stdin).
|
||||
Use "time:unix" to show the seconds since unix epoch as time meta data.
|
||||
Use "time:unix" to show the seconds since unix epoch as time meta data. This is always UTC.
|
||||
Use "time:iso" to show the time with ISO-8601 format (YYYY-MM-DD"T"hh:mm:ss).
|
||||
Use "time:off" to remove time meta data.
|
||||
Use "time:usec" to add microseconds to date time meta data.
|
||||
Use "time:tz" to output time with timezone offset.
|
||||
Use "time:utc" to output time in UTC.
|
||||
(this may also be accomplished by invocation with TZ environment variable set).
|
||||
"usec" and "utc" can be combined with other options, eg. "time:unix:utc:usec".
|
||||
"usec" and "utc" can be combined with other options, eg. "time:iso:utc" or "time:unix:usec".
|
||||
Use "replay[:N]" to replay file inputs at (N-times) realtime.
|
||||
Use "protocol" / "noprotocol" to output the decoder protocol number meta data.
|
||||
Use "level" to add Modulation, Frequency, RSSI, SNR, and Noise meta data.
|
||||
|
|
|
@ -299,6 +299,9 @@ reflect : reflect each byte (MSB first to MSB last)
|
|||
decode_uart : UART 8n1 (10\-to\-8) decode
|
||||
.RE
|
||||
.RS
|
||||
decode_dm : Differential Manchester decode
|
||||
.RE
|
||||
.RS
|
||||
match=<bits> : only match if the <bits> are found
|
||||
.RE
|
||||
.RS
|
||||
|
@ -382,7 +385,7 @@ Use "time" to add current date and time meta data (preset for live inputs).
|
|||
Use "time:rel" to add sample position meta data (preset for read\-file and stdin).
|
||||
.RE
|
||||
.RS
|
||||
Use "time:unix" to show the seconds since unix epoch as time meta data.
|
||||
Use "time:unix" to show the seconds since unix epoch as time meta data. This is always UTC.
|
||||
.RE
|
||||
.RS
|
||||
Use "time:iso" to show the time with ISO\-8601 format (YYYY\-MM\-DD"T"hh:mm:ss).
|
||||
|
@ -403,7 +406,7 @@ Use "time:utc" to output time in UTC.
|
|||
(this may also be accomplished by invocation with TZ environment variable set).
|
||||
.RE
|
||||
.RS
|
||||
"usec" and "utc" can be combined with other options, eg. "time:unix:utc:usec".
|
||||
"usec" and "utc" can be combined with other options, eg. "time:iso:utc" or "time:unix:usec".
|
||||
.RE
|
||||
.RS
|
||||
Use "replay[:N]" to replay file inputs at (N\-times) realtime.
|
||||
|
|
|
@ -97,6 +97,7 @@ struct flex_params {
|
|||
uint32_t symbol_sync;
|
||||
struct flex_get getter[GETTER_SLOTS];
|
||||
unsigned decode_uart;
|
||||
unsigned decode_dm;
|
||||
char const *fields[7 + GETTER_SLOTS + 1]; // NOTE: needs to match output_fields
|
||||
};
|
||||
|
||||
|
@ -254,6 +255,18 @@ static int flex_callback(r_device *decoder, bitbuffer_t *bitbuffer)
|
|||
}
|
||||
}
|
||||
|
||||
if (params->decode_dm) {
|
||||
for (i = 0; i < bitbuffer->num_rows; i++) {
|
||||
// TODO: refactor to bitbuffer_decode_dm_row()
|
||||
unsigned len = bitbuffer->bits_per_row[i];
|
||||
bitbuffer_t tmp = {0};
|
||||
bitbuffer_differential_manchester_decode(bitbuffer, i, 0, &tmp, len);
|
||||
len = tmp.bits_per_row[0];
|
||||
memcpy(bitbuffer->bb[i], tmp.bb[0], (len + 7) / 8); // safe to write over: can only be shorter
|
||||
bitbuffer->bits_per_row[i] = len;
|
||||
}
|
||||
}
|
||||
|
||||
if (decoder->verbose) {
|
||||
fprintf(stderr, "%s: ", params->name);
|
||||
bitbuffer_print(bitbuffer);
|
||||
|
@ -399,6 +412,7 @@ static void help(void)
|
|||
"\tinvert : invert all bits\n"
|
||||
"\treflect : reflect each byte (MSB first to MSB last)\n"
|
||||
"\tdecode_uart : UART 8n1 (10-to-8) decode\n"
|
||||
"\tdecode_dm : Differential Manchester decode\n"
|
||||
"\tmatch=<bits> : only match if the <bits> are found\n"
|
||||
"\tpreamble=<bits> : match and align at the <bits> preamble\n"
|
||||
"\t\t<bits> is a row spec of {<bit count>}<bits as hex number>\n"
|
||||
|
@ -664,6 +678,8 @@ r_device *flex_create_device(char *spec)
|
|||
|
||||
else if (!strcasecmp(key, "decode_uart"))
|
||||
params->decode_uart = val ? atoi(val) : 1;
|
||||
else if (!strcasecmp(key, "decode_dm"))
|
||||
params->decode_dm = val ? atoi(val) : 1;
|
||||
|
||||
else if (!strcasecmp(key, "symbol_zero"))
|
||||
params->symbol_zero = parse_symbol(val);
|
||||
|
|
Loading…
Add table
Reference in a new issue