Hello
My raspberry get an IP address by a DHCP server. I want to show it on a visualisation page.
What function block and what library should J use to find the IP address by programme......
Thank you in advance for your reply
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
use SysSocket lib following codesnippet or check attached Project example
PROGRAMPLC_PRGVAR  sHostName  :STRING;  Host:SysSocket.SOCK_HOSTENT;  pIPAddress :POINTERTODWORD;  in_addr   :INADDR;  sIPAddress :STRING:='aaa.bbb.ccc.ddd';  sTextEingabe:String;END_VAR(*Getownhostname.*)SysSockGetHostName(szHostName:=sHostName,diNameLen:=SIZEOF(sHostName));(*GetownIPaddressbyitsname.*)SysSockGetHostByName(szHostName:=sHostName,pHost:=ADR(Host));pIPAddress:=Host.pAddrList[0];//selecttheadapterofaddrList[]in_addr.ulAddr:=pIPAddress^;SysSockInetNtoa(pInAddr:=ADR(in_addr),szIPADDR:=sIPAddress,diIPAddrSize:=SIZEOF(sIPAddress));
Hi,
yes even this is possible:
You need to ad 'CmpSysEthernet' to the LibraryManager
then then the following code snippet should help.
getnumberofadapters(ADR(diNumber));FORiAdapter:=0TOdiNumberDOPROGRAMPLC_PRGVAR  diNumber:DINT;  iAdapter:DINT;  stName:STRING(255);  stDescription:STRING(255);  aby_address:ARRAY[1..6]OFBYTE;END_VAR  getadapterinfo(  iAdapterNum:=iAdapter,  pbName:=ADR(stName),  pbDescrition:=ADR(stDescription),  iBuffersize:=SIZEOF(stName),  iMacLength:=6,  sMacAdress:=ADR(aby_address));END_FOR
BR
Edwin
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello
My raspberry get an IP address by a DHCP server. I want to show it on a visualisation page.
What function block and what library should J use to find the IP address by programme......
Thank you in advance for your reply
Hi Jabib,
use SysSocket lib following codesnippet or check attached Project example
BR
Edwin
PiFaceIoDrv_LadderExample_andSysProcess.project [104.28 KiB]
And is this the same way for wlan0 address ?
Host.pAddrList[0] returns the eth0 address but wlan0 is another adapter of addrList[], no ?
Hi Edwin,
Thank you. Its work well.
How to discover the possibilitése all those libraries that are not documented in the online help ?
It lacks a Wikipedia section !
great,
and the mac adress?
thx
Hi,
yes even this is possible:
You need to ad 'CmpSysEthernet' to the LibraryManager
then then the following code snippet should help.
BR
Edwin
Thank You,
work perfect.
Thank you very much
Great!
Is there possible to get a Serial number from CPU?
Thank You!
Best regards,
Zdenko.
Great info! So is there a way to combine these two and get the IP address from eth0 always? Thanks