Moshiboard

The educational technology and digital learning wiki
Jump to navigation Jump to search

Moshiboard

The Moshiboard laser cutter board is a proprietary controller with proprietary software. In the case of Moshiboard this software is called `MoshiDraw`. Like most proprietary laser cutting software intended for a specific board it has significant disadvantages and the only open source solutions are attempts at reverse engineering.

USB Protocol

The USB plug on the board is connected directly to the CH341A communications chip and configured in parallel port (EPP19) mode. This gives it the same Vendor id and product id as other things like the M2 Nano.

The usb device is located at vendor 0x1a86 with a PID of 0x5512


Swizzling

Like many different boards there is some light swizzling for some bytes in this case the command bytes are swizzled. Half of the command byte has random data (random distribution) and the other half is control code. This gives us 4 bits of command code, 4 random bytes. The swizzling can actually thus be interpreted in several ways, but we'll put the first four bits as command and the last 4 bits as random.

The algorithm from unswizzled to swizzled form is:

   def swizzle(b, b0, b1, b2, b3, b4, b5, b6, b7):
       return ((b >> 0) & 1) << b7 | ((b >> 1) & 1) << b6 | \
              ((b >> 2) & 1) << b5 | ((b >> 3) & 1) << b4 | \
              ((b >> 4) & 1) << b3 | ((b >> 5) & 1) << b2 | \
              ((b >> 6) & 1) << b1 | ((b >> 7) & 1) << b0
   def convert(q):
       if q & 1:
           return swizzle(q, 7, 6, 2, 4, 3, 5, 1, 0)
       else:
           return swizzle(q, 5, 1, 7, 2, 4, 3, 6, 0)

Note that each lowest bit triggers a different type of swizzle. So every other bit is swizzled in a different form. The last bit remains in the same position in both so these different swizzles perfectly intermingle.

Swizzle LUT

CMD 0x00 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x09 0x0A 0x0B 0x0C 0x0D 0x0E 0x0F
0x0? 0x00 0x01 0x40 0x03 0x10 0x21 0x50 0x23 0x04 0x09 0x44 0x0b 0x14 0x29 0x54 0x2b
0x1? 0x08 0x11 0x48 0x13 0x18 0x31 0x58 0x33 0x0c 0x19 0x4c 0x1b 0x1c 0x39 0x5c 0x3b
0x2? 0x80 0x05 0xc0 0x07 0x90 0x25 0xd0 0x27 0x84 0x0d 0xc4 0x0f 0x94 0x2d 0x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e 0xff

All commands will be referenced by the first 4 bits. The remaining 4 bits fit a random distribution.


Moshiboard Commands

Since command bytes have 4 bits there can only be 16 of them.

Command Length Code Parameters
2nd CMD For Jump 0 0x0? (2 bytes) (2 bytes) (2 bytes)
UNKNOWN 1 0x1? unknown
Terminal Commands 1 0x2? nothing. (occurs in 6 bytes increments)
Move_Y_ABS 1 0x3? (2 byte ABS Y)
UNKNOWN 1 0x4? unknown
Header Start 1 0x5? (2 bytes unknown)
Move_X_ABS 1 0x6? (2 byte ABS X)
Move_XY_ABS 1 0x7? (2 byte ABS X) (2 byte ABS Y)
UNKNOWN 1 0x8? unknown
UNKNOWN 1 0x9? unknown
UNKNOWN 1 0xA? unknown
Cut_Y_ABS 1 0xB? (2 byte ABS Y)
UNKNOWN 1 0xC? unknown
UNKNOWN 1 0xD? unknown
Cut_X_ABS 1 0xE? (2 byte ABS X)
Cut_XY_ABS 1 0xF? (2 byte ABS X) (2 byte ABS Y)

Bitwise this implies our flags for our 4 data bytes are: Laser, X-Value, Unknown, Y-Value

Reverse engineering resources.

Links

Official

Other Sources