How to get the MAC Address of a NetLinx Master
Question:
How to get the MAC address of a NetLinx master, using GET_UNIQUE_ID() and print to touch panel.
Answer:
This attached code allows for retrieving the MAC address of a NetLinx master. It also shows how to parse it and send it to a touch panel. This can be adapted to use the MAC as a conditional in code.
The code is well commented. GET_UNIQUE_ID() returns the MAC address of the local system into a variable. cMac = GET_UNIQUE_ID().
You can use this in code like:
cMac = GET_UNIQUE_ID()
IF(cMac = “’$00,$9F,$05,$4C,$3B,$21’”) // DO SOMETHINGYou can also use it to display the MAC address on an information page of a touch panel. The page may show things like IP address, system number, online status, etc. For this, you must break up the nMac string and format it to display on the panel.
Example:
cMac = GET_UNIQUE_ID()
// THIS WILL ADD A LEADING 0 IF THE VALUE IS 0
IF(cMac[1] == 0)
{
cMac1 = "'00'"
}
ELSE
{
cMac1 = "ITOHEX(cMac[1])"
}
IF(cMac[2] == 0)
{
cMac2 = "'00'"
}
ELSE
{
cMac2 = "ITOHEX(cMac[2])"
}
IF(cMac[3] == 0)
{
cMac3 = "'00'"
}
ELSE
{
cMac3 = "ITOHEX(cMac[3])"
}
IF(cMac[4] == 0)
{
cMac4 = "'00'"
}
ELSE
{
cMac4 = "ITOHEX(cMac[4])"
}
IF(cMac[5] == 0)
{
cMac5 = "'00'"
}
ELSE
{
cMac5 = "ITOHEX(cMac[5])"
}
IF(cMac[6] == 0)
{
cMac6 = "'00'"
}
ELSE
{
cMac6 = "ITOHEX(cMac[6])"
}
SEND_COMMAND dvTPA,"'^TXT-4,0,MAC: ',cMac1,':',cMac2,':',cMac3,':',cMac4,':',cMac5,':',cMac6"
The result of this command will display in the following format:
00:9F:03:5E:4C:FE