-
Notifications
You must be signed in to change notification settings - Fork 881
Decodings
Wireless protocols may use sophisticated encodings to prevent transmission errors or increase their energy efficiency. While this is a great idea for designing good IoT protocols it somehow hinders you investigating the (true) transmitted data.
Therefore URH comes with a powerful decoding component. You can access it via Edit -> Decoding
from the main menu or by selecting ...
as decoding in the analysis tab. This will open the decoding dialog:
A decoding consists of (at least one) primitives that are chained together and processed based on their position in the list from top to bottom. You can add primitives by drag&drop.
You can preview the effect of your decoding with the fields in the lower area of the dialog. This way you can make experiments without leaving the dialog.
Have a very though encoding and can't find a way to build it with the given primitives? No worries! You can program your decoding in your favored language and use it right in URH!
The interface for your external program is simple:
- Read the input as string ('11000') from STDIN
- Write the result to STDOUT
Consider this example C program:
#include <stdio.h>
#include <string.h>
int main(int argc, char **argv)
{
int i, count, what;
if(argc>2)
{
if(argv[1][0]=='d')
{
for(i = 0; i < strlen(argv[2]); i++)
if(argv[2][i] == '0') printf("000");
else printf("11");
}
else
{
count = 0;
what = -1;
for(i = 0; i < strlen(argv[2]); i++)
{
if(argv[2][i] == '0')
{
if(what == 1) count = 0;
what = 0;
count++;
if(count == 3)
{
putchar('0');
count = 0;
}
}
else
{
if(what == 0) count = 0;
what = 1;
count++;
if(count == 2)
{
putchar('1');
count = 0;
}
}
}
}
}
return 0;
}
Can you guess what it does? Let's find out!
Assume you have compiled your program called it test
and dropped it in /tmp
. You can use it as an external encoding in URH like this:
Simple, isn't it? As you see from the sample output, the decoding triples a zero and doubles a one.
To apply your crafted decoding to your data, just select the messages you want to set it for (Ctrl+A for all) and use the selection in the analysis tab: