From a4f0515ab164bb6a2fd44c2fc3e2d3c7ba45a08b Mon Sep 17 00:00:00 2001
From: rswindell <>
Date: Mon, 6 Jul 2009 20:36:23 +0000
Subject: [PATCH] Have comOpen() force the port to N-8-1 as some com devices
 apparently default to E-7-1.

---
 src/comio/comio_win32.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/src/comio/comio_win32.c b/src/comio/comio_win32.c
index 2324d85298..3e0dd467df 100644
--- a/src/comio/comio_win32.c
+++ b/src/comio/comio_win32.c
@@ -8,7 +8,7 @@
  * @format.tab-size 4		(Plain Text/Source Code File Header)			*
  * @format.use-tabs true	(see http://www.synchro.net/ptsc_hdr.html)		*
  *																			*
- * Copyright 2007 Rob Swindell - http://www.synchro.net/copyright.html		*
+ * Copyright 2009 Rob Swindell - http://www.synchro.net/copyright.html		*
  *																			*
  * This library is free software; you can redistribute it and/or			*
  * modify it under the terms of the GNU Lesser General Public License		*
@@ -52,6 +52,7 @@ COM_HANDLE comOpen(const char* device)
 {
 	COM_HANDLE handle;
 	COMMTIMEOUTS timeouts;
+	DCB	dcb;
 
 	if((handle=CreateFile(device
 		,GENERIC_READ|GENERIC_WRITE 	/* Access */
@@ -73,6 +74,14 @@ COM_HANDLE comOpen(const char* device)
 		SetCommTimeouts(handle,&timeouts);
 	}
 
+	/* Force N-8-1 mode: */
+	if(GetCommState(handle, &dcb)==TRUE) {
+		dcb.ByteSize	= 8;
+		dcb.Parity		= NOPARITY;
+		dcb.StopBits	= ONESTOPBIT;
+		SetCommState(handle, &dcb);
+	}
+
 	return handle;
 }
 
-- 
GitLab