Added diagnostics support.
adjusted parameters from real scanner
add select() calls before reading in TCP mode.

Now diagnostics won't go stale when the device is unplugged but report
missing data errors correctly. The driver reconnects when the cable is
plugged again.
Merge pull request #5 from dornhege/diagnostics

Looks good, thanks!