Ich habe das Problem bereits gelöst. Ich habe einfach nur vergessen die windows.h zu includen.
Ich bin neu in diesem Forum. Ich wollte mit Hilfe des IoWarriors und C++ eine kleine Automatisierung bauen. Dazu muss ich unter anderem die Temperatur messen. Leider gibt mir mein C++-Compiler lauter Fehlermeldungen in Verbindung mit der iowkit.h. Ich benutze Dev-C++ mit mingw32 um alles zu kompilieren. Anbei erstmal der Sourcecode des Testprogramms (ist leider noch recht unsauber, soll ja nur zum Testen sein):
#include <iostream>
#include "iowkit.h"
using namespace std;
double gettemp(IOWKIT_HANDLE iohandle)
{
char temp_high=0;
char temp_low=0;
double temp=0.0;
unsigned long ret;
IOWKIT_SPECIAL_REPORT report;
report.ReportID=2;
report.Bytes[0]=1;
report.Bytes[1]=0x4C;
report.Bytes[2]=0x01;
report.Bytes[3]=0;
report.Bytes[4]=0;
report.Bytes[5]=1;
report.Bytes[6]=1;
ret=IowKitWrite(iohandle,1,&report,8);
if(ret==8){
report.ReportID=3;
report.Bytes[0]=1;
report.Bytes[1]=0x4C;
report.Bytes[2]=0;
report.Bytes[3]=0;
report.Bytes[4]=0;
report.Bytes[5]=0;
report.Bytes[6]=0;
ret=IowKitWrite(iohandle,1,&report,8);
report.ReportID=3;
report.Bytes[0]=0;
report.Bytes[1]=0;
report.Bytes[2]=0;
report.Bytes[3]=0;
report.Bytes[4]=0;
report.Bytes[5]=0;
report.Bytes[6]=0;
ret=IowKitRead(iohandle,1,&report,8);
if(report.ReportID==3){
temp_high=report.Byte[1];
}
}
report.ReportID=2;
report.Bytes[0]=1;
report.Bytes[1]=0x4C;
report.Bytes[2]=0x10;
report.Bytes[3]=0;
report.Bytes[4]=0;
report.Bytes[5]=1;
report.Bytes[6]=1;
ret=IowKitWrite(iohandle,1,&report,8);
if(ret==IOWKIT_SPECIAL_REPORT_SIZE){
report.ReportID=3;
report.Bytes[0]=1;
report.Bytes[1]=0x4C;
report.Bytes[2]=0;
report.Bytes[3]=0;
report.Bytes[4]=0;
report.Bytes[5]=0;
report.Bytes[6]=0;
ret=IowKitWrite(iohandle,1,&report,8);
report.ReportID=3;
report.Bytes[0]=0;
report.Bytes[1]=0;
report.Bytes[2]=0;
report.Bytes[3]=0;
report.Bytes[4]=0;
report.Bytes[5]=0;
report.Bytes[6]=0;
ret=IowKitRead(iohandle,1,&report,8);
if(report.ReportID==3){
temp_low=report.Byte[1];
}
}
switch(temp_low){
case 0:temp=temp+0.0;break;
case 64:temp=temp+0.25;break;
case 128:temp=temp+0.5;break;
case 192:temp=temp+0.75;break;
default:break;
}
temp=temp+(double)temp_high;
return temp;
}
int main()
{
IOWKIT_HANDLE iohandle;
iohandle = IowKitOpenDevice();
if(iohandle!=NULL){
unsigned long res;
IOWKIT_SPECIAL_REPORT start_iic;
start_iic.ReportID = 1;
res=IowKitWrite(iohandle,1,&start_iic,8);
if(res!=8){
cout << "Fehler!" << endl;
}
else{
IOWKIT_SPECIAL_REPORT send_rep;
send_rep.ReportID=2;
send_rep.Bytes[0]=2;
send_rep.Bytes[1]=0x4C;
send_rep.Bytes[2]=0x0A;
send_rep.Bytes[3]=0x0A;
send_rep.Bytes[4]=0;
send_rep.Bytes[5]=0;
send_rep.Bytes[6]=0;
res=IowKitWrite(iohandle,1,&send_rep,8);
cout << gettemp(iohandle) << endl;
}
}
IowKitCloseDevice();
}
Und hier das Compilerlog:
Compiler: Default compiler
Building Makefile: "D:\Brauanlage\Makefile.win"
Führt make... aus
make.exe -f "D:\Brauanlage\Makefile.win" all
g++.exe -c main.cpp -o main.o -I"D:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include" -I"D:/Dev-Cpp/include/c++/3.4.2/backward" -I"D:/Dev-Cpp/include/c++/3.4.2/mingw32" -I"D:/Dev-Cpp/include/c++/3.4.2" -I"D:/Dev-Cpp/include" -I"D:/Brauanlage/qt_tests/iowarrior/SDK/Windows/library" -I"C:/qt/include"
In file included from main.cpp:2:
D:/Brauanlage/qt_tests/iowarrior/SDK/Windows/library/iowkit.h:46: error: `UCHAR' does not name a type
D:/Brauanlage/qt_tests/iowarrior/SDK/Windows/library/iowkit.h:49: error: `DWORD' does not name a type
D:/Brauanlage/qt_tests/iowarrior/SDK/Windows/library/iowkit.h:50: error: `BYTE' does not name a type
D:/Brauanlage/qt_tests/iowarrior/SDK/Windows/library/iowkit.h:57: error: `UCHAR' does not name a type
D:/Brauanlage/qt_tests/iowarrior/SDK/Windows/library/iowkit.h:60: error: `DWORD' does not name a type
D:/Brauanlage/qt_tests/iowarrior/SDK/Windows/library/iowkit.h:61: error: `BYTE' does not name a type
D:/Brauanlage/qt_tests/iowarrior/SDK/Windows/library/iowkit.h:68: error: `UCHAR' does not name a type
D:/Brauanlage/qt_tests/iowarrior/SDK/Windows/library/iowkit.h:71: error: `WORD' does not name a type
D:/Brauanlage/qt_tests/iowarrior/SDK/Windows/library/iowkit.h:72: error: `BYTE' does not name a type
D:/Brauanlage/qt_tests/iowarrior/SDK/Windows/library/iowkit.h:92: error: `PVOID' does not name a type
D:/Brauanlage/qt_tests/iowarrior/SDK/Windows/library/iowkit.h
D:/Brauanlage/qt_tests/iowarrior/SDK/Windows/library/iowkit.h
D:/Brauanlage/qt_tests/iowarrior/SDK/Windows/library/iowkit.h:101: error: variable or field `IowKitCloseDevice' declared void
D:/Brauanlage/qt_tests/iowarrior/SDK/Windows/library/iowkit.h:101: warning: `__stdcall__' attribute only applies to function types
D:/Brauanlage/qt_tests/iowarrior/SDK/Windows/library/iowkit.h:101: error: `IOWKIT_HANDLE' was not declared in this scope
D:/Brauanlage/qt_tests/iowarrior/SDK/Windows/library/iowkit.h:102: error: expected constructor, destructor, or type conversion before "IowKitWrite"
D:/Brauanlage/qt_tests/iowarrior/SDK/Windows/library/iowkit.h:102: error: expected `,' or `;' before "IowKitWrite"
D:/Brauanlage/qt_tests/iowarrior/SDK/Windows/library/iowkit.h:104: error: expected constructor, destructor, or type conversion before "IowKitRead"
D:/Brauanlage/qt_tests/iowarrior/SDK/Windows/library/iowkit.h:104: error: expected `,' or `;' before "IowKitRead"
D:/Brauanlage/qt_tests/iowarrior/SDK/Windows/library/iowkit.h:106: error: expected constructor, destructor, or type conversion before "IowKitReadImmediate"
D:/Brauanlage/qt_tests/iowarrior/SDK/Windows/library/iowkit.h:106: error: expected `,' or `;' before "IowKitReadImmediate"
D:/Brauanlage/qt_tests/iowarrior/SDK/Windows/library/iowkit.h:107: error: expected constructor, destructor, or type conversion before "IowKitGetNumDevs"
D:/Brauanlage/qt_tests/iowarrior/SDK/Windows/library/iowkit.h:107: error: expected `,' or `;' before "IowKitGetNumDevs"
D:/Brauanlage/qt_tests/iowarrior/SDK/Windows/library/iowkit.h:108: error: expected constructor, destructor, or type conversion before "IowKitGetDeviceHandle"
D:/Brauanlage/qt_tests/iowarrior/SDK/Windows/library/iowkit.h:108: error: expected `,' or `;' before "IowKitGetDeviceHandle"
D:/Brauanlage/qt_tests/iowarrior/SDK/Windows/library/iowkit.h:109: error: expected constructor, destructor, or type conversion before "IowKitSetLegacyOpenMode"
D:/Brauanlage/qt_tests/iowarrior/SDK/Windows/library/iowkit.h:109: error: expected `,' or `;' before "IowKitSetLegacyOpenMode"
D:/Brauanlage/qt_tests/iowarrior/SDK/Windows/library/iowkit.h:110: error: expected constructor, destructor, or type conversion before "IowKitGetProductId"
D:/Brauanlage/qt_tests/iowarrior/SDK/Windows/library/iowkit.h:110: error: expected `,' or `;' before "IowKitGetProductId"
D:/Brauanlage/qt_tests/iowarrior/SDK/Windows/library/iowkit.h:111: error: expected constructor, destructor, or type conversion before "IowKitGetRevision"
D:/Brauanlage/qt_tests/iowarrior/SDK/Windows/library/iowkit.h:111: error: expected `,' or `;' before "IowKitGetRevision"
D:/Brauanlage/qt_tests/iowarrior/SDK/Windows/library/iowkit.h:112: error: expected constructor, destructor, or type conversion before "IowKitGetThreadHandle"
D:/Brauanlage/qt_tests/iowarrior/SDK/Windows/library/iowkit.h:112: error: expected `,' or `;' before "IowKitGetThreadHandle"
D:/Brauanlage/qt_tests/iowarrior/SDK/Windows/library/iowkit.h:113: error: expected constructor, destructor, or type conversion before "IowKitGetSerialNumber"
D:/Brauanlage/qt_tests/iowarrior/SDK/Windows/library/iowkit.h:113: error: expected `,' or `;' before "IowKitGetSerialNumber"
D:/Brauanlage/qt_tests/iowarrior/SDK/Windows/library/iowkit.h:114: error: expected constructor, destructor, or type conversion before "IowKitSetTimeout"
D:/Brauanlage/qt_tests/iowarrior/SDK/Windows/library/iowkit.h:114: error: expected `,' or `;' before "IowKitSetTimeout"
D:/Brauanlage/qt_tests/iowarrior/SDK/Windows/library/iowkit.h:115: error: expected constructor, destructor, or type conversion before "IowKitSetWriteTimeout"
D:/Brauanlage/qt_tests/iowarrior/SDK/Windows/library/iowkit.h:115: error: expected `,' or `;' before "IowKitSetWriteTimeout"
D:/Brauanlage/qt_tests/iowarrior/SDK/Windows/library/iowkit.h:116: error: expected constructor, destructor, or type conversion before "IowKitCancelIo"
D:/Brauanlage/qt_tests/iowarrior/SDK/Windows/library/iowkit.h:116: error: expected `,' or `;' before "IowKitCancelIo"
D:/Brauanlage/qt_tests/iowarrior/SDK/Windows/library/iowkit.h:117: error: expected constructor, destructor, or type conversion before "IowKitVersion"
D:/Brauanlage/qt_tests/iowarrior/SDK/Windows/library/iowkit.h:117: error: expected `,' or `;' before "IowKitVersion"
main.cpp:5: error: `IOWKIT_HANDLE' was not declared in this scope
main.cpp:6: error: expected `,' or `;' before '{' token
main.cpp: In function `int main()':
main.cpp:107: error: `IOWKIT_HANDLE' undeclared (first use this function)
main.cpp:107: error: (Each undeclared identifier is reported only once for each function it appears in.)
main.cpp:107: error: expected `;' before "iohandle"
main.cpp:109: error: `iohandle' undeclared (first use this function)
main.cpp:109: error: `IowKitOpenDevice' undeclared (first use this function)
main.cpp:115: error: `IowKitWrite' undeclared (first use this function)
main.cpp:132: error: `gettemp' cannot be used as a function
main.cpp:136: error: `IowKitCloseDevice' cannot be used as a function
make.exe: *** [main.o] Error 1
Ausführung beendet
Über schnelle und kompetente Hilfe würde ich mich sehr freuen.
Danke im Voraus.