bennomeier / leCroyParser

A Python Module to parse LeCroy Binary Trace Files
MIT License
12 stars 8 forks source link

read raw input #4

Closed JeroenvO closed 3 years ago

JeroenvO commented 3 years ago

Next to reading files, it would be nice to send raw binary data directly to the script. This can easily be done by splitting the function for parsing from the file reading. My use case is a waveform retrieved using VXI11 with https://github.com/python-ivi/python-vxi11 What i did now is:

a=scope.ask_raw(str('C1:WF?').encode('utf-8'))
with open('test.bin', 'wb') as f:
    f.write(a)
    f.flush()
d=lecroyparser.ScopeData('test.bin')

But i'd like to skip the file writing/reading.

bennomeier commented 3 years ago

Apologies for not having replied earlier. I believe the best way to achieve this would be to create a new class that inherits from ScopeData, e.g.,

ScopeDataFromBinaryString(ScopeData) and overwrite the __init__. If you create an according pull request I could include it in the next update.

JeroenvO commented 3 years ago

As you already load the whole file in fileContent, it is easier to read everything from this string instead of using file.seek. Some profiling shows me that it might be faster as well. I'll send a pull request.

JeroenvO commented 3 years ago

Looking forward to you opinion on this!