powered by simpleCommunicator - 2.0.61     © 2026 Programmizd 02
Целевая тема:
Создать новую тему:
Автор:
Закрыть
Цитировать
Форумы / C++ [игнор отключен] [закрыт для гостей] / uprvalenie DTR linii COM porta
1 сообщений из 1, страница 1 из 1
uprvalenie DTR linii COM porta
    #33233388
Radioinjiner
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
HANDLE hCom = CreateFile( "COM1:",
GENERIC_READ | GENERIC_WRITE,
0, // must be opened with exclusive-access
NULL, // no security attributes
OPEN_EXISTING, // must use OPEN_EXISTING
0, // not overlapped I/O
NULL // hTemplate must be NULL for comm devices
);

if (hCom == INVALID_HANDLE_VALUE)
{
ShowMessage("Port is not open !!!");
}
else
{
ShowMessage("Port open");
}
DCB PortDCB;

PortDCB.DCBlength = sizeof (DCB);

// Get the default port setting information.
GetCommState (hCom, &PortDCB);

PortDCB.BaudRate = 9600; // Current baud
PortDCB.fDtrControl = DTR_CONTROL_ENABLE; // DTR flow control type
PortDCB.ByteSize = 8; // Number of bits/byte, 4-8
PortDCB.Parity = NOPARITY; // 0-4=no,odd,even,mark,space
PortDCB.StopBits = ONESTOPBIT; // 0,1,2 = 1, 1.5, 2

if (!SetCommState (hCom, &PortDCB))
{
ShowMessage("Unable to configure the serial port");

}
COMMTIMEOUTS cto;
cto.ReadIntervalTimeout = 0;
cto.ReadTotalTimeoutMultiplier = 0;
cto.ReadTotalTimeoutConstant = 0;
cto.WriteTotalTimeoutMultiplier = 0;
cto.WriteTotalTimeoutConstant = 0;
SetCommTimeouts (hCom, &cto);
//Then im trining to chanege potr state by the EscapeCommFunction
EscapeCommFunction(hCom, SETDTR); //To Set DTR
EscvapeCommFunction(hCom, CLRDTR); //To reset DTR

//i close port by CloseHandle(hCom);
...
Рейтинг: 0 / 0
1 сообщений из 1, страница 1 из 1
Форумы / C++ [игнор отключен] [закрыт для гостей] / uprvalenie DTR linii COM porta
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]