LMD文件格式解析
LMD格式是二进制保存方式,所以解析文件必须要分析文件内容的结构体,先看文件中定义的这些宏,然后我们再用二进制软件打开文件,数里面的码的位置是不是和描述的一致。
//-------------- 基本类型定义 ---------------
#define LMD_BLOCK_END 0
#define LMD_BYTE 1 // + unsigned 8-bit value
#define LMD_SHORT 2 // + signed 16bit integer
#define LMD_INT 3 // + signed 32 bit integer
#define LMD_LONG 4 // + signed 64bit Integer
#define LMD_FLOAT 5 // + 32bit real
#define LMD_DOUBLE 6 // + 64bit real
#define LMD_SSTRING 7 // + 0-terminated single-byte string
#define LMD_DSTRING 8 // + 0-terminated double-byte string
(unicode)
#define LMD_BINARY1 9 // + 1byte(=n) + (n/8)bytes; (n==no.of
bits,round up)
#define LMD_BINARY4 10 // + 4bytes(=n) + (n/8)bytes;
(n==no.of bits,round up)
//-------------- 扩展类型定义 ---------------
#define LMD_TYPE_DEF 11 // + byte(=new-type) + int (=parameter_
size)
//-------------- 扩展类型 -------------------------
//- All commands from 12 to 127 are reserved for extended types
//- All extended types have a fixed length (command + param
eter_size)
//-------------- 预定义扩展类型 ---------------
#define LMD_MOVE 12 // + float(=x) + float(=y)
#define LMD_DRAW 13 // + float(=x) + float(=y)
#define LMD_CIRCLE 14 // + float(=x) + float(=y) + float
(=r; r>0 CCW)
future
#define LMD_DRILL 15 // + float(=x) + float(=y)
#define LMD_TOOL_SELECT 16 // + int(=iTool)
#define LMD_ARC 17 // + float(cx)+float(cy)+float(ex)
+float(ey)+float(r)
// draw arc 0..+-355 degree.
// If start and end points are the same,
// draw a 360 degree circle
// ********* 扩展型扫描头 *********
// scanner head has its window (box), defined by points
// (-xmax,-ymax) and (xmax,ymax).
// Origin of the head is at (0,0)
// Position of the head is the point at which the origin (0,0)
is placed
#define LMD_HEAD_BOX 18 // + float(=xmax) + float(=ymax)
#define LMD_HEAD_POS 19 // + float(=x) + float(=y)
#define LMD_HEAD_NONE 20 // head position undefined, do not
use head
// -------------- 预定义块类型 -------------------
#define LMD_TOOL 128
// + LMD_INT iTool for use in LMD_TOOL_SELECT
// + LMD_BYTE for mode: 0:draw, 1=flash 2=flash+draw
// + LMD_FLOAT: width
// + LMD_SSTRING: tool-name
#define LMD_PHASE_HEADER 129
// + LMD_SSTRING: phase-name
// + LMD_SSTRING: layer-name
#define LMD_PHASE 130
// + LMD_PHASE_HEADER()
// + LMD_TOOL { LMD_TOOL }
// + { LMD_TOOL_SELECT() { LMD_DRILL() | path }
// path ::= LMD_MOVE() { [LMD_CIRCLE()] LMD_DRAW() };
//Please note that this structure may change in future ver
sions.
2,查看了这些定义之后,我们大致可以分析出来,这个结构体的雏形。
LMD_begin
Phase_Begin
Layer_Begin
TOOL_Select
HEAD_Box
HEAD_POS
LMD_MOVE
LMD_DRAW
LMD_ARC
。。。
Layer_End
Phase_End
....
LMD_End
3,我们需要用二进制查看软件,打开LMD格式的文件,这样方便我们验证
1,首先,我们找到了 82 ,81 ,对应的是LMD_PHASE,LMD_PHASE_HEADER,然后后面接的一串字符串,
#define LMD_PHASE_HEADER 129
// + LMD_SSTRING: phase-name
// + LMD_SSTRING: layer-name
明文中已经解析出来为MillingTop,TopLayer
2,后面我们找到80,对应LMD_TOOL,
#define LMD_TOOL 128
// + LMD_INT iTool for use in LMD_TOOL_SELECT
// + LMD_BYTE for mode: 0:draw, 1=flash 2=flash+draw
// + LMD_FLOAT: width
// + LMD_SSTRING: tool-name
Tool后面会跟一些参数。我们可以解析出来,但是最后LMD_SSTRING,这个是不固定的,所以必须解析到下一个特征,才能判断这个参数是多长。
(C1,72,04,3c,34,12,21,3c),分别转成float,对应XY坐标值
然后找到11,又数20字节,到了00(LMD_BLOCK_END)。
分析LMD文件需要请留邮箱地址。
总结
- 上一篇: 基于stm32电子时钟设计
- 下一篇: 华硕(ASUS)TUF GAMING B