COM-Port Daten auslesen



  • Hallo,

    habe hier folgendes Problem: ich bekomme Daten über den COM-Port gesendet (bzw
    eigentlich über USB, mit dem TTDI-Chip FT245, aber der Treiber simuliert einen
    COM-Port sehr hoher Geschwindigkeit). Das Ganze klappt unter DOS prima mit
    dem Programm "serialterm". Es kommen alle Zeichen vor, also alles von 0x00 bis 0xff.

    Auf der GUI mache ich folgendes:

    VARIANT in_dat;
    char cBuf[1024];
    unsigned int len;
    
    im Init:
    [code]
    // COM Port Initialization
    	m_COMControl.SetCommPort(3);	// com3
    	m_COMControl.SetSettings("115200,N,8,1");											// 19200 bits/s, no parity, 8 data bits, 1 stop bit
    	m_COMControl.SetInputLen(100);
    	m_COMControl.SetInputMode(0);
    	m_COMControl.SetDTREnable(FALSE);
    	m_COMControl.SetRTSEnable(FALSE);
    	m_COMControl.SetEOFEnable(FALSE);
    	m_COMControl.SetRThreshold(20);		// only wake me when > 20 chars have arrived
    	m_COMControl.SetSThreshold(0);
    	m_COMControl.SetPortOpen(TRUE);
    
    switch(m_COMControl.GetCommEvent()) {
    case 2: /*
    	 * comEvReceive Event... this means we received a number of Rthreshold
    	 * characters. Event is generated continuously until data is fetched via
    	 * GetInput()
    	 */
    	in_dat = m_COMControl.GetInput();
    	// convert from Variant to String
    	m_COMPortString = in_dat.bstrVal;
    	len = m_COMPortString.GetLength();
    	memcpy(cBuf, m_COMPortString, len);
    	analyzeData(cBuf, len);
    	break;
    .....
    }
    

    Das Problem:



  • Echt top posting 👍 ! Aber was willst du jetzt von uns? 😉

    MarcGast schrieb:

    Das Problem:

    🙄



  • das problem wird hier beschrieben 😉

    http://www.c-plusplus.net/forum/viewtopic.php?t=98577


Anmelden zum Antworten