Canon Pixma MX340 Main Board Command Versus Bulk Transfer
I'm writing a simple (hopefully) program to parse data flowing between main board and control panel of a Canon Pixma MX340 multi-function inkjet. It will listen to traffic in both directions by constantly polling two serial ports for data availability and process data as they come in on whichever port. My previous code listening for control panel button scan code was easily adapted, now I need to figure out how to handle main board commands.
Based on what I've seen so far, the majority (by byte count) of main board traffic updates LCD screen bitmap, with each screen refresh consisting of five bulk transfers of 196 bytes. Remaining traffic consist of two byte sequences, including the bytes leading up to each bulk transfer. So before anything else, I need to read through those two-byte commands and recognize the bulk transfer command so I know to skip ahead 196 bytes. Otherwise I'd end up trying to parse screen image bitmap as commands and that won't end well.
Right now I don't plan to do anything with the LCD screen image bitmap data, they'll just be discarded. My Python project is just a command line tool with no practical way to show an image anyway. The closest thing I can do is print out an array of asterisks/spaces 196 columns wide and 40 rows tall. Which may be an interesting exercise but not very practical. I don't plan to render the LCD screen image bitmap data until I evolve to something more advanced. Either a computer app with a graphical interface, or an ESP32 serving up HTML, something along those lines.
Once I separate main board commands from image data, I want my program to comb through those commands. Look for sequences I've already analyzed, and call attention to any sequences I haven't seen yet. Articulating all these patterns in terms of Python code could be straightforward or a hidden gotcha could turn it into an interesting challenge. I decided to try the easy thing first and see how far I get.
Source code for this quick-and-dirty data parsing project is publicly available on GitHub.
This teardown ran far longer than I originally thought it would. Click here to rewind back to where this adventure started.