[問題] RS 232 傳輸問題 C++
小弟我目前在利用RS232做傳輸 做到已經可以開COM1了
只是目前在傳輸資料部份有點問題 也因小弟的 C++ 在新手階段 所以煩請大大指導一下 謝謝
以下為 傳輸資料的部份
HANDLE hCom;
DCB dcb;
COMMTIMEOUTS cto;
int fSuccess;
DWORD cReadBytes ;
DWORD cWriteBytes ;
int szReadText[1],szWriteText[10];
int ClickEdit01St=0;
int ClickEdit01=0;
void Crs232test4Dlg::OnBnClickedButton2Send()
{
int szWriteText[10];
int fSuccess;
HANDLE hCom;
DWORD cWriteBytes ;
CString str1;
CEdit* Edit01 = (CEdit*)GetDlgItem(IDC_EDIT_writebox);
Edit01->GetWindowTextW(str1);
//strcpy (szWriteText, str1);
fSuccess = WriteFile (hCom, szWriteText, , &cWriteBytes, 0);
if(!fSuccess)
AfxMessageBox(_T("WriteFile Fail !"),MB_OK);
CloseHandle(hCom);
}
void Crs232test4Dlg::OnEnSetfocusEdit1()
{
if(ClickEdit01St==0)
{
CString str;
str="";
SetDlgItemText(IDC_EDIT1,str);
ClickEdit01St=1;
}
ClickEdit01=1;
}
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 124.11.23.107
→
09/22 17:28, , 1F
09/22 17:28, 1F
→
09/23 11:07, , 2F
09/23 11:07, 2F
推
09/24 09:44, , 3F
09/24 09:44, 3F
→
09/24 09:45, , 4F
09/24 09:45, 4F
→
09/24 09:46, , 5F
09/24 09:46, 5F
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章