About ArtNETLib dll call

Alles was nicht direkt mit dem normalen Verhalten des PC_DIMMERs zu tun hat
Antworten
xxm10

About ArtNETLib dll call

Beitrag von xxm10 »

Hi,cloud someone show me how to call ArtNETLib in VC or c++ builder not delphi, thanks.
Sorry I don't konw German language.

:wall: I call this dll,have a error.

static call:

1: get ArtNETlib.lib file:
implib.exe ArtNETlib.lib ArtNETlib.dll
can get ArtNETlib.lib.

2:include ArtNETlib.lib to my project.

3:declare in function:
extern "C" __declspec(dllimport) LPSTR __stdcall ArtNET_Activate();//(void(*p1)(),void(*p2)()); <- declare Error
extern "C" __declspec(dllimport) LPSTR __stdcall ArtNET_Deactivate(void);
extern "C" __declspec(dllimport) LPSTR __stdcall ArtNET_SendDMXUniverse(int SubNet,int Universe,unsigned char * buff,int Length);
extern "C" __declspec(dllimport) LPSTR __stdcall ArtNET_SetChannel(int SubNet,int Universe,int Channel,int Value);
extern "C" __declspec(dllimport) LPSTR __stdcall ArtNET_SetReceiveUniverseOnOff(int SubNet,int Universe,bool En);
extern "C" __declspec(dllimport) LPSTR __stdcall ArtNET_ShowAbout(void);


//--- test call ArtNET_Activate() ----
void __fastcall TForm1::Button2Click(TObject *Sender)
{
ArtNET_Activate(&ReceiveDMXUniverse, &ReceiveSingleValue); //error
}

I don't know how to call ArtNET_Activate() and how to declare ArtNET_Activate() and ReceiveDMXUniverse() / ReceiveSingleValue(),
Can someone help me,Thanks.

Best Regards,
XXM
Benutzeravatar
Christian
PC_DIMMER-Entwickler
Beiträge: 1866
Registriert: 12.11.2007, 09:30
Wohnort: Knw.-Remsfeld
Kontaktdaten:

Re: About ArtNETLib dll call

Beitrag von Christian »

Hi XXM,

void ArtNET_Activate(Pointer1; Pointer2); is a function of the type VOID in VC++ but you have to give the pointers of two callback-functions that will be called by the DLL when values are received by an ArtNet Node connected to the DLL. This is really helpful, because you do not have to poll for new values.

The two callbackfunctions are declared like this:

void ReceiveDMXUniverse(int ArtNETSubNet; int ArtNETUniverse; PDMXArray Buffer; int Length);
void ReceiveSingleValue(int ArtNETSubNet; int ArtNETUniverse; int Channel; int Value);


PDMXArray is a Pointer to a standard Byte-Array. I'm not shure at the moment, how it is declared in VC++ - sorry. Perhaps &char[]?

Now if you call ArtNET_Activate, you have to give this function the pointers of your callback-functions. Thats it. These two functions will be called, if new values are received by the DLL.


void ArtNET_Deactivate(); has no parameters.



void ArtNET_SetChannel(int ArtNETSubNet; int ArtNetUniverse; int Channel; int Value);
void ArtNET_SendDMXUniverse(string Address; int ArtNETSubNet; int ArtNetUniverse; char[] Buffer; int Length);
void ArtNET_ShowConfig();
void ArtNET_ShowAbout();
void ArtNET_SetReceiveUniverseOnOff(int ArtNETSubNet; int ArtNetUniverse; bool Enabled);



I'm not shure if all types of variables are ok (I did this without testing). Use this website, to find the correct type: http://www.herculina.de/dllusage.htm


good luck,
Chris
xxm10

Re: About ArtNETLib dll call

Beitrag von xxm10 »

Hi Chris,
Thank you very much!
In c++ builder declared like this call ArtNETLib.dll succeed. :clap:

static void CALLBACK ReceiveSingleValue(int SubNet,int Universe,int Channel,int Value);
static void CALLBACK ReceiveDMXUniverse(int SubNet,int Universe,unsigned char * buff,int Length);


