Git Product home page Git Product logo

hantek-wave-viewer's Introduction

Hantek Wave Viewer

This project aims to reverse engineer the Hantek lwf file format. I couldn't find any documentation for the format or previous projects so created this one by reverse engineering samples. I hope it works for you.

Note: All tests conducted on a Hantek DSO2C10

Kaitai Struct

In the kaitai directory there is a Kaitai Struct file which describes the structure of the file. As mentioned above this is based on me reverse engineering and may not be 100% accurate; there are also bytes I haven't yet identified.

This file can be used to build bindings for other languages. To generate the currently supported Python and C++ files you can run ./generate.sh from the project root directory.

I captured a number of wavefiles with known parameters, all files used are in wavefiles. You can read more about each sample in wavefiles/README.md

Python

The sample Python allows you to view the lwf file using matplotlib or to simply describe the file and it's content

Installation

git clone https://github.com/mattdavis90/hantek-wave-viewer.git
cd hantek-wave-viewer/python
pip install .

Usage

To display information about an lwf file

> hantek_wave_viewer info <lwf_file>
Hantek Wave Viewer: v0.1.0
Common:
        Version: 2001
        Acquisition Mode: Normal [0]
        Timebase: 500us [16]
        Sampling Depth: 4000
        Samples per Second: 500000.0
        Trigger Type: UART [9]
        Trigger Channel: 0
        Trigger Level: 0
        Horizontal Offset: 0
Channel 1
        Sample Count: 4000
        Offset: 24
        Vots per Division: 2V [11]
        Probe Mode: 1x [0]
Channel 2
        Disabled
Channel 3
        Disabled
Channel 4
        Disabled
Data:
        Channel 1: 4000
        Channel 2: 0
        Channel 3: 0
        Channel 4: 0

To view the file using matplotlib

hantek_wave_viewer view <lwf_file>

Screenshots

This is a screenshot of the Python based viewer

Screenshot of Python viewer

and the same waves on the Oscilloscope for comparison

Screenshot from Oscilloscope

C++

The C++ example has the same info command as the Python application and will output in the same format. This examples also has a converter that will output a vcd file which can be used in GTKWave or Sigrok.

Building

git clone https://github.com/mattdavis90/hantek-wave-viewer.git
cd hantek-wave-viewer/cpp
mkdir build
cd build
cmake ..
make

Usage

To output information about the lwf file

./hantek info <lwf_file>

To convert the file into a vcd

./hantek vcd <lwf_file> <vcd_output>

Other Programming Languages

This project is licensed as MIT so feel free to use and modify as you wish. The Kaitai file is included and, as per their docs, could be used to generate a parser in other languages.

hantek-wave-viewer's People

Contributors

mattdavis90 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

marrony brizzer

hantek-wave-viewer's Issues

Size mismatch between data and time

Hi,

I tried the viewer with filed from a DSO2D15, but it fails:

Traceback (most recent call last):
  [...]
  File "hantek-wave-viewer/hantek_wave_viewer/__main__.py", line 5, in <module>
    main()
 [...]
  File "/usr/lib/python3.9/site-packages/matplotlib/axes/_base.py", line 498, in _plot_args
    raise ValueError(f"x and y must have same first dimension, but "
ValueError: x and y must have same first dimension, but have shapes (4000000,) and (4064000,)

The values are:

sampling depth:  4000000
seconds per sample: 4e-06
time size:  4000000
data1 size 4064000
data2 size 4064000

I tried with different dumps and it is always the same. I submitted one file here: https://drive.google.com/file/d/13J9sNVoYwQnq_i0Xxa1Q8ZOQbdxAwoYw/view

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.