ALT Linux Community general discussions
 help / color / mirror / Atom feed
From: "Бессонов Ян" <yashka@mailru.com>
To: <community@altlinux.ru>
Subject: [Comm] Re: [Comm] Программирование для COM-порта
Date: Thu, 16 Jan 2003 16:49:32 +0300
Message-ID: <000d01c2bd66$19a2aac0$056409c0@LocalHost> (raw)
In-Reply-To: <3E26A82B.2020608@rmts.donpac.ru>

----- 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
>



      parent reply	other threads:[~2003-01-16 13:49 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-01-16 12:40 Прокопьев Евгений
2003-01-16 13:05 ` Sergey Vlasov
2003-01-16 13:49 ` Бессонов Ян [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='000d01c2bd66$19a2aac0$056409c0@LocalHost' \
    --to=yashka@mailru.com \
    --cc=community@altlinux.ru \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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