Test by a button:
void __fastcall TForm1::Button2Click(TObject *Sender)
{
ArtNET_Activate(&ReceiveDMXUniverse,&ReceiveSingleValue);
}

But I have two questions:
question 1:
in Delphi example "testprogramm.pas" file:
// Testuniverse als Pointer der DLL 黚ergeben und als Subnet 0, Universe 0 senden
ArtNET_SendDMXUniverse(0, 0, @TestUniverse, 512);

but your post:
void ArtNET_SendDMXUniverse(string Address; int ArtNETSubNet; int ArtNetUniverse; char[] Buffer; int Length);

where the first parameter "Address" in ArtNET_SendDMXUniverse(0, 0, @TestUniverse, 512) ?

I test in c++ builder have error:
void __fastcall TForm1::Button6Click(TObject *Sender) //test by a button
{
unsigned char data[512];
for(int i=0;i<512;i++)
data=0;
AnsiString Address=0; // What mean Address?
ArtNET_SendDMXUniverse(Address,0,0,&data,512);//Address=?, ArtNETSubNet=0,ArtNetUniverse=0,Buffer=data,Length=512
}

but not test succee, have a error, ok, like your delphi example :

void __fastcall TForm1::Button6Click(TObject *Sender) //test by a button
{
unsigned char data[512];
for(int i=0;i<512;i++)
data=0;
//AnsiString Address=0;// What mean Address?
ArtNET_SendDMXUniverse(0,0,&data,512);//not Address, ArtNETSubNet=0,ArtNetUniverse=0,Buffer=data,Length=512
}

also have erro,why? :cry:

other function test succee:
void ArtNET_SetChannel(int ArtNETSubNet; int ArtNetUniverse; int Channel; int Value); //test ok
void ArtNET_ShowConfig(); //test ok
void ArtNET_ShowAbout(); //test ok
void ArtNET_SetReceiveUniverseOnOff(int ArtNETSubNet; int ArtNetUniverse; bool Enabled); //test ok

void ArtNET_SendDMXUniverse(string Address; int ArtNETSubNet; int ArtNetUniverse; char[] Buffer; int Length); // not ok!

question 2:
How can I get the Receive data?

Test code:
//----------------------------------------------------------------------------
unsigned char MyDMXData[512];
int MySubNetData=0;
int MyUniverseDtata=0;
int MyLengthData=0;

ArtNET_SetReceiveUniverseOnOff(0; 0; TRUE); //Enable ReceiveUniverse
ReceiveDMXUniverse(int SubNet,int Universe,unsigned char *buff,int Length)
{
MySubNetData=SubNet;
MyUniverseDtata=Universe;
MyDMXData=buff;
MyLengthData=Length;
}
print(MySubNetData);
print(MyUniverseDtata);
print(MyLengthData);
print(MyDMXData);

Is the print are Receive data? Thank you Chris.
//------------------------------------------------------------------

BTW:Can release a English version,Thanks.


Best Regards,
XXM
Benutzeravatar
Christian
PC_DIMMER-Entwickler
Beiträge: 1866
Registriert: 12.11.2007, 09:30
Wohnort: Knw.-Remsfeld
Kontaktdaten:

Re: About ArtNETLib dll call

Beitrag von Christian »

Hi,


you are right: ArtNET_SendDMXUniverse is without the "Address" parameter. Perhaps this was from an old version of the library - sorry. You have to define the function like this:

static void ArtNET_SendDMXUniverse(int ArtNETSubNet; int ArtNetUniverse; char[] Buffer; int Length);



The received values will be sent to the callback-functions:
static void CALLBACK ReceiveSingleValue(int SubNet,int Universe,int Channel,int Value);
static void CALLBACK ReceiveDMXUniverse(int SubNet,int Universe,unsigned char * buff,int Length);


so you have to implement some code within this functions, so that you can save and proceed the received values. For example: when "ReceiveDMXUniverse" is called, you will receive the received SubNet, the Universe-Number, the Length and the complete Values as an array of bytes.


Hope this will work for you!


bye,
Chris
xxm10

Re: About ArtNETLib dll call

Beitrag von xxm10 »

Hi Chris,
Thank you yery much!
I'll try it.

Best Regards,
XXM
Antworten