<?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[Problem mit Daten vom Parallelport]]></title><description><![CDATA[<p>Hallo!</p>
<p>Weil ich vorhabe ein kleines PC-Link Programm zu schreiben, das den Parallelport nutzt, habe ich ein wenig gegoogelt und die inpout32.dll (<a href="http://www.logix4u.net/inpout32.htm" rel="nofollow">http://www.logix4u.net/inpout32.htm</a>)gefunden. Wenn ich aber mein Testprogramm starte, wird mir immer ein bestimmter Wert ausgegeben, obwohl nichts an dem Port angeschlossen ist. Hier der wohl entscheidende Programmteil:</p>
<pre><code class="language-cpp">short port::Inp32(short i)
{
  return (inp32fp)(i); //die unveränderte Funktion aus der DLL
}

int port::read_all()
{
  data=0;
  for (address=pportBase; (address&lt;(pportBase+8)); address++)//pportBase = 0x378 
    data+=Inp32(address);
  return data;
}
</code></pre>
<p>Mir fällt da kein großer Fehler auf. Im Hauptprogramm wird dann nur read_all() in einer Schleife ausgeführt und der Wert - auf meinem XP-Rechner 1851, auf dem Win 98-Notebook 1853 - ausgegeben.</p>
<p>Weil ich nicht weiß, ob das normal ist, oder ob ich sonstige Verständnisprobleme habe, habe ich jetzt nicht den ganzen Quelltext eingefügt. Wenn es aber nötig sein sollte, werde ich es natürlich nachholen.</p>
<p>Kann und will mir jemand helfen?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/152994/problem-mit-daten-vom-parallelport</link><generator>RSS for Node</generator><lastBuildDate>Sat, 11 Jul 2026 16:58:49 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/152994.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 11 Jul 2006 20:27:27 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Problem mit Daten vom Parallelport on Tue, 11 Jul 2006 20:27:27 GMT]]></title><description><![CDATA[<p>Hallo!</p>
<p>Weil ich vorhabe ein kleines PC-Link Programm zu schreiben, das den Parallelport nutzt, habe ich ein wenig gegoogelt und die inpout32.dll (<a href="http://www.logix4u.net/inpout32.htm" rel="nofollow">http://www.logix4u.net/inpout32.htm</a>)gefunden. Wenn ich aber mein Testprogramm starte, wird mir immer ein bestimmter Wert ausgegeben, obwohl nichts an dem Port angeschlossen ist. Hier der wohl entscheidende Programmteil:</p>
<pre><code class="language-cpp">short port::Inp32(short i)
{
  return (inp32fp)(i); //die unveränderte Funktion aus der DLL
}

int port::read_all()
{
  data=0;
  for (address=pportBase; (address&lt;(pportBase+8)); address++)//pportBase = 0x378 
    data+=Inp32(address);
  return data;
}
</code></pre>
<p>Mir fällt da kein großer Fehler auf. Im Hauptprogramm wird dann nur read_all() in einer Schleife ausgeführt und der Wert - auf meinem XP-Rechner 1851, auf dem Win 98-Notebook 1853 - ausgegeben.</p>
<p>Weil ich nicht weiß, ob das normal ist, oder ob ich sonstige Verständnisprobleme habe, habe ich jetzt nicht den ganzen Quelltext eingefügt. Wenn es aber nötig sein sollte, werde ich es natürlich nachholen.</p>
<p>Kann und will mir jemand helfen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1096024</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1096024</guid><dc:creator><![CDATA[kynarion]]></dc:creator><pubDate>Tue, 11 Jul 2006 20:27:27 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit Daten vom Parallelport on Wed, 12 Jul 2006 13:22:33 GMT]]></title><description><![CDATA[<p>Hallo,<br />
hier ist der ganze Quelltext:</p>
<p>Header:</p>
<pre><code class="language-cpp">#ifndef PORT_HEADER
#define PORT_HEADER

#include &lt;conio.h&gt;
#include &lt;windows.h&gt;
#include &lt;iostream&gt;

using namespace std;

typedef short (_stdcall *inpfuncPtr)(short portaddr);
typedef void (_stdcall *oupfuncPtr)(short portaddr, short datum);

class port{

  private:
          short data;
          int address;
          int pportBase;
          inpfuncPtr inp32fp;
          oupfuncPtr oup32fp;
          HINSTANCE hLib;

          short Inp32(short i);
          void Out32(short i, short x);

  public:
          port(short portadress);
          ~port();
          int read(short portnr);
          int read_all();
          bool write(short data);
};

#endif
</code></pre>
<p>Implementation der Klasse:</p>
<pre><code class="language-cpp">#include &quot;port.hpp&quot;

port::port(short portaddress)
{
  pportBase=portaddress;

  inp32fp = NULL;
  oup32fp = NULL;

  hLib = LoadLibrary(&quot;inpout32.dll&quot;);
  if(hLib == NULL) {
    cerr&lt;&lt;&quot;Hard Error: Couldn't load library.&quot;&lt;&lt;endl;
    exit(1);
  }

  inp32fp = reinterpret_cast&lt;inpfuncPtr&gt;(GetProcAddress(hLib, &quot;Inp32&quot;));
  if(inp32fp == NULL) {
    cerr&lt;&lt;&quot;Hard Error: Couldn't get ProcAddress for Inp32.&quot;&lt;&lt;endl;
    exit(0);
  }

  oup32fp = reinterpret_cast&lt;oupfuncPtr&gt;(GetProcAddress(hLib, &quot;Out32&quot;));
  if(oup32fp == NULL) {
    cerr&lt;&lt;&quot;Hard Error: Couldn't get ProcAddress for Out32.&quot;&lt;&lt;endl;
    exit(0);
  }
}

short port::Inp32(short i)
{
  return (inp32fp)(i);
}

void port::Out32(short i, short x)
{
  (oup32fp)(i, x);
}

port::~port()
{
  FreeLibrary(hLib);
}

int port::read(short portnr)
{
  if(portnr&lt;0 || portnr&gt;7)
    return -1;

  data=Inp32(pportBase+portnr);
  return data;
}

int port::read_all()
{
  data=0;
  for (address=pportBase; (address&lt;(pportBase+8)); address++)
    data+=Inp32(address);
  return data;
}

bool port::write(short data)
{
  Out32(pportBase, data);
  if(data!=Inp32(pportBase))
    return false;
  return true;
}
</code></pre>
<p>main:</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;ctime&gt;
#include &quot;port.hpp&quot;

int main()
{
  port parallel(0x378);

  short message;
  time_t start, end;

  cout&lt;&lt;&quot;Starte Suche nach angeschlossenem PC&quot;&lt;&lt;endl;
  start = time(NULL);
  end = start + 10;

  while(time(NULL)&lt;end){
    message=parallel.read_all();
    cout&lt;&lt;&quot;Daten empfangen: &quot;&lt;&lt;message&lt;&lt;endl;
  }
}
</code></pre>
<p>Der Port sendet nach wie vor 1800 oder 1851. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /> Habe ich etwa die Hardware geschrottet?</p>
<p>Grüße,<br />
kynarion</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1096456</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1096456</guid><dc:creator><![CDATA[kynarion]]></dc:creator><pubDate>Wed, 12 Jul 2006 13:22:33 GMT</pubDate></item></channel></rss>