[Ttssh2-commit] [3874] シリアルポート接続のボーレートを直接入力できるようにした。

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2010年 5月 11日 (火) 20:15:21 JST


Revision: 3874
          http://sourceforge.jp/projects/ttssh2/svn/view?view=rev&revision=3874
Author:   maya
Date:     2010-05-11 20:15:21 +0900 (Tue, 11 May 2010)

Log Message:
-----------
シリアルポート接続のボーレートを直接入力できるようにした。

Modified Paths:
--------------
    trunk/doc/en/html/about/history.html
    trunk/doc/en/html/macro/command/setbaud.html
    trunk/doc/ja/html/about/history.html
    trunk/doc/ja/html/macro/command/setbaud.html
    trunk/teraterm/common/tttypes.h
    trunk/teraterm/teraterm/commlib.c
    trunk/teraterm/teraterm/commlib.h
    trunk/teraterm/teraterm/ttdde.c
    trunk/teraterm/teraterm/ttwinman.c
    trunk/teraterm/ttpdlg/ttdlg.c
    trunk/teraterm/ttpdlg/ttpdlg.rc
    trunk/teraterm/ttpfile/bplus.c
    trunk/teraterm/ttpfile/zmodem.c
    trunk/teraterm/ttpset/ttset.c


-------------- next part --------------
Modified: trunk/doc/en/html/about/history.html
===================================================================
--- trunk/doc/en/html/about/history.html	2010-05-10 00:41:23 UTC (rev 3873)
+++ trunk/doc/en/html/about/history.html	2010-05-11 11:15:21 UTC (rev 3874)
@@ -43,12 +43,15 @@
         </ul></li>
       <li>added support for the VPB and HPB control sequence.</li>
       <li>added the Show Macro Window of the Control menu to flash the running macro window.</li>
