Hack: Elecrow Laser Engraver Tool Protocol

Disclaimer: Contains Amazon Affiliate and direct links to products.

This is Part II of our Elecrow Laser Engraver Tool hackery:

What We Did

Roughly:

  • Sniff USB (under both Windows and OS X)
  • Identify packets to/from the ELET (Elecrow Laser Engraver Tool)
  • Isolate individual commands by pushing app buttons and seeing what was sent and received
  • Formalize those commands for repeatability

This is the same process you’d use to reverse engineer any protocol, e.g., if you want to find out how the littleBits app talks to their CodeKit board, or what commands are being sent to your cheap ESP8266 120V relay controller, or pretty much anything.

How We Did It

The first step in figuring out how the Elecrow app was talking to the engraver was to sniff the USB connection. Under Windows we used USB Analyzer. Under OS X we used Wireshark, but needed to bring up the interface so Wireshark could track it:

$ sudo ifconfig XHC20 up

(And conversely bring it down when we were done.)

Wireshark is pretty great, by the way, but provides very complete information, which isn’t always what we need. In this case we needed to filter by the source, so we clicked the “Fan” icon and looked for likely suspects in the Wireshark display.

We knew from Windows USB sniffing that the fan on/fan off commands were four bytes long, but under OS X we were seeing the entire block of 32 bytes plus the payload data from the Elecrow software, so our first guess was to look for something that was 36 bytes long:

Wireshark: Find the Device
Find the Source, Luke

Once we had that we could set a display filter to see just this data, and add a column to display it:

Getting this data into something we could (trivially) look at and dissect was a dive back into the world of Wireshark. First we saved just our filtered packets:

Wireshark: Export Displayed Packets
Export Displayed Packets

Then fell into the following workflow (roughly):

  • Capture and filter data as shown above
  • Export the selected packets via Export Specified Packets…
  • And only exporting the “Displayed” packets (as per our filter)
  • Run tshark to save off just the “Leftover Capture Data”…
  • …and strip out the newlines via tr so they didn’t muck up the analysis
  • Turn this into a binary file with a quick-and-dirty script
  • Analyze the result

Here’s the tshark command to save just the isolated data (and strip out the newlines to create a clean binary file for analysis):

tshark -r test2.pcap -T fields -e usb.capdata | tr -d '\n' > outfile

The Python script, lifted off the net somewhere, but it’s trivial to implement in any language:

import binascii
import sys
string = open(sys.argv[1],'r').read()
sys.stdout.write(binascii.unhexlify(string)) # needs to be stdout.write to avoid trailing newline

Under OS X we tried out Synalyze It! and it was okay, but we found the grammar creation to be a bit fraught. Honestly for this it wasn’t worth the effort since (a) the messages were short anyway, and (b) we pretty much knew we were going to replace the controller board, but it was interesting.

(It did, however, highlight the need for one of our old, old projects that’s been on the backburner for a number of years–our Data File Disassembler, that we’ll bring into the modern age Real Soon Now.)

To sanity-check our assumptions we cobbled together a small NodeJS app and we were able to turn the fan on and off (04 00 04 00, 04 00 05 00 respectively) under a separate app, but that was as far as we wanted to take it. Knowing (a) it was a custom protocol that (b) didn’t work with anything else was enough for us.

The initial protocol hacking notes are in a Github repo. If we (or anyone else) develops any tools around its native protocol we’ll try to keep the repo updated. If nothing else, we may include a tool that’ll wrap up the protocol capture so the binary files can be downloaded to an RPi which could then be used to send duplicate commands to a printer, allowing semi-automated printing without having to use the included application.

What’s Next

In Part III we’ll start grafting on a commercially-available SainSmart controller we hope will be a drop-in replacement (delta the GRBL configuration) for the controller board that comes with the ELET. Hint: worked out of the box, just needs configuration and endstops.)

Resources

Products

Mini-Review: Elecrow Laser Engraver Tool

Elecrow Laser Engraver Tool - 3/4 View

