User defined template for decoding data
Previous  Next


You can define structures using which the captured data will be decoded. USBTrace allows you to define structure formats via an XML file. The captured data can then be decoded using any of the selected structure format definitions.

Right click on the Buffer View area and select 'Edit Template' in order to define your own structures. Instructions to edit the template file is given in the file itself.

graphic

In order to decode captured data according to a defined structure, right click on the Buffer View area and select 'Apply Template'. In the resulting dialog select the template and USBTrace will decode and show you the details.

Template

Template XML File Format

The template XML file (template.xml) contains the custom structure definitions made by you. The structure definitions must be enclosed between the <template> and </template> tags.

Within the <template> tag, each structure definition, i.e the fields within the structure, is written between the <structure name="structname"> and </structure> tags.

Field definition can take the following forms :

1. char/byte/short/long/long64 Value:

<field label="field_name" type="$type">offset=$offset</field>

where $type can be char, byte, short (2 bytes), long (4 bytes), long64 (8 bytes)

2. Generic Value:

<field label="field_name" type="value">offset=$Offset length=$len</field>

3. String:

<field label="field_name" type="string">offset=$offset length=$len</field>

$len denotes the length of the string in number of characters

4. Unicode String:

<field label="field_name" type="ustring">offset=$offset length=$len</field>

$len denotes the length of the unicode string in number of characters

( $offset is offset of the field from the beginning of structure. $len denotes length of the field in bytes )


Sample template definition


<template>
            <struct name="TEST-STRUCT-1">
                        <field label="bLength" type="value">offset=0 length=4</field>
                        <field label="bType" type="value">offset=4 length=1</field>
                        <field label="strName" type="string">offset=5 length=10</field>
                        <field label="strAttribute" type="string">offset=15 length=5</field>
                        <field label="bTest" type="value">offset=20 length=3</field>
            </struct>

            <struct name="TEST-STRUCT-2">
                        <field label="8bitValue" type="byte">offset=0</field>
                        <field label="16bitValue" type="short">offset=1</field>
                        <field label="32bitValue" type="long">offset=3</field>
                        <field label="charValue" type="char">offset=7</field>
            </struct>

            <struct name="TEST-STRUCT-3">
                        <field label="longValue" type="long">offset=0</field>
                        <field label="charValue" type="char">offset=4</field>
                        <field label="string" type="string">offset=5 length=10</field>
                        <field label="shortValue" type="short">offset=15</field>
                        <field label="wstring" type="ustring">offset=17 length=10</field>
            </struct>
</template>