Debian Codegraph @

doc/specifications.md

raw symbols SCIP
1 # Specifications
2 The new binarized G-code file consists of a file header followed by an ordered succession of blocks, in the following sequence:
3 1. File Header
4 2. File Metadata Block (optional)
5 3. Printer Metadata Block
6 4. Thumbnails Blocks (optional)
7 5. Print Metadata Block
8 6. Slicer Metadata Block
9 7. G-code Blocks
10
11 All of the multi-byte integers are encoded in little-endian byte ordering.
12
13 ## File header
14
15 The file header contains the following data:
16
17 | | type | size | description |
18 | ------------- | -------- | ------- | ---------------------------------- |
19 | Magic Number | uint32_t | 4 bytes | GCDE |
20 | Version | uint32_t | 4 bytes | Version of the G-code binarization |
21 | Checksum type | uint16_t | 2 bytes | Algorithm used for checksum |
22
23 The size in bytes of the file header is 10.
24
25 Current value for `Version` is **1**
26
27 Possible values for `Checksum type` are:
28 ```
29 0 = None
30 1 = CRC32
31 ```
32
33 ## Blocks
34
35 All blocks have the following structure:
36 * [Block header](#block-header)
37 * [Block parameters](#block-parameters)
38 * [Block data](#block-data)
39 * [Block checksum (optional)](#block-checksum)
40
41 ### Block header
42
43 The block header is the same for all blocks.
44 It is defined as:
45
46 | | type | size | description |
47 | ----------------- | -------- | ------- | ---------------------------------- |
48 | Type | uint16_t | 2 bytes | Block type |
49 | Compression | uint16_t | 2 bytes | Compression algorithm |
50 | Uncompressed size | uint32_t | 4 bytes | Size of the data when uncompressed |
51 | Compressed size | uint32_t | 4 bytes | Size of the data when compressed |
52
53 The size in bytes of the block header is **8** when `Compression` = **0** and **12** in all other cases.
54
55 Possible values for `Type` are:
56 ```
57 0 = File Metadata Block
58 1 = GCode Block
59 2 = Slicer Metadata Block
60 3 = Printer Metadata Block
61 4 = Print Metadata Block
62 5 = Thumbnail Block
63 ```
64
65 Possible values for `Compression` are:
66 ```
67 0 = No compression
68 1 = Deflate algorithm
69 2 = Heatshrink algorithm with window size 11 and lookahead size 4
70 3 = Heatshrink algorithm with window size 12 and lookahead size 4
71 ```
72
73 ### Block parameters
74 Block parameters are used to let readers be able to interpret the block data.
75
76 Each block type may define its own parameters, so the size in bytes may vary.
77
78 ### Block data
79 Block data content is described by the block paramenters.
80
81 The size in bytes of the block data is defined in the block header.
82 For `Compression` = **0** it is `Uncompressed size`, otherwise it is `Compressed size`.
83
84 ### Block checksum
85 Block checksum is present when the `Checksum type` in the file header is different from **0**.
86
87 The size in bytes depends on the selected algorithm. For CRC32 it is **4**.
88
89 ### Block types
90
91 * [File metadata](#file-metadata)
92 * [Printer metadata](#printer-metadata)
93 * [Thumbnail](#thumbnail)
94 * [Print metadata](#print-metadata)
95 * [Slicer metadata](#slicer-metadata)
96 * [GCode](#gcode)
97
98 ### File metadata
99 Table of key-value pairs of generic metadata, such as producer (software), etc.
100
101 #### Parameters
102 | | type | size | description |
103 | -------- | -------- | ------- | ------------- |
104 | Encoding | uint16_t | 2 bytes | Encoding type |
105
106 Possible values for `Encoding` are:
107 ```
108 0 = INI encoding
109 ```
110
111 ### Printer metadata
112 Table of key-value pairs of metadata consumed by printer, such as printer model, nozzle diameter etc.
113
114 #### Parameters
115 | | type | size | description |
116 | -------- | -------- | ------- | ------------- |
117 | Encoding | uint16_t | 2 bytes | Encoding type |
118
119 Possible values for `Encoding` are:
120 ```
121 0 = INI encoding
122 ```
123
124 ### Thumbnail
125 Image data for thumbnail.
126 Each thumbnail is defined in its own block.
127
128 #### Parameters
129 | | type | size | description |
130 | ------ | -------- | ------- | ------------ |
131 | Format | uint16_t | 2 bytes | Image format |
132 | Width | uint16_t | 2 bytes | Image width |
133 | Height | uint16_t | 2 bytes | Image height |
134
135 Possible values for `Format` are:
136 ```
137 0 = PNG format
138 1 = JPG format
139 2 = QOI format
140 ```
141
142 ### Print metadata
143 Table of key-value pairs of print metadata, such as print time or material consumed, etc.
144
145 #### Parameters
146 | | type | size | description |
147 | -------- | -------- | ------- | ------------- |
148 | Encoding | uint16_t | 2 bytes | Encoding type |
149
150
151 Possible values for `Encoding` are:
152 ```
153 0 = INI encoding
154 ```
155
156 ### Slicer metadata
157 Table of key-value pairs of metadata produced and consumed by the software generating the G-code file.
158
159 #### Parameters
160 | | type | size | description |
161 | -------- | -------- | ------- | ------------- |
162 | Encoding | uint16_t | 2 bytes | Encoding type |
163
164 Possible values for `Encoding` are:
165 ```
166 0 = INI encoding
167 ```
168
169 ### GCode
170 G-code data.
171
172 #### Parameters
173 | | type | size | description |
174 | -------- | -------- | ------- | ------------- |
175 | Encoding | uint16_t | 2 bytes | Encoding type |
176
177 Possible values for `Encoding` are:
178 ```
179 0 = No encoding
180 1 = MeatPack algorithm
181 2 = MeatPack algorithm modified to keep comment lines
182 ```
183
184