* [Comm] Программирование для COM-порта @ 2003-01-16 12:40 Прокопьев Евгений 2003-01-16 13:05 ` Sergey Vlasov 2003-01-16 13:49 ` [Comm] " Бессонов Ян 0 siblings, 2 replies; 3+ messages in thread From: @ 2003-01-16 12:40 UTC (permalink / raw) ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Comm] Программирование для COM-порта 2003-01-16 12:40 [Comm] Программирование для COM-порта Прокопьев Евгений @ 2003-01-16 13:05 ` Sergey Vlasov 2003-01-16 13:49 ` [Comm] " Бессонов Ян 1 sibling, 0 replies; 3+ messages in thread From: Sergey Vlasov @ 2003-01-16 13:05 UTC (permalink / raw) To: community On Thu, 16 Jan 2003 15:40:11 +0300 Прокопьев Евгений <john@rmts.donpac.ru> wrote: > Как в программе на С устанавливать параметры COM-порта? > > Ecть следующий код для оффтопика, необходимо написать его аналог: [термиты поели] [p]info libc, раздел Low-Level Terminal Interface. Ещё есть Serial-Programming-HOWTO. ^ permalink raw reply [flat|nested] 3+ messages in thread
* [Comm] Re: [Comm] Программирование для COM-порта 2003-01-16 12:40 [Comm] Программирование для COM-порта Прокопьев Евгений 2003-01-16 13:05 ` Sergey Vlasov @ 2003-01-16 13:49 ` Бессонов Ян 1 sibling, 0 replies; 3+ messages in thread From: Бессонов Ян @ 2003-01-16 13:49 UTC (permalink / raw) To: community ----- Original Message ----- From: "Прокопьев Евгений" <john@rmts.donpac.ru> To: <community@altlinux.ru> Sent: Thursday, January 16, 2003 3:40 PM Subject: [Comm] Программирование для COM-порта > Здравствуйте! > > Как в программе на С устанавливать параметры COM-порта? > > Ecть следующий код для оффтопика, необходимо написать его аналог: > > #ifdef __WIN32__ > handle = CreateFile(port.c_str(), GENERIC_READ|GENERIC_WRITE, 0, > NULL, OPEN_EXISTING, 0, NULL); > > if (handle == INVALID_HANDLE_VALUE) > throw runtime_error("serial device "+port+" open error"); > > DCB dcb; > ZeroMemory(&dcb, sizeof(DCB)); > if (!GetCommState(handle, &dcb)) > throw runtime_error("serial device "+port+" get state error"); > > dcb.DCBlength=sizeof(DCB); > BuildCommDCB(params.c_str(), &dcb); > > dcb.BaudRate = 600; > dcb.ByteSize = 8; > dcb.Parity = NOPARITY; > dcb.StopBits = TWOSTOPBITS; > > if (!SetCommState(handle, &dcb)) > throw runtime_error("serial device "+port+" set state error"); > > COMMTIMEOUTS ct; > ZeroMemory(&ct, sizeof(COMMTIMEOUTS)); > ct.ReadIntervalTimeout = MAXDWORD; > ct.ReadTotalTimeoutMultiplier = ct.ReadTotalTimeoutConstant = 0; > ct.WriteTotalTimeoutMultiplier = ct.WriteTotalTimeoutConstant = 0; > SetCommTimeouts(handle, &ct); > #endif http://linuxland.itam.nsc.ru/misch.html Ян > > -- > С уважением, Прокопьев Евгений > > _______________________________________________ > Community mailing list > Community@altlinux.ru > http://www.altlinux.ru/mailman/listinfo/community > ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2003-01-16 13:49 UTC | newest] Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2003-01-16 12:40 [Comm] Программирование для COM-порта Прокопьев Евгений 2003-01-16 13:05 ` Sergey Vlasov 2003-01-16 13:49 ` [Comm] " Бессонов Ян
ALT Linux Community general discussions This inbox may be cloned and mirrored by anyone: git clone --mirror http://lore.altlinux.org/community/0 community/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 community community/ http://lore.altlinux.org/community \ mandrake-russian@linuxteam.iplabs.ru community@lists.altlinux.org community@lists.altlinux.ru community@lists.altlinux.com public-inbox-index community Example config snippet for mirrors. Newsgroup available over NNTP: nntp://lore.altlinux.org/org.altlinux.lists.community AGPL code for this site: git clone https://public-inbox.org/public-inbox.git