简体   繁体   English

从未知的编码文件中提取数据

[英]Extracting data from an unknown encoding file

We use testing equipment (1995 year manufacturing) powered by MS DOS. 我们使用由MS DOS驱动的测试设备(1995年制造)。 Analog-digital converter records information in the file. 模数转换器将信息记录在文件中。 In [picture 1 ] is shown the structure of that file. 在[图片1 ]中示出了该文件的结构。 In [picture 2 ] is shown the oscillogram that constructed according to the data from the file (program for opening the file on MS DOS). 在[图2 ]中显示了根据来自文件的数据(用于在MS DOS上打开文件的程序)构造的波形图。 Below I placed link to this file (google drive). 我在下面放置了指向该文件(Google驱动器)的链接。

This file contains the data that need for me - the massive of point of oscillogram. 该文件包含了我需要的数据-大量的示波图。 I want have opportunities to keep, analyze and print this chart on Windows or Linux (not MS DOS). 我希望有机会在Windows或Linux(不是MS DOS)上保存,分析和打印此图表。 So I need to extract data from the file. 所以我需要从文件中提取数据。

But I can't make it. 但是我做不到。 And no program (known to me) can't open this file. 而且(我所知)没有程序无法打开此文件。 I analyzed a few first byte and they point to program 'TRAS v4.99'. 我分析了一些第一个字节,它们指向程序“ TRAS v4.99”。 This program is on MS DOS. 该程序在MS DOS上。

But I really hope, that it is really to get data without this program. 但我真的希望,如果没有此程序,就可以获取数据。

PS If anyone will say it is impossible - it is will well too because I haven't found point of view yet:) PS:如果有人会说这是不可能的,那也很好,因为我还没有找到观点:)

Thank you for your time! 感谢您的时间! Best regards! 最好的祝福!

LINK TO FILE ON GOOGLE DISK - 00014380.K00 链接到GOOGLE DISK上的文件-00014380.K00

STRUCTURE OF FILE 文件的结构 文件结构

OPENING FILE VIA PROGRAM IN MS DOS 通过MS DOS中的程序打开文件 波形图是根据文件中的数据构建的

Here is an idea on how you can tackle this problem. 这是关于如何解决此问题的想法。 Since the format is relatively well specified in the handbook you can use the Java programming language for example with something like java.io.RandomAccessFile to read arrays of bytes. 由于该格式在手册中有相对明确的规定,因此您可以将Java编程语言与例如java.io.RandomAccessFile以读取字节数组。 These arrays of bytes can then be converted to Java primitive types OR to string according to the data type. 然后可以将这些字节数组转换为Java基本类型,或者根据数据类型转换为字符串。 After this conversion you can the print out the data in a human readable format. 转换之后,您可以以人类可读的格式打印数据。

Below you can find some sample code to give you an idea of what you could do with this approach (I have not tested the code, it is not complete, it is just to give you an idea of what you can do): 在下面,您可以找到一些示例代码,以使您了解使用此方法可以做什么(我尚未测试代码,它并不完整,只是让您了解可以做什么):

public static void readBinaryfile() throws IOException {
    java.io.RandomAccessFile randomAccessFile = new RandomAccessFile("test.bin", "r");
    byte[] addKenStrBytes = new byte[12];
    randomAccessFile.read(addKenStrBytes);
    String addKenStr = new String(addKenStrBytes, "UTF-8");
    // TODO: Do something with addKenStr.
    System.out.println(addKenStr);

    byte[] kopfSizeBytes = new byte[2];
    randomAccessFile.read(kopfSizeBytes);
    // TODO: Do something with kopfSizeBytes
    System.out.println(convertToInt(kopfSizeBytes));

    byte[] addRufNrCounterBytes = new byte[6];
    randomAccessFile.read(addRufNrCounterBytes);
    long addRufNrCounter = convertToLong(addRufNrCounterBytes);
    // TODO: Do something with addRufNrCounter
    System.out.println(addRufNrCounter);

    byte[] endAdrBytes = new byte[4];
    randomAccessFile.read(endAdrBytes);
    // TODO: Do something with endAdrBytes
    System.out.println(convertToLong(endAdrBytes));

    // Continue here and after you reached the end of the record repeat until you reached the end off the file
}

private static int convertToInt(byte[] bytes) {
    if(bytes.length > 4) {
        throw new IllegalArgumentException();
    }
    int buffer = 0;
    for(byte b : bytes) {
        buffer |= b;
        buffer = buffer << 8;
    }
    return buffer;
}

private static long convertToLong(byte[] bytes) {
    if(bytes.length > 8) {
        throw new IllegalArgumentException();
    }
    long buffer = 0L;
    for(byte b : bytes) {
        buffer |= b;
        buffer = buffer << 8;
    }
    return buffer;
}

Note that fields with more than 8 bytes need to be most probably converted to strings. 请注意,超过8个字节的字段很可能需要转换为字符串。 This is not complete code, just an example to give you an idea on how you can tackle this problem. 这不是完整的代码,仅是一个示例,使您可以了解如何解决此问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM