Skip to content

Query commands

John Galbraith edited this page Jan 13, 2017 · 5 revisions

Command Line Tool: Part I

Polysync-transcode ships with plog example files in artifacts/. To work this tutorial, one may either copy those resources to the current working directory, change into artifacts/, or fully specify the path name. The tutorial assumes you have the files in the current directory somehow. Suppose that the PLog file ibeo.25.plog is fresh from your latest drive, and you need to find out what it contains. The transcoder gives you some exploratory options.

Identify the contents of a PLog

Count the instances of each datatype:

➜ cd polysync-transcode/artifacts
➜ polysync-transcode ibeo.25.plog
ibeo.header x25
ibeo.resolution_info x8
ibeo.scan_data x8
ibeo.scan_point x8
ibeo.scanner_info x8
ibeo.vehicle_state x9
log_record x25
msg_header x25
ps_byte_array_msg x25

This is the complete list of all the compound datatypes found in the file.

Print the data model

Great, but what is a "ibeo.vehicle_state", anyway? Introspect and print the data model using the --detail flag:

➜  polysync-transcode ibeo.25.plog --detail
ibeo.header {
    magic: uint32
    ...
    time: uint64
} x1
...
ibeo.vehicle_state {
    skip-1: skip-1(4)
    ...
    longitudinal_acceleration: float
} x9
...
ps_byte_array_msg {
    dest_guid: uint64
    data_type: uint32
    payload: uint32
} x25

Woah! That is way too much information.

Filter on the type name:

➜  polysync-transcode ibeo.25.plog --detail --type ibeo.header
ibeo.header {
    magic: uint32
    prev_size: uint32
    size: uint32
    skip-1: skip-1(1)
    device_id: uint8
    data_type: uint16
    time: uint64
} x25

Much better. Furthermore, --type is a composing argument, so two models are accepted as well:

➜  polysync-transcode ibeo.25.plog --detail --type ibeo.header --type ps_byte_array_msg
ibeo.header {
    magic: uint32
    prev_size: uint32
    size: uint32
    skip-1: skip-1(1)
    device_id: uint8
    data_type: uint16
    time: uint64
} x25
ps_byte_array_msg {
    dest_guid: uint64
    data_type: uint32
    payload: uint32
} x25

Filter on the record number

What types are contained by the 2nd record (0 based offset)?

➜  polysync-transcode ibeo.25.plog --slice 1
ibeo.header x1
ibeo.resolution_info x1
ibeo.scan_data x1
ibeo.scan_point x1
ibeo.scanner_info x1
log_record x1
msg_header x1
ps_byte_array_msg x1

What types are contained in the first 20 records?

➜  polysync-transcode ibeo.25.plog --slice :20
ibeo.header x20
ibeo.resolution_info x7
ibeo.scan_data x7
ibeo.scan_point x7
ibeo.scanner_info x7
ibeo.vehicle_state x7
log_record x20
msg_header x20
ps_byte_array_msg x20

In general, the --slice argument accepts any slice using the syntax swiped from Python Numpy. So you can select a portion of the PLog for processing that is the first 20 records using --slice :20, all but the first 20 records using --slice 20:, a set from the middle using --slice 10:20, subsample every 3rd record using --slice :3:. The transcoder can only iterate forward in the file, so negative strides are not allowed. Additionally, the transcoder does not know the length of file until it gets there, so negative indices are also not allowed - i.e., --slice -20: would be nice syntax to select the last 20 records, but is not supported because there is no efficient way to implement this feature.

Print the contents of a PLog

Printing the data contained in a PLog quickly becomes unwieldy; the filters are useful to zero in on what you want to see.

Print, or "dump", the first record in the file

➜  polysync-transcode ibeo.25.plog --slice 0 dump
log_record {
    index: 0
    size: 150
    prev_size: 0
    timestamp: 1464470621734607
    msg_header {
        type: 16
        timestamp: 1464470621734607
        src_guid: 0
    } 
    ps_byte_array_msg {
        dest_guid: 0
        data_type: 160
        payload: 114
    } 
    ibeo.header {
        magic: 0xaffec0c2
        ...
        time: 0xdaf49729f8bb2bbb
    } 
    ibeo.vehicle_state {
        skip-1: [ ff ff ff ff ] (4 elements)
        timestamp: 0xdaf4972a2b2e3822
        distance_x: 784592
        distance_y: -2097145
        ...
        longitudinal_acceleration: nan
    } 
} 

Clone this wiki locally