PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : K8055D USB Intercace



raphaelf
08.01.2006, 20:54
Hallo Zusammen,

OS:Windows xp Professional
Compiler: Visual Studio .Net

Ich habe mir ein K8055D USB Intercace geholht (http://www.conrad.de/script/usb_experiment_interface.sap)und habe probiert über die Funktion OpenDevice mich zu verbinden.
Ich habe aber nicht geschaft.
Im Projekt verzeichniss liegt das DLL k8055D.dll. Ich weiss nicht was ich noch vergessen habe. Ich wäre für eine Hilfe sehr dankbar

Hier meine Fehlermeldung:
mainwindow.obj : error LNK2019: Nicht aufgelöstes externes Symbol '__imp__OpenD
vice@4', verwiesen in Funktion '"public: virtual void __thiscall MainWindow::in
tDevice(void)" (?initDevice@MainWindow@@UAEXXZ)'
tutorial1.exe : fatal error LNK1120: 1 unaufgelöste externe Verweise
NMAKE : fatal error U1077: 'link': Rückgabe-Code '0x460'
Stop.

*******************************************

hier der code:
//k8055d.h

#ifdef __cplusplus
extern "C" {
#endif

#define FUNCTION __declspec(dllimport)

FUNCTION long __stdcall OpenDevice(long CardAddress);
FUNCTION __stdcall CloseDevice();
FUNCTION long __stdcall ReadAnalogChannel(long Channel);
FUNCTION __stdcall ReadAllAnalog(long *Data1, long *Data2);
FUNCTION __stdcall OutputAnalogChannel(long Channel, long Data);
FUNCTION __stdcall OutputAllAnalog(long Data1, long Data2);
FUNCTION __stdcall ClearAnalogChannel(long Channel);
FUNCTION __stdcall ClearAllAnalog();
FUNCTION __stdcall SetAnalogChannel(long Channel);
FUNCTION __stdcall SetAllAnalog();
FUNCTION __stdcall WriteAllDigital(long Data);
FUNCTION __stdcall ClearDigitalChannel(long Channel);
FUNCTION __stdcall ClearAllDigital();
FUNCTION __stdcall SetDigitalChannel(long Channel);
FUNCTION __stdcall SetAllDigital();
FUNCTION bool __stdcall ReadDigitalChannel(long Channel);
FUNCTION long __stdcall ReadAllDigital();
FUNCTION long __stdcall ReadCounter(long CounterNr);
FUNCTION __stdcall ResetCounter(long CounterNr);
FUNCTION __stdcall SetCounterDebounceTime(long CounterNr, long DebounceTime);

#ifdef __cplusplus
}
#endif



*************************************
//main.cpp
#include <qapplication.h>
#include "mainwindow.h"

int main( int argc, char ** argv )
{
QApplication a( argc, argv );
MainWindow w;
w.show();
a.connect( &a, SIGNAL( lastWindowClosed() ), &a, SLOT( quit() ) );
return a.exec();
}


//mainwindow.cpp
/************************************************** **************************
** Form implementation generated from reading ui file 'mainwindow.ui'
**
** Created: So 8. Jan 20:05:54 2006
** by: The User Interface Compiler ()
**
** WARNING! All changes made in this file will be lost!
************************************************** **************************/

#include "mainwindow.h"
#include "K8055D.h"

#include <qvariant.h>
#include <qpushbutton.h>
#include <qlayout.h>
#include <qtooltip.h>
#include <qwhatsthis.h>
#include <qimage.h>
#include <qpixmap.h>




/*
* Constructs a MainWindow as a child of 'parent', with the
* name 'name' and widget flags set to 'f'.
*
* The dialog will by default be modeless, unless you set 'modal' to
* TRUE to construct a modal dialog.
*/
MainWindow::MainWindow( QWidget* parent, const char* name, bool modal, WFlags fl )
: QDialog( parent, name, modal, fl )
{
if ( !name )
setName( "MainWindow" );

pb1 = new QPushButton( this, "pb1" );
pb1->setGeometry( QRect( 50, 30, 82, 26 ) );
languageChange();
resize( QSize(187, 79).expandedTo(minimumSizeHint()) );
clearWState( WState_Polished );

// signals and slots connections
connect( pb1, SIGNAL( clicked() ), this, SLOT( initDevice() ) );
}

/*
* Destroys the object and frees any allocated resources
*/
MainWindow::~MainWindow()
{
// no need to delete child widgets, Qt does it all for us
}

/*
* Sets the strings of the subwidgets using the current
* language.
*/
void MainWindow::languageChange()
{
setCaption( tr( "Tutorial1" ) );
pb1->setText( tr( "init" ) );
}



void MainWindow::initDevice()
{
//funktioniert nicht, warum?
int CardAddr = 0; //sk5 und sk6 gejumpt = 0 siehe tabelle 1 von seite 1
int h = OpenDevice(CardAddr);
switch (h) {
case 0 :
pb1->setText( tr( "connected" ) );
break;
case 1 :
case 2 :
case 3 :

case -1 :
pb1->setText( tr( "not connected" ) );
}

}




//mainwindow.h
/************************************************** **************************
** Form interface generated from reading ui file 'mainwindow.ui'
**
** Created: So 8. Jan 20:05:54 2006
** by: The User Interface Compiler ()
**
** WARNING! All changes made in this file will be lost!
************************************************** **************************/

#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <qvariant.h>
#include <qdialog.h>

class QVBoxLayout;
class QHBoxLayout;
class QGridLayout;
class QSpacerItem;
class QPushButton;


class MainWindow : public QDialog
{
Q_OBJECT

public:
MainWindow( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 );
~MainWindow();

QPushButton* pb1;

public slots:
virtual void initDevice();


protected:

protected slots:
virtual void languageChange();

};

#endif // MAINWINDOW_H