[译]IntelliPort-著名的超级终端的替代Windows版本
By robot-v1.0
本文链接 https://www.kyfws.com/applications/intelliport-an-alternative-windows-version-to-the-zh/
版权声明 本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
- 9 分钟阅读 - 4109 个词 阅读量 0[译]IntelliPort-著名的超级终端的替代Windows版本
原文地址:https://www.codeproject.com/Articles/799126/IntelliPort-An-Alternative-Windows-Version-to-the
原文作者:Ștefan-Mihai MOGA
译文由本站 robot-v1.0 翻译
前言
You can use IntelliPort to transfer large files from a computer onto your portable computer using a serial port rather than going through the process of setting up your portable computer on a network.
您可以使用IntelliPort通过串行端口将大文件从计算机传输到便携式计算机上,而无需执行在网络上设置便携式计算机的过程.
The main purpose of this MFC application is to get logs via serial port or UDP socket from embedded systems, such as EFTPOS devices, and it is based on PJ Naughter’s CSerialPort and CWSocket classes.
该MFC应用程序的主要目的是通过串行端口或UDP套接字从嵌入式系统(例如EFTPOS设备)获取日志,它基于PJ Naughter的CSerialPort和CWSocket类.
- 下载源代码(来自GitLab)(Download source code (from GitLab))
- 下载可执行文件(外部站点)(Download executable (external site))
介绍(Introduction)
如您所知,Microsoft从Windows 7开始放弃了超级终端的开发.IntelliPort是一个程序,您可以使用空调制解调器电缆或以太网连接来连接到其他计算机. IntelliPort记录在连接另一端进出计算机的消息.因此,在设置和使用调制解调器时,它可以作为有价值的故障排除工具.为确保调制解调器正确连接或查看调制解调器的设置,您可以通过IntelliPort发送命令并检查结果. IntelliPort具有滚动功能,使您可以查看从屏幕上滚动出来的收到的文本.您可以使用IntelliPort通过串行端口将大文件从计算机传输到便携式计算机上,而无需执行在网络上设置便携式计算机的过程. IntelliPort被设计为易于使用的工具,并不意味着要替代市场上可用的其他全功能工具.您可以使用IntelliPort执行上述特定任务,但不要尝试将IntelliPort用于更复杂的通信需求.(As you already know, Microsoft has dropped the development of HyperTerminal starting with Windows 7. IntelliPort is a program that you can use to connect to other computers, using either your null modem cable or Ethernet connection. IntelliPort records the messages passed to and from the computer on the other end of your connection. Therefore, it can serve as a valuable troubleshooting tool when setting up and using your modem. To make sure that your modem is connected properly or to view your modem’s settings, you can send commands through IntelliPort and check the results. IntelliPort has scroll functionality that allows you to look at received text that has scrolled off the screen. You can use IntelliPort to transfer large files from a computer onto your portable computer using a serial port rather than going through the process of setting up your portable computer on a network. IntelliPort is designed to be an easy-to-use tool and is not meant to replace other full-feature tools available on the market. You can use IntelliPort to perform the specific tasks described above, but do not attempt to use IntelliPort for more complex communication needs.)
背景(Background)
该MFC应用程序的主要目的是通过串行端口或UDP套接字从嵌入式系统(例如EFTPOS设备)获取日志,它基于PJ Naughter的(The main purpose of this MFC application is to get logs via serial port or UDP socket from embedded systems, such as EFTPOS devices, and it is based on PJ Naughter’s) CSerialPort
和(and) CWSocket
类.对于不知道的人,EFTPOS是无需携带现金即可购买商品或服务的方法.在进行购买时,EFTPOS客户会将EFTPOS卡交给出纳员,然后将其插入现场EFTPOS机器中.当EFTPOS客户通过签名或安全PIN确认购买后,EFTPOS设备就交易以电子方式联系商店的银行.一条消息也会发送到客户的银行.除非有理由不完成EFTPOS交易,否则资金将在两个帐户之间转移. EFTPOS事务仅需几秒钟的时间.在EFTPOS客户将货物放入袋中之前,EFTPOS交易将完成. EFTPOS交易的确认以打印的EFTPOS交易记录的形式发送到商店并传递给客户.(classes. For those who do not know, EFTPOS is the method for paying for goods or services without needing to carry cash. On making a purchase, the EFTPOS customer gives an EFTPOS card to the cashier who inserts it into an on-site EFTPOS machine. When the EFTPOS customer confirms the purchase, either by signature or security PIN, the EFTPOS equipment contacts the store’s bank electronically about the transaction. A message is also sent to the customer’s bank. Unless there is reason for the EFTPOS transaction not to be completed, the funds will then be transferred between the two accounts. The EFTPOS transaction takes a matter of only a few seconds. Before the EFTPOS customer has had the goods put into a bag, the EFTPOS transaction will be complete. Confirmation of the EFTPOS transaction is sent to the store and passed on to the customer in the form of a printed EFTPOS transaction record.)
我如何开始?(How Do I Get Started?)
首先,配置MFC应用程序以从串行端口或TCP/UDP套接字连接获取日志.请检查(First, configure the MFC application to get logs from either serial port or TCP/UDP socket connection. Please check the) CConfigureDlg
类以了解实现细节.(class for implementation details.)
接下来,现在您可以连接/断开数据源.请检查(Next, now you can connect/disconnect from your data source. Please check the) OnOpenSerialPort
和(and) OnCloseSerialPort
实现细节的功能.(functions for implementation details.)
void CMainFrame::OnOpenSerialPort()
{
CString strFormat, strMessage;
switch (theApp.GetInt(_T("Connection"), 0))
{
case 0:
{
CString strFullPortName;
strFullPortName.Format(_T("\\\\.\\%s"), theApp.GetString(_T("SerialName"), _T("COM1")));
m_pSerialPort.Open(
strFullPortName,
theApp.GetInt(_T("BaudRate"), CBR_115200),
(CSerialPort::Parity) theApp.GetInt(_T("Parity"), CSerialPort::NoParity),
(BYTE)theApp.GetInt(_T("DataBits"), 8),
(CSerialPort::StopBits) theApp.GetInt(_T("StopBits"), CSerialPort::OneStopBit),
(CSerialPort::FlowControl) theApp.GetInt(_T("FlowControl"), CSerialPort::NoFlowControl),
FALSE);
if (m_pSerialPort.IsOpen())
{
m_nThreadRunning = TRUE;
AfxBeginThread(SerialPortThreadFunc, this);
strFormat.LoadString(IDS_SERIAL_PORT_OPENED);
strMessage.Format(strFormat, theApp.GetString(_T("SerialName"), _T("COM1")));
SetCaptionBarText(strMessage);
}
break;
}
case 1:
case 2:
{
CString strServerIP = theApp.GetString(_T("ServerIP"), _T("127.0.0.1"));
if (strServerIP.IsEmpty()) strServerIP = _T("127.0.0.1");
UINT nServerPort = theApp.GetInt(_T("ServerPort"), 0);
CString strClientIP = theApp.GetString(_T("ClientIP"), _T("127.0.0.1"));
if (strClientIP.IsEmpty()) strClientIP = _T("127.0.0.1");
UINT nClientPort = theApp.GetInt(_T("ClientPort"), 0);
m_pSocket.SetBindAddress(strClientIP);
m_pSocket.CreateAndBind(nClientPort,
((theApp.GetInt(_T("Connection"), 0) == 1) ? SOCK_STREAM : SOCK_DGRAM), AF_INET);
if (m_pSocket.IsCreated())
{
if (theApp.GetInt(_T("Connection"), 0) == 1) // TCP Socket
{
if (theApp.GetInt(_T("SocketType"), 0) == 1) // Client
{
m_pSocket.Connect(strServerIP, nServerPort);
}
else // TCP Server
{
m_dlgIncoming.ShowWindow(SW_SHOW);
m_dlgIncoming.CenterWindow(this);
m_dlgIncoming.Invalidate();
m_dlgIncoming.UpdateWindow();
m_pSocket.Listen();
m_pSocket.Accept(m_pIncomming);
m_dlgIncoming.ShowWindow(SW_HIDE);
}
}
else // UDP Socket
{
strServerIP = strClientIP;
nServerPort = nClientPort;
}
m_nThreadRunning = TRUE;
AfxBeginThread(SocketThreadFunc, this);
strFormat.LoadString(IDS_SOCKET_CREATED);
strMessage.Format(strFormat, ((theApp.GetInt(_T("Connection"), 0) == 1) ?
_T("TCP") : _T("UDP")), strServerIP, nServerPort);
SetCaptionBarText(strMessage);
}
break;
}
}
}
void CMainFrame::OnCloseSerialPort()
{
CString strFormat, strMessage;
m_nThreadRunning = FALSE;
::Sleep(1000);
switch (theApp.GetInt(_T("Connection"), 0))
{
case 0:
{
m_pSerialPort.Close();
if (!m_pSerialPort.IsOpen())
{
strFormat.LoadString(IDS_SERIAL_PORT_CLOSED);
strMessage.Format(strFormat, theApp.GetString(_T("SerialName"), _T("COM1")));
SetCaptionBarText(strMessage);
}
break;
}
case 1:
case 2:
{
CString strServerIP = theApp.GetString(_T("ServerIP"), _T("127.0.0.1"));
if (strServerIP.IsEmpty()) strServerIP = _T("127.0.0.1");
UINT nServerPort = theApp.GetInt(_T("ServerPort"), 0);
CString strClientIP = theApp.GetString(_T("ClientIP"), _T("127.0.0.1"));
if (strClientIP.IsEmpty()) strClientIP = _T("127.0.0.1");
UINT nClientPort = theApp.GetInt(_T("ClientPort"), 0);
m_pSocket.Close();
m_pIncomming.Close();
if (!m_pSocket.IsCreated())
{
if (theApp.GetInt(_T("Connection"), 0) == 1) // TCP Socket
{
if (theApp.GetInt(_T("SocketType"), 0) == 1) // Client
{
}
else // TCP Server
{
}
}
else // UDP Socket
{
strServerIP = strClientIP;
nServerPort = nClientPort;
}
strFormat.LoadString(IDS_SOCKET_CLOSED);
strMessage.Format(strFormat, ((theApp.GetInt(_T("Connection"), 0) == 1) ?
_T("TCP") : _T("UDP")), strServerIP, nServerPort);
SetCaptionBarText(strMessage);
}
break;
}
}
}
void CMainFrame::OnSendReceive()
{
CInputDlg dlgInput(this);
if (dlgInput.DoModal() == IDOK)
{
CStringA pBuffer(dlgInput.m_strSendData);
const int nLength = pBuffer.GetLength();
switch (theApp.GetInt(_T("Connection"), 0))
{
case 0:
{
m_pMutualAccess.lock();
m_pSerialPort.Write(pBuffer.GetBufferSetLength(nLength), nLength);
m_pMutualAccess.unlock();
pBuffer.ReleaseBuffer();
break;
}
case 1:
case 2:
{
CString strServerIP = theApp.GetString(_T("ServerIP"), _T("127.0.0.1"));
if (strServerIP.IsEmpty()) strServerIP = _T("127.0.0.1");
const UINT nServerPort = theApp.GetInt(_T("ServerPort"), 0);
if (theApp.GetInt(_T("Connection"), 0) == 1) // TCP Socket
{
if (theApp.GetInt(_T("SocketType"), 0) == 1) // Client
{
if (m_pSocket.IsWritable(1000))
{
m_pMutualAccess.lock();
m_pSocket.Send(pBuffer.GetBufferSetLength(nLength), nLength, 0);
pBuffer.ReleaseBuffer();
m_pMutualAccess.unlock();
}
}
else
{
if (m_pIncomming.IsWritable(1000))
{
m_pMutualAccess.lock();
m_pIncomming.Send(pBuffer.GetBufferSetLength(nLength), nLength, 0);
pBuffer.ReleaseBuffer();
m_pMutualAccess.unlock();
}
}
}
else
{
if (m_pSocket.IsWritable(1000))
{
m_pMutualAccess.lock();
m_pSocket.SendTo(pBuffer.GetBufferSetLength(nLength),
nLength, nServerPort, strServerIP, 0);
pBuffer.ReleaseBuffer();
m_pMutualAccess.unlock();
}
}
break;
}
}
}
}
兴趣点(Points of Interest)
为了响应GUI,MFC应用程序在单独的工作线程中进行读取:(In order to be GUI responsive, the MFC application does the reading in separate working threads:)
UINT SerialPortThreadFunc(LPVOID pParam)
{
COMSTAT status = { 0, };
char pBuffer[0x10000] = { 0, };
CMainFrame* pMainFrame = (CMainFrame*)pParam;
CRingBuffer& pRingBuffer = pMainFrame->m_pRingBuffer;
CSerialPort& pSerialPort = pMainFrame->m_pSerialPort;
std::mutex& pMutualAccess = pMainFrame->m_pMutualAccess;
while (pMainFrame->m_nThreadRunning)
{
memset(&status, 0, sizeof(status));
pSerialPort.GetStatus(status);
if (status.cbInQue > 0)
{
memset(pBuffer, 0, sizeof(pBuffer));
const int nLength = pSerialPort.Read(pBuffer, sizeof(pBuffer));
pMutualAccess.lock();
pRingBuffer.WriteBinary(pBuffer, nLength);
pMutualAccess.unlock();
}
else
{
::Sleep(10);
}
}
return 0;
}
UINT SocketThreadFunc(LPVOID pParam)
{
char pBuffer[0x10000] = { 0, };
CMainFrame* pMainFrame = (CMainFrame*)pParam;
CRingBuffer& pRingBuffer = pMainFrame->m_pRingBuffer;
CWSocket& pSocket = pMainFrame->m_pSocket;
CWSocket& pIncomming = pMainFrame->m_pIncomming;
std::mutex& pMutualAccess = pMainFrame->m_pMutualAccess;
BOOL bIsTCP = (theApp.GetInt(_T("Connection"), 0) == 1);
BOOL bIsClient = (theApp.GetInt(_T("SocketType"), 0) == 1);
CString strServerIP = theApp.GetString(_T("ServerIP"), _T("127.0.0.1"));
if (strServerIP.IsEmpty()) strServerIP = _T("127.0.0.1");
UINT nServerPort = theApp.GetInt(_T("ServerPort"), 0);
while (pMainFrame->m_nThreadRunning)
{
if (bIsTCP)
{
if (bIsClient)
{
if (pSocket.IsReadible(1000))
{
memset(pBuffer, 0, sizeof(pBuffer));
const int nLength = pSocket.Receive(pBuffer, sizeof(pBuffer), 0);
pMutualAccess.lock();
pRingBuffer.WriteBinary(pBuffer, nLength);
pMutualAccess.unlock();
}
else
{
::Sleep(10);
}
}
else
{
if (pIncomming.IsReadible(1000))
{
memset(pBuffer, 0, sizeof(pBuffer));
const int nLength = pIncomming.Receive(pBuffer, sizeof(pBuffer), 0);
pMutualAccess.lock();
pRingBuffer.WriteBinary(pBuffer, nLength);
pMutualAccess.unlock();
}
else
{
::Sleep(10);
}
}
}
else
{
if (pSocket.IsReadible(1000))
{
memset(pBuffer, 0, sizeof(pBuffer));
const int nLength = pSocket.ReceiveFrom(pBuffer, sizeof(pBuffer),
strServerIP, nServerPort, 0);
pMutualAccess.lock();
pRingBuffer.WriteBinary(pBuffer, nLength);
pMutualAccess.unlock();
}
else
{
::Sleep(10);
}
}
}
return 0;
}
最后的话(Final Words)
IntelliPort应用程序使用已在Code Project上发布的许多组件.非常感谢:(IntelliPort application uses many components that have been published on Code Project. Many thanks to:)
- PJ诺特为他(PJ Naughter for his)
EnumSerialPorts
类(class) - 拉里
安特兰(Larry Antram)(*Larry Antram for his*)
CRingBuffer` 类(class) - PJ诺特为他(PJ Naughter for his)
CSerialPort
类(class) - PJ诺特为他(PJ Naughter for his)
CWSocket
类(class) - PJ诺特为他(PJ Naughter for his)
CVersionInfo
类(class) 进一步的计划(Further plans):我想补充(: I would like to add)**远程登录(Telnet)**和(and)**SSH协议(SSH)**尽快支持.(support as soon as possible.)
历史(History)
-
版本1.3(20(Version 1.3 (20)日(th)2014年7月)(July, 2014))
- 初始发行(Initial release)
-
1.5版(28(Version 1.5 (28)日(th)2014年7月)(July, 2014))
- 修复了与串行端口和UDP套接字的日志记录功能有关的一些错误(Fixed several bugs regarding logging functions for serial port and UDP socket)
-
1.6版(30(Version 1.6 (30)日(th)2015年8月)(August, 2015))
- Microsoft Windows 10 64位修复(Fix for Microsoft Windows 10 64bit)
-
版本1.7(03(Version 1.7 (03)rd(rd)2019年4月)(April, 2019))
- 性能和安全修复(Performance and security fixes)
-
版本1.8(15(Version 1.8 (15)日(th)2019年6月)(June, 2019))
- 增加了罗马尼亚语翻译;(Added Romanian translation;)谁能添加德语/法语/西班牙语/等.翻译?(could anyone add German/French/Spanish/etc. translations?)
- 添加了PJ Naughter的(Added PJ Naughter’s)
CInstanceChecker
类;(class;)
-
版本1.9(27(Version 1.9 (27)日(th)2019年7月)(July, 2019))
- 串口名称的错误修正-请参阅注释中提到的文章(Bugfix for serial port name - please see the article mentioned in the comments)
-
将源代码从CodeProject移至GitLab(7(Moved source code from CodeProject to GitLab (7)日(th)2019年12月)(December, 2019))
-
版本1.10(25(Version 1.10 (25)日(th)2020年3月)(March, 2020))
- 更改了主对话框和输入对话框的字体大小(Changed font size for main and input dialogs)
-
版本1.11(9(Version 1.11 (9)日(th)2020年5月)(May, 2020))
- 感谢Stefan Gaftoniuc,添加了法语翻译(Added French translation, thanks to Stefan Gaftoniuc)
-
版本1.12(6(Version 1.12 (6)日(th)2020年6月)(June, 2020))
- 添加了意大利语翻译,感谢(Added Italian translation, thanks to) 国际语言(InterLingua)
-
版本1.13(13(Version 1.13 (13)日(th)2020年6月)(June, 2020))
- 感谢InterLingua,增加了德语翻译(Added German translation, thanks to InterLingua)
-
版本1.14(20(Version 1.14 (20)日(th)2020年6月)(June, 2020))
- 感谢InterLingua,添加了西班牙语翻译(Added Spanish translation, thanks to InterLingua)
-
版本1.15(19(Version 1.15 (19)日(th)2020年7月)(July, 2020))
- 感谢InterLingua,增加了俄语翻译(Added Russian translation, thanks to InterLingua)
-
版本1.16(31(Version 1.16 (31)圣(st)2020年7月)(July, 2020))
- 感谢InterLingua,添加了希腊语翻译(Added Greek translation, thanks to InterLingua)
-
版本1.17(12(Version 1.17 (12)日(th)2020年9月)(September, 2020))
-
我进行了改进并减少了错误,因此#IntelliPort更适合您:(I made improvements and squashed bugs so #IntelliPort is even better for you:)
- 我已经将PJ Naughter的CSerialPort库更新为可用的最新版本.(I’ve updated PJ Naughter’s CSerialPort library to the latest version available)
- 我已经将PJ Naughter的CWSocket库更新为可用的最新版本.(I’ve updated PJ Naughter’s CWSocket library to the latest version available)
-
-
版本1.18(25(Version 1.18 (25)日(th)2020年9月)-我已经重写了CEditCtrl 64K的限制.(September, 2020) - I’ve overwrote CEditCtrl 64K limit.)
许可
本文以及所有相关的源代码和文件均已获得The Code Project Open License (CPOL)的许可。
XML HTML Objective-C C++ .NET Windows MFC VS2010 Visual-Studio text 新闻 翻译