Index: trunk/Serial_Server/library/Library.h
===================================================================
--- trunk/Serial_Server/library/Library.h	(revision 213)
+++ trunk/Serial_Server/library/Library.h	(revision 215)
@@ -53,5 +53,4 @@
 	unsigned char divisor;
 	char *display;
-	char *altSelection;
 };
 struct baudRate *baudRateMatchString( char *str );
Index: trunk/Serial_Server/library/Process.cpp
===================================================================
--- trunk/Serial_Server/library/Process.cpp	(revision 213)
+++ trunk/Serial_Server/library/Process.cpp	(revision 215)
@@ -48,6 +48,9 @@
 #define SERIAL_COMMAND_HEADERMASK 0xe0
 
-#define SERIAL_INQUIRE_PORTANDBAUD_BAUD 3
-#define SERIAL_INQUIRE_PORTANDBAUD_PORT 0xfc
+#define SERIAL_INQUIRE_PORTANDBAUD_BAUDMASK 3
+#define SERIAL_INQUIRE_PORTANDBAUD_PORTMASK 0xfc
+#define SERIAL_INQUIRE_PORTANDBAUD_STARTINGPORT 0x240
+
+#define SERIAL_INQUIRE_PORTANDBAUD_PORTTRANSLATE( a ) ( ((a) & SERIAL_INQUIRE_PORTANDBAUD_PORT) << 1 | SERIAL_INQUIRE_PORTANDBAUD_STARTINGPORT )
 
 void logBuff( char *message, unsigned long buffoffset, unsigned long readto, int verboseLevel )
@@ -77,10 +80,7 @@
 	int workOffset, workCount;
 
-	int vtype = 0;
-
 	unsigned long mylba;
 	unsigned long readto;
 	unsigned long buffoffset;
-	int timeout;
 	unsigned long lasttick;
 	unsigned short crc;
@@ -95,9 +95,9 @@
 	buffoffset = 0;
 	readto = 0;
-	timeout = 0;
 	workCount = workOffset = workCommand = 0;
+
 	lasttick = GetTime();
 
