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