-2

I received data from the oscilloscope in 64-bit doubles (.dbl) or in "measured data" (.mt4) format. How can I parse it (preferably Java or Kotlin) or where can I find documentation for this format?

I tried using DataInputStream.readDouble but the results were weird

c5 12 52 9b ec 3f 12 c0 17 29 e9 87 4e 71 12 c0 6a 3f 80 74 b0 a2 12 c0 b8 39 8e 9e b1 37 12 c0 17 29 e9 87 4e 71 12 c0 c5 12 52 9b ec 3f 12 c0 4e 8d f8 7a 3a 92 12 c0 aa 60 ca a1

sergii.gudym
  • 163
  • 1
  • 13
  • 1
    That doesn't sound like a standard file format, we would probably need to know which oscilloscope this is and get related documentation to that. A sample of the file could also prove helpful – JensV Jul 21 '23 at 14:14
  • I don't have an app. A friend sent me a file. There are several formats, now I looked, there is an option *.mt4 – sergii.gudym Jul 21 '23 at 14:35
  • Maybe your friend can give you enough information about the oscilloscope so that you can find out how to parse the file. – Jorn Jul 21 '23 at 14:37
  • Why not post a link to the file? – g00se Jul 21 '23 at 14:45
  • Can you edit the question with first 20 bytes or so (`print(list(open('filename', 'rb').read(20)))` in python). I'd rather not be opening random files from dropbox. – Holloway Jul 21 '23 at 15:04
  • So how did the "weird" stuff manifest itself? If that's a file of 64 bit values, it could be big-endian *or* little-endian – g00se Jul 21 '23 at 15:11
  • 1
    First eight values as doubles, little-endian: `-4.56, -4.61, -4.66, -4.55, -4.61, -4.56, -4.64, -4.55` Big-endian ones are *crazy* ;) – g00se Jul 21 '23 at 15:27

1 Answers1

3

You can read it with this. The values are in line with your expectations:

import java.nio.ByteBuffer;
import static java.nio.ByteOrder.*;
import java.nio.file.Path;
import java.nio.file.Files;
import java.io.InputStream;

public class Doubler {
    public static void main(String[] args) throws Exception {
        int count = -1;
        byte[] buff = new byte[8];
        ByteBuffer bb = ByteBuffer.allocate(8).order(LITTLE_ENDIAN);
        try (InputStream in = Files.newInputStream(Path.of(args[0]))) {
            while ((count = in.read(buff)) > -1) {
                bb.put(buff);
                bb.rewind();
                System.out.printf("%.2f%n", bb.getDouble());
                bb.rewind();
            }
        }
    }
}

g00se
  • 3,207
  • 2
  • 5
  • 9