Get IP/MAC of LAN, with GX400

Hi, I have not found a way to get the Mac Address of the devices connected to the LAN. I’ve taken a look at devicetree on how to obtain this variable specific, but I have not found it. I also searched as trading MSCIID (aleos.msciid), but neither I found.

The firmware is 4.4.4

Cheers.

Allan

Hi Allan,

below the code to retrieve the mac address.
There is no dev tree path for this currently, it is under creation on our side and will be available in forth-coming firmwares. In the meantime you can use the below sample.

local sched  = require 'sched'
local dev    = require 'devicetree'

local MAC_path = 'aleos.10621'
local MAC_address = ""


local function main()
  -- initialize access to ALEOS Template msci variables.
  dev.init()
  
  -- retrieve First MAC address of the MAC table in Status LAN tab
  MAC_address  = dev.get(MAC_path)
  print("MAC_address: ", MAC_address)
  -- if more than one address in the list, do increment of 1 the msci id,
  -- eg aleos.10622 instead of aleos.10621, to jump to the next line MAC address

end

-- Schedule the main function, and launch the scheduler main loop
sched.run(main)
sched.loop()

Note that you might want to correlate the MAC address to the IP address, in such case you can fetch the IP address in the LAN>IP/MAC table, with following call:

local LANtable_IP = dev.get ('aleos.10601')

Here again add one to the initial msci id (10601) if you want to read down the IP @ list.

Note also that the given msci id (10601 and 10621) are valid on the 4.4.x branch.
If you use your script on 4.6 those will be different, do ask us in this case,

Thanks man, your answer really works.