Is it possible reading the PCD "IP address" from the user program?
FAQ #100952
Yes, this is possible by calling the system function (CSF) "IPGetLocalConfig".
Introduction
For having the possibility to read the current IP configuration from the user program, a specific System Function has been added to the firmware. This function does return the IP address, the subnet mask as well as the default gateway (each address in one register). The returned value contains the full IP address in one register (each byte or the register contains one octed of the IP address):
Example
This System Function is part of the IPD Library. In order to use these functions, the file "IPLib.inc" is to be included to the source file where the function is called. This can be done with the line:
$INCLUDE "IPLib.inc"
The IP configuration can then be read in th following way:
STH | F 0 | ; only call the function | ||
DYN | F 1 | ; on a rising edge of F0 | ||
CSF H | S.IPD.Library | ; from the IPD library | ||
S.IPD.IPGetLocalConfig | ; call the function "IPGetLocalConfig" | |||
R 0 | ; (R) returned IP address | |||
R 1 | ; (R) returned Subnet mask | |||
R 2 | ; (R) returned Default gateway |
Returned IP address (hex): 0xAC100179h
IP address in "Dot-decimal notation": 172.16.1.121 (0xACh = 172, 0x10h = 16, 0x01h = 1, 0x79h = 121)
Firmware versions supporting the GetLocalIPConfig
Please refer to the table below for the first firmware versions that support the "IPGetLocalConfig" function.
PCD System | minimal firmware version |
PCD1.M1x5 | 0E3 |
PCD2.M150 | 0E3 |
PCD2/4.M170 | 0E3 |
PCD2.M480 | 1.08.21 |
PCD2.M5xx0 | 1.08.19 |
PCD3.Mxxx0 | 03C |
Remark
The include file "IPLib.inc" from PG5 1.4.300 and earlyer versions needs to be updated in order to "know" this feature. Therefore please download the file "IPLib.inc" attached to this FAQ and replace the existing file from PG5 which is located in the "Libs/App" of PG5:
c:\Program Files\SAIA-Burgess\PG5 1_4\Libs\App\IPLib.inc
Categories
PCD1 / _Firmware Classic
PCD2 / _Firmware Classic
PCD3 / _Firmware Classic
Local FAQ Deutschland / SEdit (IL programming)
Communication / Ether-S-Bus
Last update: 28.05.2015 13:06
First release: 05.06.2008 14:39
Views: 7405