What's the best way to Intercept serial data


#1

Hi All.

I'm planning on adding support for the Robox Dual printer and one of the things that I need to do is add support for their proprietary serial format that it uses to communicate with the printer. Unfortunately, the format isn't directly compatible with the standard Gcode string format that we all love and know.

So I was hoping to write a plugin that will allow me to intercept the serial line so that I can encode and decode the data between the printer and OctoPrint.

Does this make sense? is this possible with just OctoPrint's plugins hooks or would I need to dig in to the source code?

That said, these are the Hooks that I think I need to use.

  • octoprint.comm.protocol.gcode.received
  • octoprint.comm.protocol.gcode.sending

#2

It is possible and it is how the GPX plugin by @markwal works. Instead of hooking into those two hooks however, which are for GCODE based communication, you rather want to hook into one level deeper and wrap the whole serial port object via octoprint.comm.transport.serial.factory (which is also how the GPX plugin does it). That gives you more control and ability to really translate everything that goes over the line.


#3

Thank you. That's perfect. :smiley:


#4

Did you make much progress on this? I am doing something similar with XYZ Davinci jr which also has a proprietary protocol, I have looked at the GPX but additional examples are always helpful