Brother Electronic Knitting Machines: Upload patterns using Knittington, GIMP (Linux)
Channel: ssslff
Date: 2015-10-20

Upload patterns to a Brother KH950 KH940 KH930 using Knittington and an FTDI cable.

https://github.com/stg/knittington

Cable tutorial at daviworks.com/knitting - home of img2track

For the FTDI cable device rule I used the information from the command  udevadm info -a -n /dev/ttyUSB0 - yours may be numbered differently but should be prefixed ttyUSB

/etc/udev/rules.d/10-local.rules: 

KERNEL=="ttyUSB[0-9]*", SUBSYSTEMS=="usb", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", ATTRS{product}=="TTL232R-3V3", MODE="0666", SYMLINK+="FTDI"

It's a good idea to plug in the FTDI cable while the knitting machine is off, and you need to have the usb side plugged into your computer before you start the knittington gui or the device file won't show when you click emulate.

Knittington is multiplatform (Windows/Linux/Mac), please see https://github.com/stg/knittington for more information.

www.imagemagick.org/Usage
Imagemagick resizes and reduces the colours, and for loops go through each pixel row by row to find the colour value (black or white). Here I've used imagemagick's convert command:
mycolour=`convert $my.png -format "%[fx: u.p{$ii,$i}]" info:`
$ii and $i being x and y coordinates.
depending of the value of $mycolour you can add to $hexstring FF or 00

printf piped into dd makes the rawformat hex file. Remember to include the \x option for hexidecimal!

printf '\x'$hexstring | dd of=myfile.raw bs=1 seek=0 count=$totalnumberofbytes conv=notrunc;

$totalnumberofbytes= height x width + 4

Before running this command make sure you remove any previous versions of myfile.raw to avoid creating an invalid file.

Thanks to daviworks for the FTDI cable tutorial.
Knittington has already been updated since I planned this video, thanks to all involved for this great program!
Yet again I am reminded why I like ImageMagick so much!