Repetier-Firmware-4-Davinci/repetier communication prot...

106 wiersze
3.5 KiB
Plaintext

repetier communication protocol
Intermediate description - a complete protocol definition will follow if have
the time to document it!
Why a new protocol?
The current reprap communication is just sending the gcode string to the reprap.
If communication is to slow, the printer waits. If communication fails very
strange things can happen, depending on the detection of the error. The current
checksum method is not very secure. I've seen errors with correct checksums.
The last disadvantage is the required parsing. It is for an arduino quite
time consuming.
What is better in this protocol?
1. Data is send in binary form, no need for number conversion
2. Binary format is shorter. We can transfer more commands with the same
bandwidth.
3. Improved checksum validation.
Comparison of sizes:
Command 1:
G1 E10810.1 F1000
Original size: 21 Bytes
Updated for errorcheck:
N6654 G1 E10810.1 F1000 *65
Errorcheck size: 29 Bytes
repetier-protocol: 15 Bytes
Command 2:
G1 X69.4864 Y48.1169 E10813.1 F2400
Original size: 36 Bytes
Updated for errorcheck:
N7665 G1 X69.4864 Y48.1169 E10813.1 F2400 *78
Errorcheck size: 56 Bytes
Repetier-protocol:23 Bytes
As you can see, this protocol reduces the average data transfered to
less then 50%.
Gcode Letter to Bit and Datatype:
N : Bit 0 : 16-Bit Integer
M : Bit 1 : 8-Bit unsigned byte
G : Bit 2 : 8-Bit unsigned byte
X : Bit 3 : 32-Bit Float
Y : Bit 4 : 32-Bit Float
Z : Bit 5 : 32-Bit Float
E : Bit 6 : 32-Bit Float
: Bit 7 : always set to distinguish binary from ASCII line.
F : Bit 8 : 32-Bit Float
T : Bit 9 : 8 Bit Integer
S : Bit 10 : 32 Bit Integer
P : Bit 11 : 32 Bit Integer
V2 : Bit 12 : Version 2 command for additional commands/sizes
Ext : Bit 13 : There are 2 more bytes following with Bits, only for future versions
Int :Bit 14 : Marks it as internal command,
Text : Bit 15 : 16 Byte ASCII String terminated with 0
If version 2 is set, 2 more bytes with bitfields follow:
I : Bit 0 : 32-Bit float
J : Bit 1 : 32-Bit float
R : Bit 2 : 32-Bit float
D : Bit 3 : 32-Bit float (V3)
C : Bit 4 : 32-bit float (V3)
H : Bit 5 : 32-Bit float (V3)
A : Bit 6 : 32-Bit float (V3)
B : Bit 7 : 32-Bit float (V3)
K : Bit 8 : 32-Bit float (V3)
L : Bit 9 : 32-Bit float (V3)
O : Bit 10 : 32-Bit float (V3)
Bit 2-15 reserved
If Text bit is set in V2, the text length is send as byte 5 Text follows at
the end just before the checksum.
A GCode line is transformed into a binary parameterization.
16 bit integer with given parameter set
if bit 0 set: 16 bit linenumber
if bit 1 set: 8 bit M value
if bit 2 set: 8 bit G value
if bit 3 set: 32 bit floatpoint X value
if bit 4 set: 32 bit floatpoint Y value
if bit 5 set: 32 bit floatpoint Z value
if bit 6 set: 32 bit floatpoint E value
if bit 7 set: 32 bit floatpoint F value
if bit 8 set: 8 bit T value
if bit 9 set: 8 bit string length + string data
16 Bit checksum
Protocol version 2 extension:
The existence of M codes > 255 and additional parameter made it necessary to
introduce version 2. Version 2 code is indicated by setting V2 bit 12 in the bits field.
If the extra data is not needed, it is preferred to use V1 command to send/store data.
First main difference is G and M codes are 16 bit in V2.
Second difference are text codes send.
The checksum is computed by Fletcher-16 checksum algorithm (using modulus 255).
See http://en.wikipedia.org/wiki/Fletcher's_checksum
Advantage: We build checksum over checksum and both bytes are 0 if
correct.
The maximum size for a command without string is 2+2+3+5*4+2=29 Byte.