1 /******************************************************************************
3 Project: Portable command line ISP for Philips LPC2000 family
4 and Analog Devices ADUC70xx
8 Compiler: Microsoft VC 6/7, GCC Cygwin, GCC Linux, GCC ARM ELF
10 Author: Martin Maurer (Martin.Maurer@clibb.de)
12 Copyright: (c) Martin Maurer 2003-2008, All rights reserved
13 Portions Copyright (c) by Aeolus Development 2004 http://www.aeolusdevelopment.com
15 This file is part of lpc21isp.
17 lpc21isp is free software: you can redistribute it and/or modify
18 it under the terms of the GNU Lesser General Public License as published by
19 the Free Software Foundation, either version 3 of the License, or
22 lpc21isp is distributed in the hope that it will be useful,
23 but WITHOUT ANY WARRANTY; without even the implied warranty of
24 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 GNU Lesser General Public License for more details.
27 You should have received a copy of the GNU Lesser General Public License
28 and GNU General Public License along with lpc21isp.
29 If not, see <http://www.gnu.org/licenses/>.
33 #if !defined __BORLANDC__
36 #endif // defined(_WIN32)
40 #ifdef TERMINAL_SUPPORT
41 /***************************** Terminal *********************************/
42 /** Acts as a simple dumb terminal. Press 'ESC' to exit.
44 BOOL CheckTerminalParameters(ISP_ENVIRONMENT *IspEnvironment, char* pstr)
46 if (stricmp(pstr, "-localecho") == 0)
48 IspEnvironment->LocalEcho = 1;
49 DebugPrintf(3, "Local echo in terminal mode.\n");
53 if (stricmp(pstr, "-term") == 0)
55 IspEnvironment->TerminalAfterUpload = 1;
56 DebugPrintf(3, "Invoke terminal after upload.\n");
60 if (stricmp(pstr, "-termonly") == 0)
62 IspEnvironment->TerminalOnly = 1;
63 IspEnvironment->ProgramChip = 0;
64 DebugPrintf(3, "Only provide terminal.\n");
71 void Terminal(ISP_ENVIRONMENT *IspEnvironment)
73 if (IspEnvironment->TerminalAfterUpload || IspEnvironment->TerminalOnly)
78 unsigned long realsize;
80 // When logging is switched on, output terminal output to lpc21isp.log
81 if (IspEnvironment->LogFile)
83 fdlogfile = open("lpc21isp.log", O_RDWR | O_BINARY | O_CREAT | O_TRUNC, 0777);
86 PrepareKeyboardTtySettings();
88 DebugPrintf(1, "Terminal started (press Escape to abort)\n\n");
93 ReceiveComPort(IspEnvironment, buffer, sizeof(buffer) - 1, &realsize, 0,200); // Check for received characters
97 write(1, buffer, realsize);
99 if (IspEnvironment->LogFile) // When logging is turned on, then copy output to logfile
101 write(fdlogfile, buffer, realsize);
105 // check for keypress, and write any out the port.
113 buffer[0] = (unsigned char)ch;
116 if (IspEnvironment->LocalEcho)
121 SendComPort(IspEnvironment, buffer);
126 DebugPrintf(1, "\n\nTerminal stopped\n\n");
129 ResetKeyboardTtySettings();
131 if (IspEnvironment->LogFile)