[SerialICE] r56 - trunk/qemu-0.11.0

svn at coresystems.de svn at coresystems.de
Thu Nov 19 23:06:14 CET 2009


Author: oxygene
Date: 2009-11-19 23:06:13 +0100 (Thu, 19 Nov 2009)
New Revision: 56

Modified:
   trunk/qemu-0.11.0/serialice.c
Log:
Fix SerialICE host side for Win32


Modified: trunk/qemu-0.11.0/serialice.c
===================================================================
--- trunk/qemu-0.11.0/serialice.c	2009-11-19 22:03:12 UTC (rev 55)
+++ trunk/qemu-0.11.0/serialice.c	2009-11-19 22:06:13 UTC (rev 56)
@@ -372,8 +372,9 @@
 
 	while (1) {
 #ifdef WIN32
-		int ret;
-		if (!ReadFile(state->fd, buf, nbyte - bytes_read, &ret, NULL))
+		int ret = 0;
+		ReadFile(state->fd, buf, nbyte - bytes_read, &ret, NULL);
+		if (!ret)
 			break;
 #else
 		int ret = read(state->fd, buf, nbyte - bytes_read);
@@ -404,9 +405,11 @@
 	for (i = 0; i < (int)nbyte; i++) {
 #ifdef WIN32
 		int ret = 0;
-		while (ret == 0) WriteFile(state->fd, buffer + i, 1, &ret, NULL);
+		while (ret == 0)
+			WriteFile(state->fd, buffer + i, 1, &ret, NULL);
 		ret = 0;
-		while (ret == 0) ReadFile(state->fd, &c, 1, &ret, NULL);
+		while (ret == 0)
+			ReadFile(state->fd, &c, 1, &ret, NULL);
 #else
 		while (write(state->fd, buffer + i, 1) != 1) ;
 		while (read(state->fd, &c, 1) != 1) ;
@@ -464,6 +467,12 @@
 		exit(1);
 	}
 
+	// compensate for CR on the wire. Needed on Win32
+	if (s->buffer[0] == '\r') {
+		memmove(s->buffer, s->buffer+1, reply_len);
+		serialice_read(s, s->buffer+reply_len-1, 1);
+	}
+
 	if (l != reply_len) {
 		printf("SerialICE: command was not answered sufficiently: "
 				"(%d/%d bytes)\n'%s'\n", l, reply_len, s->buffer);
@@ -828,33 +837,16 @@
 		exit(1);
 	}
 
-	dcb.BaudRate = 115200;
+	dcb.BaudRate = CBR_115200;
 	dcb.ByteSize = 8;
 	dcb.Parity = NOPARITY;
 	dcb.StopBits = ONESTOPBIT;
-	dcb.fDtrControl = DTR_CONTROL_DISABLE;
-	dcb.fInX = FALSE;
 
 	if (!SetCommState(s->fd, &dcb)) {
 		perror("SerialICE: Could not store config for target TTY");
 		exit(1);
 	}
 
-	COMMTIMEOUTS to;
-	if (!GetCommTimeouts(s->fd, &to)) {
-		perror("SerialICE: Could not load timeouts for target TTY");
-		exit(1);
-	}
-
-	to.ReadIntervalTimeout = 1000;
-	to.ReadTotalTimeoutMultiplier = 0;
-	to.ReadTotalTimeoutConstant = 0;
-
-	if (!SetCommTimeouts(s->fd, &to)) {
-		perror("SerialICE: Could not store timeouts for target TTY");
-		exit(1);
-	}
-	
 #else
 	s->fd = open(serialice_device, O_RDWR | O_NOCTTY | O_NONBLOCK);
 




More information about the SerialICE mailing list