🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #12749

Re: WriteFile(to COM1)

#12749
From: Remy Lebeau (TeamB)
Date: Thu, 20 Nov 2003 01:59
29 lines
1773 bytes
"Nicholas Gessler" <gessler@ucla.edu> wrote in message
news:3fbc160d$1@newsgroups.borland.com...

> Could someone please provide me with a few simple sample lines of
> code?  All I want to do is write and read 2-3 ASCII bytes at a time.

(untested)

    HANDLE hComm = CreateFile("COM1", GENERIC_READ | GENERIC_WRITE, 0, NULL,
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);

    if( hComm != INVALID_HANDLE_VALUE )
    {
        // call Get/SetCommState() to set the port settings
        // call Get/SetCommTimeouts() to set the port timeouts

        PurgeComm(hComm, PURGE_RXCLEAR);  // Clear Input Buffer.
        PurgeComm(hComm, PURGE_TXCLEAR);  // Clear Output Buffer.
        EscapeCommFunction(hComm, SETRTS);    // Request to Send

        DWORD dwWritten = 0;
        WriteFile(hComm, "w01", 3, &dwWritten, NULL);

        CloseHandle(hComm);
    }


Gambit
Technical Details
Message-ID: <3fbc1f3c@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <3fbc160d$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,bcf3c83168a0fa3a
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2003-11-19 18:09:58 PST
From: "Remy Lebeau \(TeamB\)" <gambit47.no.spam@no.spam.yahoo.com>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <3fbc160d$1@newsgroups.borland.com>
Subject: Re: WriteFile(to COM1)
Date: Wed, 19 Nov 2003 17:59:58 -0800
Lines: 31
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
NNTP-Posting-Host: 67.22.137.149
Message-ID: <3fbc1f3c@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1069293372 67.22.137.149 (19 Nov 2003 17:56:12 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail