Click here to Skip to main content
15,926,596 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: What the! Pin
Alexandru Savescu11-Jun-02 20:47
Alexandru Savescu11-Jun-02 20:47 
GeneralRe: What the! Pin
wilche12-Jun-02 13:16
wilche12-Jun-02 13:16 
GeneralRe: What the! Pin
Mike Nordell13-Jun-02 4:39
Mike Nordell13-Jun-02 4:39 
GeneralRe: What the! Pin
Tim Smith13-Jun-02 4:45
Tim Smith13-Jun-02 4:45 
GeneralWM_NCPAINT not being called by RedrawWindow Pin
Roman Nurik11-Jun-02 18:24
Roman Nurik11-Jun-02 18:24 
GeneralSerial port stripping characters. Pin
clintsinger11-Jun-02 17:32
clintsinger11-Jun-02 17:32 
GeneralRe: Serial port stripping characters. Pin
Tim Smith12-Jun-02 1:51
Tim Smith12-Jun-02 1:51 
GeneralRe: Serial port stripping characters. Pin
Roger Allen12-Jun-02 2:01
Roger Allen12-Jun-02 2:01 
This is code I developed a long time ago to open a COM port for that kind of use. I hope its of use

// WINDOWS NT
// we must pass a security_attributes structure to the on-create call to
// all the created threads to access the serial port!
SECURITY_ATTRIBUTES sa ;
sa.nLength = sizeof(SECURITY_ATTRIBUTES) ;
sa.lpSecurityDescriptor = NULL ;        // use default descriptor
sa.bInheritHandle = true ;              // allow sub-threads to inherit handle

m_hSerialPort = CreateFile((LPCTSTR)m_csCommPortName,
                    GENERIC_READ | GENERIC_WRITE,
                    0,
                    &sa,                            // needed for inherit
                    OPEN_EXISTING,
                    0,
                    0) ;
if (m_hSerialPort != INVALID_HANDLE_VALUE)
    {
    m_bOpen = true ;
    if (!GetCommState(m_hSerialPort, &m_dcb))
        {
        error.LoadString(IDS_CAVRO_DCB) ;
        DisplayText(error) ;
        }
    else
        {
        // make sure we are using the correct settings
        m_dcb.BaudRate = CBR_9600 ;                 // 9600 baud
        m_dcb.ByteSize = 8 ;                        // 8 data bits
        m_dcb.Parity = NOPARITY ;                   // no parity
        m_dcb.fParity = false ;                     // parity checking off
        m_dcb.StopBits = ONESTOPBIT ;               // 1 stop bit
        m_dcb.fDtrControl = DTR_CONTROL_DISABLE ;   // no DTR input flow control
        m_dcb.fOutxCtsFlow = false ;                // don't monitor CTS
        m_dcb.fDsrSensitivity = false ;             // always read bytes received
        m_dcb.fTXContinueOnXoff = true ;            // don't wait for XONN / XOFF
        m_dcb.fOutX = false ;                       // No XON / XOFF control
        m_dcb.fRtsControl = RTS_CONTROL_DISABLE ;   // don't use RTS comms control
        m_dcb.fAbortOnError = false ;               // don't quit on error
        // now apply the correct comm state to the device
        if (!SetCommState(m_hSerialPort, &m_dcb))
            {
            error.LoadString(IDS_CAVRO_STATE) ;
            DisplayText(error) ;
            }
        // set the communication event flags
        if (!SetCommMask(m_hSerialPort, EV_RXCHAR))
            {
            error.LoadString(IDS_CAVRO_MASK) ;
            DisplayText(error) ;
            }
        COMMTIMEOUTS    timeouts ;

        // return immediately on reads
        // return after completion on writes
        timeouts.ReadIntervalTimeout = MAXDWORD ;
        timeouts.ReadTotalTimeoutConstant = 0 ;
        timeouts.ReadTotalTimeoutMultiplier = 0 ;
        timeouts.WriteTotalTimeoutConstant = 0 ;
        timeouts.WriteTotalTimeoutMultiplier = 0 ;

        SetCommTimeouts(m_hSerialPort, &timeouts) ;
        }
    }



Roger Allen
Sonork 100.10016

If I had a quote, it would be a very good one.
GeneralODBC Pin
11-Jun-02 16:31
suss11-Jun-02 16:31 
GeneralRe: ODBC Pin
Nish Nishant11-Jun-02 17:29
sitebuilderNish Nishant11-Jun-02 17:29 
GeneralRe: ODBC Pin
11-Jun-02 18:35
suss11-Jun-02 18:35 
Generalarticles about monikers Pin
Chen Jiadong11-Jun-02 16:20
Chen Jiadong11-Jun-02 16:20 
GeneralRe: articles about monikers Pin
Rama Krishna Vavilala11-Jun-02 18:41
Rama Krishna Vavilala11-Jun-02 18:41 
GeneralVersion of msado15.dll and VStudio service packs Pin
Rostrox11-Jun-02 15:45
Rostrox11-Jun-02 15:45 
GeneralRe: Version of msado15.dll and VStudio service packs Pin
Rama Krishna Vavilala11-Jun-02 17:18
Rama Krishna Vavilala11-Jun-02 17:18 
GeneralCopy TreeView Branch - Not to another but clipboard Pin
Paul Belikian11-Jun-02 15:49
Paul Belikian11-Jun-02 15:49 
GeneralRe: Copy TreeView Branch - Not to another but clipboard Pin
benjymous12-Jun-02 2:39
benjymous12-Jun-02 2:39 
GeneralRe: Copy TreeView Branch - Not to another but clipboard Pin
Paul Belikian12-Jun-02 16:13
Paul Belikian12-Jun-02 16:13 
GeneralRe: Copy TreeView Branch - Not to another but clipboard Pin
benjymous13-Jun-02 9:39
benjymous13-Jun-02 9:39 
GeneralRe: Copy TreeView Branch - Not to another but clipboard Pin
Paul Belikian13-Jun-02 17:58
Paul Belikian13-Jun-02 17:58 
GeneralRe: Copy TreeView Branch - Not to another but clipboard Pin
benjymous13-Jun-02 21:43
benjymous13-Jun-02 21:43 
GeneralShutdown message Pin
Steve L.11-Jun-02 13:58
Steve L.11-Jun-02 13:58 
GeneralRe: Shutdown message Pin
Christian Graus11-Jun-02 14:27
protectorChristian Graus11-Jun-02 14:27 
GeneralRe: Shutdown message Pin
Steve L.11-Jun-02 14:34
Steve L.11-Jun-02 14:34 
GeneralRe: Shutdown message Pin
Nish Nishant11-Jun-02 14:58
sitebuilderNish Nishant11-Jun-02 14:58 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.