+      <!--li>ƒVƒŠƒAƒ‹ƒ|[ƒgÚ‘±‚̃{[ƒŒ[ƒg‚ð‘I‘ðŽˆˆÈŠO‚©‚ç‚àŽè“ü—͏o—ˆ‚é‚悤‚É‚µ‚½B
+        <ul>
+          <li>ƒ}ƒNƒƒRƒ}ƒ“ƒh "<a href="../macro/command/setbaud.html">setbaud</a>" ‚̈ø”‚Ƀ{[ƒŒ[ƒg‚Ì’l‚𒼐ڎw’è‚Å‚«‚é‚悤‚É‚µ‚½B</li-->
+        </ul></li>
       <li>added the "<a href="../macro/command/filestat.html">filestat</a>" macro command.</li>
       <li>added support for bracketed paste mode.</a>
     </ul>
   </li>
 
-
   <li>Bug fixes
     <ul>
       <li>Switching to alternate screen buffer, saving and restoring cursor position do not work correctly.</li>

Modified: trunk/doc/en/html/macro/command/setbaud.html
===================================================================
--- trunk/doc/en/html/macro/command/setbaud.html	2010-05-10 00:41:23 UTC (rev 3873)
+++ trunk/doc/en/html/macro/command/setbaud.html	2010-05-11 11:15:21 UTC (rev 3874)
@@ -21,10 +21,13 @@
 setbaud &lt;value&gt;
 </pre>
 
-<h2>Remarks</h2>
+<h2>Parameters</h2>
 
+<dl>
+	<dt class="macro">integer &lt;value&gt; (less than version 4.66)</dt>
+	<dd>The corresponding ID of baud rate.
 <pre>
-value    baudrate
+value    baud rate
 1        110 
 2        300 
 3        600 
@@ -41,11 +44,22 @@
 14       460800 
 15       921600 
 </pre>
+	</dd>
+	
+	<dt class="macro">integer &lt;value&gt; (version 4.66 or later)</dt>
+	<dd>The immediate baud rate.</dd>
+</dl>
 
 <h2>Example</h2>
 
 <pre class="macro-example">
-setbaud 12            ;change baud rate to 115200
+; change baud rate to 115200
+
+; less than version 4.66
+setbaud 12
+
+; version 4.66 or later
+setbaud 115200
 </pre>
 
 </body>

Modified: trunk/doc/ja/html/about/history.html
===================================================================
--- trunk/doc/ja/html/about/history.html	2010-05-10 00:41:23 UTC (rev 3873)
+++ trunk/doc/ja/html/about/history.html	2010-05-11 11:15:21 UTC (rev 3874)
@@ -43,6 +43,10 @@
         </ul></li>
       <li>VPB, HPB §ŒäƒV[ƒPƒ“ƒX‚ɑΉž‚µ‚½B</li>
       <li>ŽÀs’†‚̃}ƒNƒƒEƒBƒ“ƒhƒE‚ª‚Ç‚ê‚©•ª‚©‚é‚悤‚É‚·‚邽‚ß‚Ì Control - Show Macro Window ƒƒjƒ…[‚ð’ljÁ‚µ‚½B</li>
+      <li>ƒVƒŠƒAƒ‹ƒ|[ƒgÚ‘±‚̃{[ƒŒ[ƒg‚ð‘I‘ðŽˆˆÈŠO‚©‚ç‚àŽè“ü—͏o—ˆ‚é‚悤‚É‚µ‚½B
+        <ul>
+          <li>ƒ}ƒNƒƒRƒ}ƒ“ƒh "<a href="../macro/command/setbaud.html">setbaud</a>" ‚̈ø”‚Ƀ{[ƒŒ[ƒg‚Ì’l‚𒼐ڎw’è‚Å‚«‚é‚悤‚É‚µ‚½B</li>
+        </ul></li>
       <li>ƒ}ƒNƒƒRƒ}ƒ“ƒh "<a href="../macro/command/filestat.html">filestat</a>" ‚ð’ljÁ‚µ‚½B</li>
       <li>Bracketed Paste Mode ‚ɑΉž‚µ‚½B</a>
     </ul>

Modified: trunk/doc/ja/html/macro/command/setbaud.html
===================================================================
--- trunk/doc/ja/html/macro/command/setbaud.html	2010-05-10 00:41:23 UTC (rev 3873)
+++ trunk/doc/ja/html/macro/command/setbaud.html	2010-05-11 11:15:21 UTC (rev 3874)
@@ -21,10 +21,13 @@
 setbaud &lt;value&gt;
 </pre>
 
-<h2>‰ðà</h2>
+<h2>ƒpƒ‰ƒ[ƒ^</h2>
 
+<dl>
+	<dt class="macro">®” &lt;value&gt; (ƒo[ƒWƒ‡ƒ“ 4.66 –¢–ž)</dt>
+	<dd>ƒ{[ƒŒ[ƒg‚ɑΉž‚·‚éID‚ðŽw’è‚·‚éB
 <pre>
-value    baudrate
+ID       baud rate
 1        110 
 2        300 
 3        600 
@@ -41,11 +44,22 @@
 14       460800 
 15       921600 
 </pre>
+	</dd>
+	
+	<dt class="macro">®” &lt;value&gt; (ƒo[ƒWƒ‡ƒ“ 4.66 ˆÈ~)</dt>
+	<dd>ƒ{[ƒŒ[ƒg‚ðŽw’è‚·‚éB</dd>
+</dl>
 
 <h2>—á</h2>
 
 <pre class="macro-example">
-setbaud 12            ;change baud rate to 115200
+; change baud rate to 115200
+
+; less than version 4.66
+setbaud 12
+
+; version 4.66 or later
+setbaud 115200
 </pre>
 
 </body>

Modified: trunk/teraterm/common/tttypes.h
===================================================================
--- trunk/teraterm/common/tttypes.h	2010-05-10 00:41:23 UTC (rev 3873)
+++ trunk/teraterm/common/tttypes.h	2010-05-11 11:15:21 UTC (rev 3874)
@@ -397,7 +397,7 @@
 	WORD HistoryList;
 	/* Serial */
 	WORD ComPort;
-	WORD Baud;
+	WORD Baud_; /* not in use */
 	WORD Parity;
 	WORD DataBit;
 	WORD StopBit;
@@ -493,6 +493,7 @@
 	WORD WindowFlag;
 	WORD EnableLineMode;
 	char ConfirmChangePasteStringFile[MAX_PATH];
+	DWORD Baud;
 };
 
 typedef struct tttset TTTSet, *PTTSet;
@@ -568,25 +569,8 @@
 #define IdCOM3 3
 #define IdCOM4 4
   /* Baud rate ID */
-#define IdBaudNone   0
-#define IdBaud110    1
-#define IdBaud300    2
-#define IdBaud600    3
-#define IdBaud1200   4
-#define IdBaud2400   5
-#define IdBaud4800   6
-#define IdBaud9600   7
-#define IdBaud14400  8
-#define IdBaud19200  9
-#define IdBaud38400  10
-#define IdBaud57600  11
-#define IdBaud115200 12
-// expansion (2005.11.30 yutaka)
-#define IdBaud230400 13
-#define IdBaud460800 14
-#define IdBaud921600 15
+#define BaudNone    0
 
-// index + 1 == IdBaudXXX ‚ƂȂ邱‚ƁB
 static PCHAR far BaudList[] =
 	{"110","300","600","1200","2400","4800","9600",
 	 "14400","19200","38400","57600","115200",

Modified: trunk/teraterm/teraterm/commlib.c
===================================================================
--- trunk/teraterm/teraterm/commlib.c	2010-05-10 00:41:23 UTC (rev 3873)
+++ trunk/teraterm/teraterm/commlib.c	2010-05-11 11:15:21 UTC (rev 3874)
@@ -159,7 +159,7 @@
 
 	memset(&dcb,0,sizeof(DCB));
 	dcb.DCBlength = sizeof(DCB);
-	dcb.BaudRate = GetCommSerialBaudRate(ts->Baud);
+	dcb.BaudRate = ts->Baud;
 	dcb.fBinary = TRUE;
 	switch (ts->Parity) {
 		case IdParityEven:
@@ -1058,17 +1058,6 @@
 	}
 }
 
-int GetCommSerialBaudRate(int id)
-{
-	char *ch;
-	int val;
-
-	// id-1‚ªƒŠƒXƒg‚Ìindex‚Æ‚È‚éB
-	ch = BaudList[id - 1];
-	val = atoi(ch);
-	return (val);
-}
-
 BOOL PrnOpen(PCHAR DevName)
 {
 	char Temp[MAXPATHLEN];

Modified: trunk/teraterm/teraterm/commlib.h
===================================================================
--- trunk/teraterm/teraterm/commlib.h	2010-05-10 00:41:23 UTC (rev 3873)
+++ trunk/teraterm/teraterm/commlib.h	2010-05-11 11:15:21 UTC (rev 3874)
@@ -22,7 +22,6 @@
 void CommSendBreak(PComVar cv);
 void CommResetSerial(PTTSet ts, PComVar cv, BOOL ClearBuffer);
 void CommLock(PTTSet ts, PComVar cv, BOOL Lock);
-int GetCommSerialBaudRate(int id);
 BOOL PrnOpen(PCHAR DevName);
 int PrnWrite(PCHAR b, int c);
 void PrnCancel();

Modified: trunk/teraterm/teraterm/ttdde.c
===================================================================
--- trunk/teraterm/teraterm/ttdde.c	2010-05-10 00:41:23 UTC (rev 3873)
+++ trunk/teraterm/teraterm/ttdde.c	2010-05-11 11:15:21 UTC (rev 3874)
@@ -807,7 +807,7 @@
 
 	case CmdSetBaud:  // add 'setbaud' (2008.2.13 steven patch)
 		{
-		int val, ret;
+		int val;
 
 		//OutputDebugPrintf("CmdSetBaud entered\n");
 
@@ -815,9 +815,8 @@
 			return DDE_FNOTPROCESSED;
 
 		val = atoi(ParamFileName);
-		ret = GetCommSerialBaudRate(val);
-		//OutputDebugPrintf("CmdSetBaud: %d %d (%d)\n", val, ret, ts.Baud);
-		if (ret > 0) {
+		//OutputDebugPrintf("CmdSetBaud: %d (%d)\n", val, ts.Baud);
+		if (val > 0) {
 			ts.Baud = val;
 			CommResetSerial(&ts,&cv,FALSE);   // reset serial port
 			PostMessage(HVTWin,WM_USER_CHANGETITLE,0,0); // refresh title bar

Modified: trunk/teraterm/teraterm/ttwinman.c
===================================================================
--- trunk/teraterm/teraterm/ttwinman.c	2010-05-10 00:41:23 UTC (rev 3873)
+++ trunk/teraterm/teraterm/ttwinman.c	2010-05-11 11:15:21 UTC (rev 3874)
@@ -169,9 +169,9 @@
 		else if (cv.PortType==IdSerial)
 		{
 			// COM5 over‚ɑΉž
-			char str[20]; // COMxxxx:xxxxxxxbaud
+			char str[24]; // COMxxxx:xxxxxxxxxxbaud
 			if (ts.TitleFormat & 32) {
-				_snprintf_s(str, sizeof(str), _TRUNCATE, "COM%d:%dbaud", ts.ComPort, GetCommSerialBaudRate(ts.Baud));
+				_snprintf_s(str, sizeof(str), _TRUNCATE, "COM%d:%ubaud", ts.ComPort, ts.Baud);
 			}
 			else {
 				_snprintf_s(str, sizeof(str), _TRUNCATE, "COM%d", ts.ComPort);

Modified: trunk/teraterm/ttpdlg/ttdlg.c
===================================================================
--- trunk/teraterm/ttpdlg/ttdlg.c	2010-05-10 00:41:23 UTC (rev 3873)
+++ trunk/teraterm/ttpdlg/ttdlg.c	2010-05-11 11:15:21 UTC (rev 3874)
@@ -1410,7 +1410,8 @@
 			}
 			SendDlgItemMessage(Dialog, IDC_SERIALPORT, CB_SETCURSEL, w, 0);
 
-			SetDropDownList(Dialog, IDC_SERIALBAUD, BaudList, ts->Baud);
+			SetDropDownList(Dialog, IDC_SERIALBAUD, BaudList, 0);
+			SetDlgItemInt(Dialog, IDC_SERIALBAUD, ts->Baud, FALSE);
 			SetDropDownList(Dialog, IDC_SERIALDATA, DataList, ts->DataBit);
 			SetDropDownList(Dialog, IDC_SERIALPARITY, ParityList, ts->Parity);
 			SetDropDownList(Dialog, IDC_SERIALSTOP, StopList, ts->StopBit);
@@ -1437,7 +1438,10 @@
 							ts->ComPort = 0;
 						}
 
-						ts->Baud = (WORD)GetCurSel(Dialog, IDC_SERIALBAUD);
+						GetDlgItemText(Dialog, IDC_SERIALBAUD, Temp, sizeof(Temp)-1);
+						if (atoi(Temp) != 0) {
+							ts->Baud = (DWORD)atoi(Temp);
+						}
 						ts->DataBit = (WORD)GetCurSel(Dialog, IDC_SERIALDATA);
 						ts->Parity = (WORD)GetCurSel(Dialog, IDC_SERIALPARITY);
 						ts->StopBit = (WORD)GetCurSel(Dialog, IDC_SERIALSTOP);

Modified: trunk/teraterm/ttpdlg/ttpdlg.rc
===================================================================
--- trunk/teraterm/ttpdlg/ttpdlg.rc	2010-05-10 00:41:23 UTC (rev 3873)
+++ trunk/teraterm/ttpdlg/ttpdlg.rc	2010-05-11 11:15:21 UTC (rev 3874)
@@ -152,7 +152,7 @@
     CONTROL         "&Port:",IDC_SERIALPORT_LABEL,"Static",SS_LEFTNOWORDWRAP,15,9,50,8
     COMBOBOX        IDC_SERIALPORT,75,7,48,52,CBS_DROPDOWNLIST | CBS_HASSTRINGS | WS_VSCROLL | WS_TABSTOP
     CONTROL         "&Baud rate:",IDC_SERIALBAUD_LEBAL,"Static",SS_LEFTNOWORDWRAP,15,24,50,8
-    COMBOBOX        IDC_SERIALBAUD,75,22,48,100,CBS_DROPDOWNLIST | CBS_HASSTRINGS | WS_VSCROLL | WS_TABSTOP
+    COMBOBOX        IDC_SERIALBAUD,75,22,48,100,CBS_DROPDOWN | CBS_HASSTRINGS | WS_VSCROLL | WS_TABSTOP
     CONTROL         "&Data:",IDC_SERIALDATA_LABEL,"Static",SS_LEFTNOWORDWRAP,15,39,50,8
     COMBOBOX        IDC_SERIALDATA,75,37,48,35,CBS_DROPDOWNLIST | CBS_HASSTRINGS | WS_VSCROLL | WS_TABSTOP
     CONTROL         "P&arity:",IDC_SERIALPARITY_LABEL,"Static",SS_LEFTNOWORDWRAP,15,54,50,8

Modified: trunk/teraterm/ttpfile/bplus.c
===================================================================
--- trunk/teraterm/ttpfile/bplus.c	2010-05-10 00:41:23 UTC (rev 3873)
+++ trunk/teraterm/ttpfile/bplus.c	2010-05-11 11:15:21 UTC (rev 3874)
@@ -95,20 +95,28 @@
   }
   else {
     bv->TimeOut = BPTimeOut;
-    switch (ts->Baud) {
-      case IdBaud110:
-	bv->TimeOut = BPTimeOut*2;
-	bv->MaxBS = 1;
-	break;
-      case IdBaud300: bv->MaxBS = 1; break;
-      case IdBaud600: bv->MaxBS = 2; break;
-      case IdBaud1200: bv->MaxBS = 4; break;
-      case IdBaud2400: bv->MaxBS = 8; break;
-      case IdBaud4800: bv->MaxBS = 12; break;
-      default:
-	bv->MaxBS = 16;
-	break;
+    if (ts->Baud <= 110) {
+      bv->TimeOut = BPTimeOut*2;
+      bv->MaxBS = 1;
     }
+    else if (ts->Baud <= 300) {
+      bv->MaxBS = 1;
+    }
+    else if (ts->Baud <= 600) {
+      bv->MaxBS = 2;
+    }
+    else if (ts->Baud <= 1200) {
+      bv->MaxBS = 4;
+    }
+    else if (ts->Baud <= 2400) {
+      bv->MaxBS = 8;
+    }
+    else if (ts->Baud <= 480) {
+      bv->MaxBS = 12;
+    }
+    else {
+      bv->MaxBS = 16;
+    }
   }
 
   fv->LogFlag = ((ts->LogFlag & LOG_BP)!=0);

Modified: trunk/teraterm/ttpfile/zmodem.c
===================================================================
--- trunk/teraterm/ttpfile/zmodem.c	2010-05-10 00:41:23 UTC (rev 3873)
+++ trunk/teraterm/ttpfile/zmodem.c	2010-05-11 11:15:21 UTC (rev 3874)
@@ -665,21 +665,19 @@
 		Max = 1024;
 	} else {
 		zv->TimeOut = NormalTimeOut;
-		switch (ts->Baud) {
-		case IdBaud110:
+		if (ts->Baud <= 110) {
 			Max = 64;
-			break;
-		case IdBaud300:
+		}
+		else if (ts->Baud <= 300) {
 			Max = 128;
-			break;
-		case IdBaud600:
-		case IdBaud1200:
+		}
+		else if (ts->Baud <= 1200) {
 			Max = 256;
-			break;
-		case IdBaud2400:
+		}
+		else if (ts->Baud <= 2400) {
 			Max = 512;
-			break;
-		default:
+		}
+		else {
 			Max = 1024;
 		}
 	}

Modified: trunk/teraterm/ttpset/ttset.c
===================================================================
--- trunk/teraterm/ttpset/ttset.c	2010-05-10 00:41:23 UTC (rev 3873)
+++ trunk/teraterm/ttpset/ttset.c	2010-05-11 11:15:21 UTC (rev 3874)
@@ -644,9 +644,7 @@
 	ts->ComPort = GetPrivateProfileInt(Section, "ComPort", 1, FName);
 
 	/* Baud rate */
-	GetPrivateProfileString(Section, "BaudRate", "9600",
-	                        Temp, sizeof(Temp), FName);
-	ts->Baud = str2id(BaudList, Temp, IdBaud9600);
+	ts->Baud = GetPrivateProfileInt(Section, "BaudRate", 9600, FName);
 
 	/* Parity */
 	GetPrivateProfileString(Section, "Parity", "",
@@ -1811,7 +1809,7 @@
 	WritePrivateProfileString(Section, "ComPort", Temp, FName);
 
 	/* Baud rate */
-	id2str(BaudList, ts->Baud, IdBaud9600, Temp, sizeof(Temp));
+	_snprintf_s(Temp, sizeof(Temp), _TRUNCATE, "%d", ts->Baud);
 	WritePrivateProfileString(Section, "BaudRate", Temp, FName);
 
 	/* Parity */
@@ -2897,7 +2895,7 @@
 	WORD ParamTCP = 65535;
 	WORD ParamTel = 2;
 	WORD ParamBin = 2;
-	WORD ParamBaud = IdBaudNone;
+	DWORD ParamBaud = BaudNone;
 	BOOL HostNameFlag = FALSE;
 	BOOL JustAfterHost = FALSE;
 
@@ -2943,7 +2941,8 @@
 
 		if (_strnicmp(Temp, "/BAUD=", 6) == 0) {	/* Serial port baud rate */
 			ParamPort = IdSerial;
-			ParamBaud = str2id(BaudList, &Temp[6], IdBaudNone);
+			if (atoi(&Temp[3]) != 0)
+				ParamBaud = atoi(&Temp[3]);
 		}
 		else if (_stricmp(Temp, "/B") == 0) {	/* telnet binary */
 			ParamPort = IdTCPIP;
@@ -3176,10 +3175,10 @@
 		ts->PortType = IdSerial;
 		if (ParamCom > 0) {
 			ts->ComPort = ParamCom;
- 		    /* Don't display new connection dialog if COM port is specified explicitly (2006.9.15 maya) */ 
+			/* Don't display new connection dialog if COM port is specified explicitly (2006.9.15 maya) */ 
 			ts->ComAutoConnect = TRUE; 
 		}
-		if (ParamBaud != IdBaudNone)
+		if (ParamBaud != BaudNone)
 			ts->Baud = ParamBaud;
 		break;
 	case IdFile:



Ttssh2-commit メーリングリストの案内
Back to archive index