commsetdlg.cpp
来自「代码为windows下的无线猫的应用程序(对AT指令的操作)。」· C++ 代码 · 共 132 行
CPP
132 行
// CommSetDlg.cpp : implementation file
//
#include "stdafx.h"
#include "SIMTOOL.h"
#include "CommSetDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CCommSetDlg dialog
extern CSIMTOOLApp theApp;
CCommSetDlg::CCommSetDlg(CWnd* pParent /*=NULL*/)
: CDialog(CCommSetDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CCommSetDlg)
//}}AFX_DATA_INIT
}
void CCommSetDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CCommSetDlg)
DDX_Control(pDX, IDC_RESEARCHINFO, m_Status2);
DDX_Control(pDX, IDC_TEXTSTATUS1, m_Status1);
DDX_Control(pDX, IDC_BAUT1, m_Baut1);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CCommSetDlg, CDialog)
//{{AFX_MSG_MAP(CCommSetDlg)
ON_BN_CLICKED(IDC_CHGBTN, OnChgbtn)
ON_BN_CLICKED(IDC_BTNRESEARCH, OnBtnresearch)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CCommSetDlg message handlers
BOOL CCommSetDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
m_Baut1.AddString("9600");
m_Baut1.AddString("19200");
m_Baut1.AddString("38400");
m_Baut1.AddString("57600");
m_Baut1.AddString("115200");
m_Baut1.SetWindowText("115200");
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CCommSetDlg::OnChgbtn()
{
// TODO: Add your control notification handler code here
CString sDevComm, RetInfo;
char cBaut[10], cText[100];
int iBaut;
memset(cText, 0, 100);
memset(cBaut, 0, 10);
m_Baut1.GetWindowText(cBaut, 10);
iBaut = atoi(cBaut);
m_Status1.SetWindowText("正在设置端口属性...");
sDevComm = theApp.ResearchDev(iBaut);
if (sDevComm.GetLength() == 0)
{
theApp.mobile.CloseComm();
m_Status1.SetWindowText("请确定拨号上网所使用的波特率");
}
else
{
theApp.mobile.IPR(0);
RetInfo = theApp.mobile.ReceiveInfo();
// theApp.mobile.SendAT();
// RetInfo = theApp.mobile.ReceiveInfo();
theApp.mobile.CloseComm();
m_Status1.SetWindowText("端口已经设置成普通操作端口波特率");
sprintf(cText, "ADBON GPRS MODEM %s/%d", sDevComm, 9600);
theApp.SetStatusText("");
theApp.SetDevText(cText);
}
}
void CCommSetDlg::OnBtnresearch()
{
// TODO: Add your control notification handler code here
CString sDevComm, RetInfo;
int i, iBaut[] = {/*2400, 4800,*/ 9600, 14400, 19200, 38400, 57600, 115200};
char cInfo[100], cBaut[10];
memset(cInfo, 0, 100);
memset(cBaut, 0, 10);
i = 0;
m_Status2.SetWindowText("正在搜索GPRS设备...");
do
{
sDevComm = theApp.ResearchDev(iBaut[i]);
i++;
}
while(sDevComm.GetLength() == 0);
if (sDevComm.GetLength() == 0)
{
theApp.mobile.CloseComm();
m_Status2.SetWindowText("没有搜索到设备");
}
else
{
theApp.mobile.CloseComm();
sprintf(cInfo,
"搜索到设备在%s/%dbps,点击\"修改>>\"可以将设备设置更改到普通操作状态",
sDevComm, iBaut[i-1]);
sprintf(cBaut, "%d", iBaut[i-1]);
m_Baut1.SetWindowText(cBaut);
m_Status2.SetWindowText(cInfo);
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?