Merge pull request #2 from zombiepantslol/duet

Fixed G31 for Z endstop switch
Fixed file handling for pause/resume

Fixed bug in file handling that affected SD card pause/resume
operations. Merged changes from zombiepantslol to allow a height to be
set for a Z endstop switch. Reverted to blocking USB I/O but only for
debug and M503 output. Added return codes for file close and seek
operations. Increased the size of the tail of the file that we scan for
G1 Z commands from 32K to nearly 200K.
Close file if necessary after network error

If a network error occurs when sending a file, we now close that file,
otherwise we would use up open file entries. Also added number of
available open file entries to M111 S2 command.
Fix jerky SD card printing when no network cable

Fixed problem whereby gcode files printed from SD card that used lots of
small fast moves in sequence would print jerkily if a network cable had
not been connected since reset.
Fixed problem whereby object height and filament needed were not
retrieved from the SD card file to be printed if the filename contained
spaces.
Added support for deprecated M190 command, because slic3r appears to
generate it sometimes
Added support for M564 command to allow movement without limits, copied
from RepRapPro dev branch
Made MAC address depend on IP address

Made the last 4 bytes of the MAC address the same as the IP address so
that multiple Duets can be connected on the same network
Various bug fixes and enhancements (version 0.59a)

Fixed bug whereby incoming gcodes were URI-decoded twice, which could
cause problems if a comment contain a % character
Fixed bug whereby M109 and M190 waited for all heaters to reach target
temperature instead of just the one involved
Fixed bug whereby files whose names contain an uppercase letter G could
not be uploaded or deleted
Increase buffer size for incoming gcodes
Removed parameter to set max PWM value in M106 command. Max PWM value is
now 255 as per recent RepRapPro change.
Changed the code that deals with dropping characters in unimportant
messages sent to USB such that we only drop characters at the end of a
line (adding ".\n" to whatever we send) or drop whole lines
Added binary 059a-dc42
File upload + other improvements

Added new request code rr_data for file uploading, and made other
changes to improve file upload speed.
Implemented S parameter to M208 command, to allow the negative limits of
axes to be set. Also reports current limits of no X/Y/Z parameter.
Reduced max reported free buffer size to 950 bytes to avoid problems
with file upload from Windows 8.1.
New file upload protocol

Introduced new file upload protocol that doesn't use gcodes and allows
upload errors to be reported back. Changed file system interface in
Platform to return success/fail status of Write and Close calls to
support this.
Faster and more reliable file uploading

Rewrote the web server command parsing as a state machine. Added support
for persistent connections, used for file uploading. Changed file upload
protocol to pass status information back. Added web message type for
deleting files.
added experimental FTP support and rewrote parts of the webserver code
merged changes from dc42/duet (version 0.59d)
several networking bug fixes
prepared Telnet support