From: robertl Date: Tue, 16 Nov 2004 03:50:19 +0000 (+0000) Subject: Suppress zero byte writes for benefit of Bob Anderson's Keyspan USB/Serial adapter. X-Git-Tag: archive/raspbian/1.10.0+ds-2+rpi1~1^2~12^2~11^2~3862 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=18ac70847a792de2cffe4f7077fd669fa5af3aa8;p=gpsbabel.git Suppress zero byte writes for benefit of Bob Anderson's Keyspan USB/Serial adapter. --- diff --git a/gpsbabel/jeeps/gpsserial.c b/gpsbabel/jeeps/gpsserial.c index b2a51bb22..f7d5d631a 100644 --- a/gpsbabel/jeeps/gpsserial.c +++ b/gpsbabel/jeeps/gpsserial.c @@ -180,6 +180,17 @@ int32 GPS_Serial_Flush(int32 fd) int32 GPS_Serial_Write(int32 ignored, const void *obuf, int size) { DWORD len; + + /* + * Unbelievably, the Keyspan PDA serial driver 3.2, a "Windows + * Certified driver", will crash the OS on a write of zero bytes. + * We get such writes from upstream when there are zero payload + * bytes. SO we trap those here to stop Keyspan & Windows from + * nuking the system. + */ + if (size == 0) { + return 0; + } WriteFile (comport, obuf, size, &len, NULL); if (len != size) { fatal ("Write error. Wrote %d of %d bytes.", len, size);