Welcome to %s forums

BrainModular Users Forum

Login Register

How to retrieve value entered in ptIpAddress ?

Create your own modules in C++
Post Reply
imodularsynth
Member
Posts: 36
Contact:

Unread post by imodularsynth » 19 Aug 2018, 12:04

Hi guys,

I am writing a module on which there is a ptIpAddress input. When I enter a new IP address on the patch, the callback is called correctly, but I am unable to retrieve the IP address, I always get 0.

Moreover, sdkGetEvtSize returns 1, which sounds strange (I was expecting 4, since there are four bytes)

sdkGetEvtData() returns 0 whatever I enter in Usine
Same result with sdkGetEvtArrayData (IPAddrEvent, 0);

The input is declared like this, so I think it's correct :

pParamInfo->ParamType = ptIpAddress;
pParamInfo->Caption = "IP";
pParamInfo->IsStoredInPreset = TRUE;
pParamInfo->IsInput = TRUE;
pParamInfo->IsOutput = FALSE;
pParamInfo->CallBackType = ctImmediate;
pParamInfo->EventPtr = &IPAddrEvent;

Anybody having an idea about the way to retrieve the IP address entered ?

Thanks

Benoit

23fx23
Member
Posts: 2545
Contact:

Unread post by 23fx23 » 19 Aug 2018, 12:47

one thing i sometimes do when doubt on pins is open the console (the white one), and hold a wire from a pin, here the console show infos like src_flow_type, src_dispay type ect.
when trying from the osc_receive module ip pin, it says flow type 3, wich is same as purple floats, the 4byte of float are an event of size 1.
if man put a color on the ip, the 4bytes are 255 255 255 255 for full rgba and so is the ip.

didn't try in sdk but what is strange is sdkGetEventData should work then . pers i never set the pParamInfo->EventPtr = &IPAddrEvent; thing
if have a UsineEventPtr my_param; in the .h, and set it in the onSetEventAddress(int ParamIndex, UsineEventPtr pEvent)
switch (ParamIndex)
{
case 0:my_param = pEvent; break;
...
like the provided examples
dk if that could be the cause of the problem...

imodularsynth
Member
Posts: 36
Contact:

Unread post by imodularsynth » 19 Aug 2018, 16:17

Hey 23fx23,

apparently, you are right : Usine considers an IP address to be one int rather than four bytes.

I have solved my problem by using sdkGetEvtDataAddr function like this :

Addr=(unsigned int*)sdkGetEvtDataAddr (IPAddrEvent);
IP=htonl(*Addr);

and now it works like a charm, I am able to receive the IP address entered on the patch

Benoit

Post Reply

Who is online

Users browsing this forum: No registered users and 8 guests