<?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[COM(X) öffnen klappt nur nach HyperTerminal]]></title><description><![CDATA[<p>Hallo<br />
Also wenn ich den PC neu starte, kann ich zwar senden(WriteFile) aber ich empfange nichts (ReadFile dwRead==0).<br />
Wenn ich das HyperTerminal starte und den jeweileigen COM port öffne und wieder schliesse funkts .</p>
<pre><code class="language-cpp">static	OVERLAPPED o;	
static	COMMTIMEOUTS ctmo;
static 	DWORD dwEvtMask=EV_ERR|EV_RXCHAR;
static	DCB dcb;

wsprintf(scPort,&quot;\\\\.\\COM%s&quot;,cPort );

 	hCom = CreateFile (scPort, GENERIC_READ | GENERIC_WRITE, 0, 
                           NULL, OPEN_EXISTING,|0, NULL); 
		rserror=GetLastError();
                 //...............
                ZeroMemory(&amp;dcb, sizeof(dcb)); 
		dcb.DCBlength = sizeof(DCB);  
  		GetCommState (hCom, &amp;dcb); 

		dcb.wReserved  = 0; 
		dcb.BaudRate  = CBR_19200;         
		dcb.ByteSize  = 8;  
  		dcb.Parity    = NOPARITY;     
   		dcb.StopBits  = ONESTOPBIT;   
   		dcb.fBinary = TRUE;

		if (!SetCommState(hCom, &amp;dcb))
                //.................Fehler-&gt;
                //bei else gehts weiter
                if (!SetCommMask (hCom, dwEvtMask))
                //.................Fehler-&gt;
                //bei else gehts weiter
		memset (&amp;o, 0, sizeof (OVERLAPPED));  
  		o.hEvent = CreateEvent (NULL, FALSE, FALSE, NULL);

	GetCommTimeouts (hCom, &amp;ctmo); 
  	ctmo.ReadIntervalTimeout         = 1000 / 19200 * (dcb.ByteSize +
 (dcb.Parity == NOPARITY ? 0 : 1) + (dcb.StopBits == ONESTOPBIT ? 1 : 2)) * 2; 
  	ctmo.ReadTotalTimeoutMultiplier  = 1;  
  	ctmo.ReadTotalTimeoutConstant    = 10;  
  	ctmo.WriteTotalTimeoutMultiplier = 0; 
  	ctmo.WriteTotalTimeoutConstant   = 0; 
  	SetCommTimeouts (hCom, &amp;ctmo); 

  SetupComm (hCom, COM_BUFFER_SIZE, COM_BUFFER_SIZE);
                  //WriteFile(.......
if (!WriteFile (hCom, &amp;HEX_LOGIN, sizeof(HEX_LOGIN), &amp;iBytesWritten, &amp;o))
		{

			if (rserror!=ERROR_IO_PENDING)
				{
			rs232_error(rserror,&quot;Fehler beim Einloggen&quot;);
				}

		}
		else
		{

    if (WAIT_OBJECT_0 == WaitForSingleObject (o.hEvent, 2000))   
    { 
      if (dwEvtMask &amp; EV_RXCHAR)  
      { 

		bRet=ReadFile (hCom, &amp;wpString, sizeof(wpString), &amp;dwRead, &amp;o);
</code></pre>
<p>bRet liefer TRUE aber dwRead = 0 !!?<br />
Vielleicht kann mir jemand helfen. Danke im voraus.<br />
Max</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/230942/com-x-öffnen-klappt-nur-nach-hyperterminal</link><generator>RSS for Node</generator><lastBuildDate>Thu, 09 Apr 2026 19:01:30 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/230942.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 04 Jan 2009 14:08:46 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to COM(X) öffnen klappt nur nach HyperTerminal on Sun, 04 Jan 2009 14:08:46 GMT]]></title><description><![CDATA[<p>Hallo<br />
Also wenn ich den PC neu starte, kann ich zwar senden(WriteFile) aber ich empfange nichts (ReadFile dwRead==0).<br />
Wenn ich das HyperTerminal starte und den jeweileigen COM port öffne und wieder schliesse funkts .</p>
<pre><code class="language-cpp">static	OVERLAPPED o;	
static	COMMTIMEOUTS ctmo;
static 	DWORD dwEvtMask=EV_ERR|EV_RXCHAR;
static	DCB dcb;

wsprintf(scPort,&quot;\\\\.\\COM%s&quot;,cPort );

 	hCom = CreateFile (scPort, GENERIC_READ | GENERIC_WRITE, 0, 
                           NULL, OPEN_EXISTING,|0, NULL); 
		rserror=GetLastError();
                 //...............
                ZeroMemory(&amp;dcb, sizeof(dcb)); 
		dcb.DCBlength = sizeof(DCB);  
  		GetCommState (hCom, &amp;dcb); 

		dcb.wReserved  = 0; 
		dcb.BaudRate  = CBR_19200;         
		dcb.ByteSize  = 8;  
  		dcb.Parity    = NOPARITY;     
   		dcb.StopBits  = ONESTOPBIT;   
   		dcb.fBinary = TRUE;

		if (!SetCommState(hCom, &amp;dcb))
                //.................Fehler-&gt;
                //bei else gehts weiter
                if (!SetCommMask (hCom, dwEvtMask))
                //.................Fehler-&gt;
                //bei else gehts weiter
		memset (&amp;o, 0, sizeof (OVERLAPPED));  
  		o.hEvent = CreateEvent (NULL, FALSE, FALSE, NULL);

	GetCommTimeouts (hCom, &amp;ctmo); 
  	ctmo.ReadIntervalTimeout         = 1000 / 19200 * (dcb.ByteSize +
 (dcb.Parity == NOPARITY ? 0 : 1) + (dcb.StopBits == ONESTOPBIT ? 1 : 2)) * 2; 
  	ctmo.ReadTotalTimeoutMultiplier  = 1;  
  	ctmo.ReadTotalTimeoutConstant    = 10;  
  	ctmo.WriteTotalTimeoutMultiplier = 0; 
  	ctmo.WriteTotalTimeoutConstant   = 0; 
  	SetCommTimeouts (hCom, &amp;ctmo); 

  SetupComm (hCom, COM_BUFFER_SIZE, COM_BUFFER_SIZE);
                  //WriteFile(.......
if (!WriteFile (hCom, &amp;HEX_LOGIN, sizeof(HEX_LOGIN), &amp;iBytesWritten, &amp;o))
		{

			if (rserror!=ERROR_IO_PENDING)
				{
			rs232_error(rserror,&quot;Fehler beim Einloggen&quot;);
				}

		}
		else
		{

    if (WAIT_OBJECT_0 == WaitForSingleObject (o.hEvent, 2000))   
    { 
      if (dwEvtMask &amp; EV_RXCHAR)  
      { 

		bRet=ReadFile (hCom, &amp;wpString, sizeof(wpString), &amp;dwRead, &amp;o);
</code></pre>
<p>bRet liefer TRUE aber dwRead = 0 !!?<br />
Vielleicht kann mir jemand helfen. Danke im voraus.<br />
Max</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1639248</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1639248</guid><dc:creator><![CDATA[_Maxx175]]></dc:creator><pubDate>Sun, 04 Jan 2009 14:08:46 GMT</pubDate></item><item><title><![CDATA[Reply to COM(X) öffnen klappt nur nach HyperTerminal on Mon, 05 Jan 2009 21:48:43 GMT]]></title><description><![CDATA[<p>Nachdem du die Schnittstelle aufgemacht hast...:</p>
<ol>
<li>Lass das GetCommState weg und setze stattdessen alle Member der Struktur genau so wie du sie brauchst</li>
<li>Dasselbe gilt für GetCommTimeouts</li>
<li>rufe ClearCommBreak auf</li>
<li>rufe ClearCommError auf</li>
</ol>
<p>3 und 4 sind möglicherweise nicht nötig, schaden aber auf keinen Fall.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1640138</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1640138</guid><dc:creator><![CDATA[hustbaer]]></dc:creator><pubDate>Mon, 05 Jan 2009 21:48:43 GMT</pubDate></item></channel></rss>