<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[serielle Schnittstelle]]></title><description><![CDATA[<p>Hallo,<br />
ich habe in der FAQ nen Beitrag zum ansprechen einer seriellen Schnittstelle gefunden. Die ersten Schritte damit sind auch recht einfach. Ich habe es schließlich auch geschaft, dass das Gerät was dort dranhängt das macht, was ich will nur die Daten die ich zurückbekomme hauen irgendwie nicht so ganz hin. Irgendwie kommt bei RS232.Receive(txt,8); nur Müll zurück. Das ganze ist übrigens in einen Dialog eingebunden.</p>
<pre><code class="language-cpp">void CVersuchSerielleSchnittstelleDlg::OnBnClickedButton4()
{
	// TODO: Fügen Sie hier Ihren Kontrollbehandlungscode für die 

	CSERIELL RS232;
	bool hallo = RS232.Init(1,9600,8,0,0,2,100,1000);
	char *txt = new char[24];
	txt[0]=2;
	txt[1]='A';
	txt[2]=0;
	txt[3]=0;
	txt[4]=0;
	txt[5]=0;
	txt[6]=0;
	txt[7]=3;
	RS232.Send(txt,8);
	RS232.Receive(txt,8);
	RS232.Close();
	delete[] txt;
}

int CSERIELL::Receive(void *puffer, int len)
{
    DWORD receive=0;
    if(m_hPort !=0 &amp;&amp; len &gt;0)
    {
        ReadFile(m_hPort, puffer, len, &amp;receive, NULL);
    }
    if(receive==0)

    return receive;
}

//schließt die serielle Schnittstelle
bool CSERIELL::Close()
{
    if(isOpen())
    {
        CloseHandle(this-&gt;m_hPort);
        this-&gt;m_hPort= 0;    
        return true;
    }
    return false;
}

//Ist serielle Schnittstelle offen
bool CSERIELL::isOpen()
{
    if(m_hPort &gt;0)
        return true;
//  this-&gt;m_error= ERROR_port_init;
    return false;
}

char* CSERIELL::Geterror()
{
    return m_error;
}

bool CSERIELL::Init(int iPort, int iBaud, int iSize, int iParity, int stopbit, int fRtsControl, int iTimeout, int iTotalTimeout)
{
    char port[]= &quot;COM0123456789&quot;;        
	sprintf(port, &quot;COM%i:&quot;, iPort);

    m_hPort = CreateFile(   port,
        GENERIC_READ | GENERIC_WRITE,
        0,
        NULL,
        OPEN_EXISTING,
        FILE_ATTRIBUTE_NORMAL,
        NULL);
    if((int)this-&gt;m_hPort == -1)         //COMx ist nicht vorhanden
            this-&gt;m_hPort=0;
    if(this-&gt;m_hPort !=0)                    
    {
        COMMTIMEOUTS comtime;  
        GetCommTimeouts(this-&gt;m_hPort, &amp;comtime);
        comtime.ReadIntervalTimeout= iTimeout;
        comtime.ReadTotalTimeoutConstant= iTotalTimeout;
        comtime.WriteTotalTimeoutConstant= iTotalTimeout;
        comtime.ReadTotalTimeoutMultiplier=2;
        comtime.WriteTotalTimeoutMultiplier=0;
        SetCommTimeouts(this-&gt;m_hPort, &amp;comtime);

        DCB dcb;           //Gerätekommunikationsanpassung
        GetCommState(this-&gt;m_hPort, &amp;dcb);
        dcb.BaudRate= iBaud;
        dcb.ByteSize= iSize;
        dcb.DCBlength= 28;
        dcb.EofChar= 0;
        dcb.ErrorChar= 0;
        dcb.fRtsControl= fRtsControl;
        dcb.Parity= iParity;
        dcb.StopBits= stopbit;
        dcb.fInX=0;
        dcb.fOutX=0;
        dcb.fAbortOnError = 1;  //Bitte hier die leerzeichen
                // wegmachen. Vermutlich Bug im Forum
    SetCommState(this-&gt;m_hPort, &amp;dcb);
    return true;
    }

    return false;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/70295/serielle-schnittstelle</link><generator>RSS for Node</generator><lastBuildDate>Wed, 29 Apr 2026 03:49:45 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/70295.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 06 Apr 2004 11:05:23 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to serielle Schnittstelle on Tue, 06 Apr 2004 11:05:23 GMT]]></title><description><![CDATA[<p>Hallo,<br />
ich habe in der FAQ nen Beitrag zum ansprechen einer seriellen Schnittstelle gefunden. Die ersten Schritte damit sind auch recht einfach. Ich habe es schließlich auch geschaft, dass das Gerät was dort dranhängt das macht, was ich will nur die Daten die ich zurückbekomme hauen irgendwie nicht so ganz hin. Irgendwie kommt bei RS232.Receive(txt,8); nur Müll zurück. Das ganze ist übrigens in einen Dialog eingebunden.</p>
<pre><code class="language-cpp">void CVersuchSerielleSchnittstelleDlg::OnBnClickedButton4()
{
	// TODO: Fügen Sie hier Ihren Kontrollbehandlungscode für die 

	CSERIELL RS232;
	bool hallo = RS232.Init(1,9600,8,0,0,2,100,1000);
	char *txt = new char[24];
	txt[0]=2;
	txt[1]='A';
	txt[2]=0;
	txt[3]=0;
	txt[4]=0;
	txt[5]=0;
	txt[6]=0;
	txt[7]=3;
	RS232.Send(txt,8);
	RS232.Receive(txt,8);
	RS232.Close();
	delete[] txt;
}

int CSERIELL::Receive(void *puffer, int len)
{
    DWORD receive=0;
    if(m_hPort !=0 &amp;&amp; len &gt;0)
    {
        ReadFile(m_hPort, puffer, len, &amp;receive, NULL);
    }
    if(receive==0)

    return receive;
}

//schließt die serielle Schnittstelle
bool CSERIELL::Close()
{
    if(isOpen())
    {
        CloseHandle(this-&gt;m_hPort);
        this-&gt;m_hPort= 0;    
        return true;
    }
    return false;
}

//Ist serielle Schnittstelle offen
bool CSERIELL::isOpen()
{
    if(m_hPort &gt;0)
        return true;
//  this-&gt;m_error= ERROR_port_init;
    return false;
}

char* CSERIELL::Geterror()
{
    return m_error;
}

bool CSERIELL::Init(int iPort, int iBaud, int iSize, int iParity, int stopbit, int fRtsControl, int iTimeout, int iTotalTimeout)
{
    char port[]= &quot;COM0123456789&quot;;        
	sprintf(port, &quot;COM%i:&quot;, iPort);

    m_hPort = CreateFile(   port,
        GENERIC_READ | GENERIC_WRITE,
        0,
        NULL,
        OPEN_EXISTING,
        FILE_ATTRIBUTE_NORMAL,
        NULL);
    if((int)this-&gt;m_hPort == -1)         //COMx ist nicht vorhanden
            this-&gt;m_hPort=0;
    if(this-&gt;m_hPort !=0)                    
    {
        COMMTIMEOUTS comtime;  
        GetCommTimeouts(this-&gt;m_hPort, &amp;comtime);
        comtime.ReadIntervalTimeout= iTimeout;
        comtime.ReadTotalTimeoutConstant= iTotalTimeout;
        comtime.WriteTotalTimeoutConstant= iTotalTimeout;
        comtime.ReadTotalTimeoutMultiplier=2;
        comtime.WriteTotalTimeoutMultiplier=0;
        SetCommTimeouts(this-&gt;m_hPort, &amp;comtime);

        DCB dcb;           //Gerätekommunikationsanpassung
        GetCommState(this-&gt;m_hPort, &amp;dcb);
        dcb.BaudRate= iBaud;
        dcb.ByteSize= iSize;
        dcb.DCBlength= 28;
        dcb.EofChar= 0;
        dcb.ErrorChar= 0;
        dcb.fRtsControl= fRtsControl;
        dcb.Parity= iParity;
        dcb.StopBits= stopbit;
        dcb.fInX=0;
        dcb.fOutX=0;
        dcb.fAbortOnError = 1;  //Bitte hier die leerzeichen
                // wegmachen. Vermutlich Bug im Forum
    SetCommState(this-&gt;m_hPort, &amp;dcb);
    return true;
    }

    return false;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/496156</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/496156</guid><dc:creator><![CDATA[seriel]]></dc:creator><pubDate>Tue, 06 Apr 2004 11:05:23 GMT</pubDate></item><item><title><![CDATA[Reply to serielle Schnittstelle on Tue, 06 Apr 2004 13:39:35 GMT]]></title><description><![CDATA[<p>ich habe ein bissschen weiter geschaut und die Schnittstelle scheint zwar zu funktionieren allerdings aber mit einem Portviewprogramm bekomme ich folgende Meldung. Vielleicht kann mir einer von Euch weiterhelfen, was das ganze heißt.</p>
<p>IOCTL_SERIAL_WAIT_ON_MASK INVALID PARAMETER</p>
]]></description><link>https://www.c-plusplus.net/forum/post/496277</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/496277</guid><dc:creator><![CDATA[seriel]]></dc:creator><pubDate>Tue, 06 Apr 2004 13:39:35 GMT</pubDate></item><item><title><![CDATA[Reply to serielle Schnittstelle on Fri, 09 Apr 2004 01:39:12 GMT]]></title><description><![CDATA[<p>eventuell kriegst du beim umschalten deiner peripherie von empfang auf senden etwas datenmüll ab. vielleicht hilft dir auch das hyperterminal beim debuggen</p>
]]></description><link>https://www.c-plusplus.net/forum/post/498021</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/498021</guid><dc:creator><![CDATA[Floh]]></dc:creator><pubDate>Fri, 09 Apr 2004 01:39:12 GMT</pubDate></item></channel></rss>