The API documentation

This part of the documentation covers all the interfaces of trsfile.

Overview

trsfile.open(path)[source]
trsfile.create(path, padding_mode=<TracePadding.PAD: 1>, force_overwrite=False)[source]
trsfile.trs_open(path)[source]
trsfile.trs_create(path, padding_mode=<TracePadding.PAD: 1>, force_overwrite=False)[source]

The defactor trace set (.trs files) library for reading Riscure Inspector trace files.

class trsfile.Trace(sample_coding, samples, data=b'', title='trace', headers={})[source]

Bases: object

Single trace

class trsfile.SampleCoding[source]

Bases: enum.Enum

Defines the encoding of all the samples in the trace. Bit 4 specifies if it is a float (1) or an integer (0), bits 0 to 3 specifies the length of the value. Finally, bits 5-7 are currently reserved and set to 000.

This class is just a simple lookup table.

class trsfile.Header[source]

Bases: enum.Enum

An enumeration.

class trsfile.TracePadding[source]

Bases: enum.Enum

Defines the padding mode of the samples in each trace. This can be helpful when not all traces will be the same length. This can be set in trsfile.open(), trsfile.trs_open(), trsfile.trsfile_mutable.TrsFileMutable()

Mode Description
NONE No padding will be used and an exception will be thrown when traces are not of the same length.
PAD All traces will be padded with zeroes to the maximum trace length.
TRUNCATE All traces will be truncated to the minimum trace length.

Helper classes and enumerates

class trsfile.common.Header[source]

Bases: enum.Enum

An enumeration.

ACQUISITION_COUPLING_OF_SCOPE = 86
ACQUISITION_DEVICE_ID = 89
ACQUISITION_FREQUENCY_FILTER = 91
ACQUISITION_INPUT_IMPEDANCE = 88
ACQUISITION_OFFSET_OF_SCOPE = 87
ACQUISITION_RANGE_FILTER = 92
ACQUISITION_RANGE_OF_SCOPE = 85
ACQUISITION_TYPE_FILTER = 90
DESCRIPTION = 71
EXTERNAL_CLOCK_BASE = 103
EXTERNAL_CLOCK_FREQUENCY = 102
EXTERNAL_CLOCK_MULTIPLIER = 98
EXTERNAL_CLOCK_PHASE_SHIFT = 99
EXTERNAL_CLOCK_RESAMPLER_ENABLED = 101
EXTERNAL_CLOCK_RESAMPLER_MASK = 100
EXTERNAL_CLOCK_THRESHOLD = 97
EXTERNAL_CLOCK_USED = 96
GO_LAST_TRACE = 106
INPUT_LENGTH = 110
INPUT_OFFSET = 107
KEY_LENGTH = 112
KEY_OFFSET = 109
LABEL_X = 73
LABEL_Y = 74
LENGTH_DATA = 68
LOGARITHMIC_SCALE = 78
NUMBER_SAMPLES = 66
NUMBER_TRACES = 65
NUMBER_VIEW = 104
OFFSET_X = 72
OUTPUT_LENGTH = 111
OUTPUT_OFFSET = 108
SAMPLE_CODING = 67
SCALE_X = 75
SCALE_Y = 76
TITLE_SPACE = 69
TRACE_BLOCK = 95
TRACE_OFFSET = 77
TRACE_OVERLAP = 105
TRACE_TITLE = 70
class trsfile.common.SampleCoding[source]

Bases: enum.Enum

Defines the encoding of all the samples in the trace. Bit 4 specifies if it is a float (1) or an integer (0), bits 0 to 3 specifies the length of the value. Finally, bits 5-7 are currently reserved and set to 000.

This class is just a simple lookup table.

BYTE = 1
FLOAT = 20
INT = 4
SHORT = 2
class trsfile.common.TracePadding[source]

Bases: enum.Enum

Defines the padding mode of the samples in each trace. This can be helpful when not all traces will be the same length. This can be set in trsfile.open(), trsfile.trs_open(), trsfile.trsfile_mutable.TrsFileMutable()

Mode Description
NONE No padding will be used and an exception will be thrown when traces are not of the same length.
PAD All traces will be padded with zeroes to the maximum trace length.
TRUNCATE All traces will be truncated to the minimum trace length.
NONE = 0
PAD = 1
TRUNCATE = 2

Trace class

class trsfile.trace.Trace(sample_coding, samples, data=b'', title='trace', headers={})[source]

Bases: object

Single trace

get_input()[source]
get_key()[source]
get_output()[source]

TrsFile class

class trsfile.trsfile.TrsFile(path)[source]

Bases: object

append(trace)[source]
close()[source]

Closes the open file handle if it is opened

extend(traces)[source]
file_handle = None
handle = None
headers = {}
insert(index, trace)[source]
reverse()[source]
save()[source]
temp_folder = None

TrsFileMutable class

class trsfile.trsfile_mutable.TrsFileMutable(path, padding_mode=<TracePadding.PAD: 1>, force_overwrite=False)[source]

Bases: trsfile.trsfile.TrsFile

append(trace)[source]
close()[source]

Closes the open file handle if it is opened

extend(traces)[source]
insert(index, trace)[source]
is_saved = False
save(padding_mode=None)[source]
temp_folder = None