-	while( timeout || (len = serial->readCharacters( &buff.b[buffoffset], (readto ? readto-buffoffset : 1) )) )
+	while( (len = serial->readCharacters( &buff.b[buffoffset], (readto ? readto-buffoffset : 1) )) )
 	{
 		buffoffset += len;
@@ -109,15 +109,35 @@
 			logBuff( "    Received: ", buffoffset, readto, verboseLevel );
 
-		timeout = 0;
-
-		if( buffoffset != 1 && (timeoutEnabled && GetTime() > lasttick + GetTime_Timeout_Local) )
+		if( timeoutEnabled && readto && GetTime() > lasttick + GetTime_Timeout_Local )
 		{
-			timeout = 1;
-			buff.b[0] = buff.b[buffoffset];
-			buffoffset = 0;
-			len = 1;
-			workCount = 0;
-			log( 1, "Timeout waiting on command" );
-			continue;
+			log( 1, "Timeout waiting on data from client, aborting previous command" );
+
+			workCount = workOffset = workCommand = 0;
+			readto = 0;
+
+			if( len <= 8 && (buff.b[buffoffset-len] & SERIAL_COMMAND_HEADERMASK) == SERIAL_COMMAND_HEADER )
+			{
+				// assume that we are at the front of a new command
+				//
+				memcpy( &buff.b[0], &buff.b[buffoffset-len], len );
+				buffoffset = len;
+				readto = 8;
+				// fall through to normal processing
+			}
+			else if( len == 1 )
+			{
+				// one new character, treat it like any other new character received, discarding the buffer
+				//
+				buff.b[0] = buff.b[buffoffset-1];
+				buffoffset = 1;
+				// fall through to normal processing
+			}
+			else
+			{
+				// discard even the newly received data and start listening anew
+				//
+				buffoffset = 0;
+				continue;
+			}
 		}
 
@@ -127,11 +147,7 @@
 		// No work currently to do, look at each character as they come in...
 		//
-		if( buffoffset == 1 && !readto )
+		if( !readto )
 		{
-			if( workCount )
-			{
-				readto = 1;
-			}
-			else if( (buff.b[0] & SERIAL_COMMAND_HEADERMASK) == SERIAL_COMMAND_HEADER )
+			if( (buff.b[0] & SERIAL_COMMAND_HEADERMASK) == SERIAL_COMMAND_HEADER )
 			{
 				//
@@ -193,4 +209,7 @@
 			workOffset++;
 			workCount--;
+
+			if( workCount )
+				readto = 1;           // looking for continuation ACK
 		}
 
@@ -204,4 +223,7 @@
 			if( workCount )
 			{
+				if( verboseLevel > 1 )
+					log( 2, "    Continuation: Offset=%u, Checksum=%04x", workOffset-1, buff.w[256] );
+
 				//
 				// Continuation...
@@ -221,22 +243,10 @@
 				if( (crc = checksum( &buff.w[0], 3 )) != buff.w[3] )
 				{
-					log( 0, "Bad Command Checksum: %02x %02x %02x %02x %02x %02x %02x %02x, Checksum=%02x",
+					log( 0, "Bad Command Checksum: %02x %02x %02x %02x %02x %02x %02x %02x, Checksum=%04x",
 						 buff.b[0], buff.b[1], buff.b[2], buff.b[3], buff.b[4], buff.b[5], buff.b[6], buff.b[7], crc);
 					continue;
 				}
 
-				if( (buff.inquire.driveAndHead & ATA_DriveAndHead_Drive) )
-				{
-					if( !image1 )
-					{
-						log( 1, "Slave drive selected when not supplied" );
-						img = NULL;
-						continue;
-					}
-					else
-						img = image1;
-				}
-				else
-					img = image0;
+				img = (buff.inquire.driveAndHead & ATA_DriveAndHead_Drive) ? image1 : image0;
 
 				workCommand = buff.chs.command & SERIAL_COMMAND_RWMASK;
@@ -248,5 +258,4 @@
 						| (((unsigned long) buff.lba.bits08) << 8) 
 						| ((unsigned long) buff.lba.bits00);
-					vtype = 1;
 				}
 				else
@@ -255,16 +264,41 @@
 					sect = buff.chs.sector;
 					head = (buff.chs.driveAndHead & ATA_COMMAND_HEADMASK);
-					mylba = (((cyl*img->head + head)*img->sect) + sect-1);
-					vtype = 2;
-				}
-
-				if( (workCommand & SERIAL_COMMAND_WRITE) && img->readOnly )
-				{
-					log( 1, "Write attempt to Read Only disk" );
-					continue;
+					mylba = img ? (((cyl*img->head + head)*img->sect) + sect-1) : 0;
 				}
 
 				workOffset = 0;
 				workCount = buff.chs.count;
+
+				if( verboseLevel > 0 )
+				{
+					char *comStr = (workCommand & SERIAL_COMMAND_WRITE ? "Write" : "Read");
+
+					if( workCommand == SERIAL_COMMAND_INQUIRE )
+						log( 1, "Inquire %d: Client Port=0x%x, Client Baud=%s", img == image0 ? 0 : 1,
+							 ((buff.inquire.portAndBaud & SERIAL_INQUIRE_PORTANDBAUD_PORTMASK) << 1) 
+							 + SERIAL_INQUIRE_PORTANDBAUD_STARTINGPORT,
+							 baudRateMatchDivisor( buff.inquire.portAndBaud & SERIAL_INQUIRE_PORTANDBAUD_BAUDMASK )->display );
+					else if( buff.chs.command & ATA_COMMAND_LBA )
+						log( 1, "%s %d: LBA=%u, Count=%u", comStr, img == image0 ? 0 : 1,
+							 mylba, workCount );
+					else
+						log( 1, "%s %d: Cylinder=%u, Sector=%u, Head=%u, Count=%u, LBA=%u", comStr, img == image0 ? 0 : 1,
+							 cyl, sect, head, workCount, mylba );
+				}
+
+				if( !img )
+				{
+					log( 1, "    No slave drive provided" );
+					workCount = 0;
+					continue;
+				}
+
+				if( (workCommand & SERIAL_COMMAND_WRITE) && img->readOnly )
+				{
+					log( 1, "    Write attempt to Read Only disk" );
+					workCount = 0;
+					continue;
+				}
+
 				if( verboseLevel > 0 && workCount > 100 )
 					perfTimer = GetTime();
@@ -286,14 +320,7 @@
 				{
 					if( serial->speedEmulation && 
-						(buff.inquire.portAndBaud & SERIAL_INQUIRE_PORTANDBAUD_BAUD) != serial->baudRate->divisor )
+						(buff.inquire.portAndBaud & SERIAL_INQUIRE_PORTANDBAUD_BAUDMASK) != serial->baudRate->divisor )
 					{
-						struct baudRate *br;
-
-						br = baudRateMatchDivisor( buff.inquire.portAndBaud & SERIAL_INQUIRE_PORTANDBAUD_BAUD );
-
-						if( br )
-							log( 1, "    Ignoring Inquire with Baud Rate=%d", br->rate );
-						else
-							log( 1, "    Ignoring Inquire with Unknown Baud Rate (portAndBaud=%d)", buff.inquire.portAndBaud );
+						log( 1, "    Ignoring Inquire with wrong baud rate" );
 						workCount = 0;
 						continue;
@@ -316,32 +343,17 @@
 					log( 0, "Serial Port Write Error" );
 
+				if( verboseLevel >= 3 )
+					logBuff( "    Sending: ", 514, 514, verboseLevel );
+
 				workCount--;
 				workOffset++;
+
+				if( workCount )
+					readto = 1;           // looking for continuation ACK
 			}
 		}
 
-		if( verboseLevel > 0 )
-		{
-			char *comStr = (workCommand & SERIAL_COMMAND_WRITE ? "Write" : 
-							(workCommand & SERIAL_COMMAND_READWRITE ? "Read" : "Inquire"));
-
-			if( vtype == 1 )
-				log( 1, "%s %d: LBA=%u, Count=%u", comStr, img == image0 ? 0 : 1,
-					 mylba, workCount );
-			else if( vtype == 2 )
-				log( 1, "%s %d: Cylinder=%u, Sector=%u, Head=%u, Count=%u, LBA=%u", comStr, img == image0 ? 0 : 1,
-					 cyl, sect, head, workCount+1, mylba );
-
-			vtype = 0;		  
-
-			if( workOffset > 1 )
-				log( 2, "    Continuation: Offset=%u, Checksum=%04x", workOffset-1, buff.w[256] );
-
-			if( !(workCommand & SERIAL_COMMAND_WRITE) && verboseLevel >= 3 )
-				logBuff( "    Sending: ", 514, 514, verboseLevel );
-
-			if( workCount == 0 && workOffset > 100 )
-				log( 1, "    Block Complete: %.2lf bytes per second", (512.0 * workOffset) / (GetTime() - perfTimer) * 1000.0 );
-		}
+		if( workCount == 0 && workOffset > 100 )
+			log( 1, "    Performance: %.2lf bytes per second", (512.0 * workOffset) / (GetTime() - perfTimer) * 1000.0 );
 	}
 }
