Monday, February 27, 2012

Teensy PDF Dropper Part 2

Last year Stevens showed how to use a Teensy micro-controller to drop a PDF file with embedded executable. But hewas limited to a file of a few kilobytes, because of the Arduino programming language he used for the Teensy.



In this post, he is using WinAVR and now its only limited by the amount of flash memory on Teensy++.


First we use a new version of my PDF tools to create a PDF file with embedded file:



Filter i is exactly like filter h (ASCIIHexDecode), except that the lines of hex code are wrapped at 512 hex digits, making them digestible to our C compiler.


Another new feature of my make PDF tools is Python 3 support.


Here is a sample of our C code showing how to embed each line of the pure-ASCII PDF document as strings:



Macro PSTR makes that the string is stored in flash memory. The embedded executable is 57KB large, but still only takes half of the flash memory of my Teensy++.


After programming my Teensy++, I can fire up Notepad and let my Teensy++ type out the PDF document:



You can download my example for the WinAVR compiler here:


avr-teensy-pdf-dropper_V0_0_0_1.zip (https)

MD5: EA14100A1BEDA4614D1AE9DE0F71B747

SHA256: 2C9A5DF1831B564D82548C72F1050737BCF17E5A25DCDC41D7FA4EA446A8FDED