Okay, danke fuer den Tipp. ich habe inzwischen eine Wrapper Funktion entworfen, aber bisher ... naja ... laeuft es nicht so richtig.
Die Funktion schaut wie folgt aus:
Code:
#ifndef ___ETHERCATLV_H
#define ___ETHERCATLV_H
/* Call Library source file */
#include <extcode.h>
#include <ethercat.h>
#include <string.h>
/* lv_prolog.h and lv_epilog.h set up the correct alignment for LabVIEW data. */
#include "lv_prolog.h"
/* Typedefs */
typedef struct {
int32_t vendorId;
int32_t productId;
int32_t revision;
int32_t serial;
LStrHandle group;
LStrHandle image;
LStrHandle order;
LStrHandle name;
int32_t objCount;
} TD1;
typedef struct {
int32_t objType;
LStrHandle name;
int32_t bitLength;
int32_t index;
int32_t syncIndex;
int32_t varCount;
} TD2;
typedef struct {
int32_t objType;
LStrHandle name;
int32_t dataType;
int32_t bitLength;
int32_t subIndex;
} TD3;
#include "lv_epilog.h"
extern "C" {
_declspec(dllexport) uint32_t KS_queryEcatSlaveInfoLV(uint32_t hSlave, int32_t indexObject,
int32_t indexVariable, TD1 *pSlaveInfo, TD2 *pDataObjInfo,
TD3 *pDataVarInfo, int32_t flags);
}
_declspec(dllexport) uint32_t KS_queryEcatSlaveInfoLV(uint32_t hSlave, int32_t indexObject,
int32_t indexVariable, TD1 *pSlaveInfo, TD2 *pDataObjInfo,
TD3 *pDataVarInfo, int32_t flags)
{
KSEcatDataVarInfo* dataVarInfo_;
KSEcatDataObjInfo* dataObjInfo_;
KSEcatSlaveInfo* slaveInfo_;
Error error = KS_OK;
uint size = 0;
error = KS_queryEcatSlaveInfo((KSHandle) hSlave, &slaveInfo_, flags);
if (error == KS_OK) {
pSlaveInfo->vendorId = slaveInfo_->vendorId;
pSlaveInfo->productId = slaveInfo_->productId;
pSlaveInfo->revision = slaveInfo_->revision;
pSlaveInfo->serial = slaveInfo_->serial;
size = strlen(slaveInfo_->group);
memcpy(LStrBuf(*pSlaveInfo->group), slaveInfo_->group, size);
LStrLen(*pSlaveInfo->group) = size;
size = strlen(slaveInfo_->image);
memcpy(LStrBuf(*pSlaveInfo->image), slaveInfo_->image, size);
LStrLen(*pSlaveInfo->image) = size;
size = strlen(slaveInfo_->order);
memcpy(LStrBuf(*pSlaveInfo->order), slaveInfo_->order, size);
LStrLen(*pSlaveInfo->order) = size;
size = strlen(slaveInfo_->name);
memcpy(LStrBuf(*pSlaveInfo->name), slaveInfo_->name, size);
LStrLen(*pSlaveInfo->name) = size;
pSlaveInfo->objCount = slaveInfo_->objCount;
size = strlen(slaveInfo_->objs[indexObject]->name);
memcpy(LStrBuf(*pDataObjInfo->name), slaveInfo_->objs[indexObject]->name, size);
LStrLen(*pDataObjInfo->name) = size;
pDataObjInfo->bitLength = slaveInfo_->objs[indexObject]->bitLength;
pDataObjInfo->index = slaveInfo_->objs[indexObject]->index;
pDataObjInfo->syncIndex = slaveInfo_->objs[indexObject]->syncIndex;
pDataObjInfo->varCount = slaveInfo_->objs[indexObject]->varCount;
pDataVarInfo->objType = slaveInfo_->objs[indexObject]->vars[indexVariable]->objType;
size = strlen(slaveInfo_->objs[indexObject]->vars[indexVariable]->name);
memcpy(LStrBuf(*pDataVarInfo->name), slaveInfo_->objs[indexObject]->vars[indexVariable]->name, size);
LStrLen(*pDataVarInfo->name) = size;
pDataVarInfo->dataType = slaveInfo_->objs[indexObject]->vars[indexVariable]->dataType;
pDataVarInfo->bitLength = slaveInfo_->objs[indexObject]->vars[indexVariable]->bitLength;
pDataVarInfo->subIndex = slaveInfo_->objs[indexObject]->vars[indexVariable]->subIndex;
}
return error;
}
#endif // ___ETHERCATLV_H
Doch leider schmiert mir mein VI, mit dem ich teste, bereits im Laufen ab, bzw. wenn er mir die Informationen auf dem VI darstellen soll. Es kommt keine Fehlermeldung, es beendet sich einfach. Ich vermute, dass einer der Ein- und Ausgabe Faktoren falsch deklariert ist, aber so richtig komme ich gerade nicht weiter.