Disclaimer: Contains Amazon Affiliate and direct links

For $130, what could go wrong? Naturally we ordered two of this tiny, 1W laser engraver tool, because that’s just how we do things. One device arrived DOA (seemed to be the controller board), one worked (as well as expected, that is to say, there’s no comparison to a real machine).

What’s in the Box

The laser machine, some sample materials, a 5V 2A power supply, and a USB stick, because who wouldn’t trust a USB stick, amiright?

Fit and Finish

On the working device, while the laser head was attached, it wasn’t attached well. Two screws were complete missing (the top two), the bottom two were quite loose. Tightening them required moving around the head using the included software and a small screwdriver–this is not a machine built for trivial fixery.

The top is removable via plastic tabs, but it’s a pain. The top is more or less required for reliable operation since it keeps the Y axis rails in place–if you take off the top, before doing much printing, you’ll either need to put it back on, or replace it with something that’ll hold the rails.

It comes with a 5V 2A power supply with a too-long barrel jack that occasionally falls out. The USB port is far enough in that some cables won’t fit, meaning it also fell out. We didn’t mean to lose connection 🙁

Once both USB and power are plugged in the laser turns on (low) for help in positioning. We needed to re-focus ours; just turn the lens cap until it’s as close to a pinpoint as possible. Use white, non-shiny paper for this step.

There’s an acrylic piece you can put on the front, which is great for keeping your eyes safe(r), but there are no side panels. Even though it’s just a 1W laser, you can be hurt by even scattered light, so be careful… None of us are blind yet, but we did occasionally get zapped with scatter enough to notice it.

There’s an “exhaust fan” on the back which does actually pull out smoke from the cutting area (more or less) but it’s not going to save your life or anything: cut responsibly.

The Software

Well, it’s software, sure enough, but holy smokes, you sure can’t do much with it. And what you can do is largely guesswork, at least on the Windows version. We haven’t tried the OS X version yet, and our Linux machines are left in the lurch.

The Software
The Software

There’s a collection of sample images we used for our initial testing. You can scale the images using the “Scaling” slider (upper-left) and if you don’t, you’ll get tiny, burned chunks. Larger, clean images will work best. You can add text using whatever fonts you have installed, but with zero means to align anything anywhere, your composition options are limited.

Laser Etched Samples
Samples

Homing the machine? It just moves until it grinds in the corner then pops out a little bit. Laser intensity? “Depth adjustment of engraving”. About 5-10-ish is decent enough, and it takes about three minutes for their sample Lexus logo image to etch on cardboard, but again, finding the sweet spot for the material being etched is sketchy, especially since you can’t enter a number directly–sliders all the way, baby!

It often failed to print the entire image for no reason we could discern, like the Big Bang Theory image. Sometimes it would skip parts of an image, as in the Bentley logo’s “L” and part of the “N”. Again, finding the intensity sweet spot was very hit-or-miss.

Cutting paper seemed… essentially impossible with the software. Fine for us (although it’s a potentially handy feature) but doesn’t make any sense for even the simplest of laser devices. We couldn’t find any way to do much of anything except raster images, which could be used to cut, but it’s slow, and even a 1W laser should have no problems cutting out hairline vectors.

Our Advice

Either try the higher-powered one (a clone with 3W laser) or get a real laser. This might be a useful toy, but as shipped, it’s not worth the effort we’re putting into it.

Next Up

Total hackage, of course: since we had a working device for testing, and a non-functional device, we wanted to bring it into the fold of devices we could use across our operating systems and usecases.

Unfortunately, the computer doesn’t talk GCode to it, meaning that either (a) the protocol had to be reverse-engineered, or (b) replace their controller board with something more-standardized that would work with other software out-of-the box. True to form, we chose (c), all of the above.

In Part II we’ll look at their native comms protocol and see if it’s worth dealing with at all (hint: nah). Then in Parts III and IV we’ll take our dead unit, graft a controller onto it, and turn it into the device we wanted in the first place: take it to a workpiece, burn it with lasers, and run away.

Resources

Products