Index: trunk/Serial_Server/library/Serial.cpp
===================================================================
--- trunk/Serial_Server/library/Serial.cpp	(revision 213)
+++ trunk/Serial_Server/library/Serial.cpp	(revision 215)
@@ -12,15 +12,15 @@
 struct baudRate supportedBaudRates[] = 
 { 
-	{   2400,  0x0,   "2400",   NULL }, 
-	{   4800, 0xff,   "4800",   NULL }, 
-	{   9600,  0x1,   "9600",   NULL }, 
-	{  19200, 0xff,  "19.2K",  "19K" }, 
-	{  38400,  0x2,  "38.4K",  "38K" }, 
-	{  76800,  0x2,  "76.8K",  "77K" },
-	{ 115200,  0x3, "115.2K", "115K" }, 
-	{ 153600,  0x3, "153.6K", "154K" },
-	{ 230400, 0xff, "230.4K", "230K" }, 
-	{ 460800,  0x1, "460.8K", "460K" }, 
-	{      0,    0,     NULL,   NULL } 
+	{   2400,  0x0,   "2400" },
+	{   4800, 0xff,   "4800" },
+	{   9600,  0x1,   "9600" },
+	{  19200, 0xff,  "19.2K" },
+	{  38400,  0x2,  "38.4K" },
+	{  76800, 0xff,  "76.8K" },
+	{ 115200,  0x3, "115.2K" },
+	{ 153600, 0xff, "153.6K" },
+	{ 230400, 0xff, "230.4K" },
+	{ 460800, 0xff, "460.8K" },
+	{      0,    0,     NULL }
 };
 
@@ -33,11 +33,7 @@
 	{
 		for( b = supportedBaudRates; b->rate; b++ )
-			if( b->rate == a )
+			if( b->rate == a || (b->rate / 1000) == a || ((b->rate + 500) / 1000) == a )
 				return( b );
 	}
-
-	for( b = supportedBaudRates; b->rate; b++ )
-		if( !stricmp( str, b->display ) || (b->altSelection && !stricmp( str, b->altSelection )) )
-			return( b );
 
 	return( NULL );
Index: trunk/Serial_Server/win32/Win32.cpp
===================================================================
--- trunk/Serial_Server/win32/Win32.cpp	(revision 213)
+++ trunk/Serial_Server/win32/Win32.cpp	(revision 215)
@@ -40,5 +40,5 @@
 		"                    With a 4x rate multiplier: 9600, 38400, 153600, 460800",
 		"                    Abbreviations also accepted (ie, '460K', '38.4K', etc)",
-		"                    (default is 9600, 115200 in named pipe mode)",
+		"                    (default is 38400, 115200 in named pipe mode)",
 		"",
 		"  -t                Disable timeout, useful for long delays when debugging",
@@ -47,4 +47,10 @@
 		"",
 		"  -v [level]        Reporting level 1-6, with increasing information",
+		"",
+		"On the client computer, a serial port can be configured for use as a hard disk",
+		"with xtidecfg.com.  Or one can hold down the ALT key at the end of the normal",
+		"IDE hard disk scan and the XTIDE Universal BIOS will scan COM1-7, at each of",
+		"the four speeds given above for BaudRate.  Note that hardware rate multipliers",
+		"must be taken into account on the server end, but are invisible on the client.",
 		NULL };
 
@@ -68,5 +74,5 @@
 	Serial *serial;
 	Image *img;
-	struct baudRate *baudRate;
+	struct baudRate *baudRate = NULL;
 
 	int timeoutEnabled = 1;
@@ -81,6 +87,4 @@
 	int imagecount = 0;
 	Image *images[2] = { NULL, NULL };
-
-	baudRate = baudRateMatchString( "9600" );
 
 	for( int t = 1; t < argc; t++ )
@@ -114,5 +118,6 @@
 			case 'p': case 'P':
 				ComPort = "PIPE";
-				baudRate = baudRateMatchString( "115200" );
+				if( !baudRate )
+					baudRate = baudRateMatchString( "115200" );
 				break;			  
 			case 'g': case 'G':
@@ -141,6 +146,6 @@
 				if( !(baudRate = baudRateMatchString( argv[++t] )) )
 				{
-						fprintf( stderr, "Unknown Baud Rate %s\n\n", argv[t] );
-						usage();
+					fprintf( stderr, "Unknown Baud Rate %s\n\n", argv[t] );
+					usage();
 				}
 				break;
@@ -163,4 +168,7 @@
 		usage();
 
+	if( !baudRate )
+		baudRate = baudRateMatchString( "38400" );
+
 	do
 	{
Index: trunk/Serial_Server/win32/Win32Serial.cpp
===================================================================
--- trunk/Serial_Server/win32/Win32Serial.cpp	(revision 213)
+++ trunk/Serial_Server/win32/Win32Serial.cpp	(revision 215)
@@ -53,4 +53,7 @@
 		if( !ConnectNamedPipe( pipe, NULL ) )
 			log( -1, "Could not ConnectNamedPipe" );
+
+		if( baudRate->divisor > 3 )
+			log( -1, "Cannot simulate baud rates with hardware multipliers" );
 
 		speedEmulation = 1;
