This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Getting the MAC of your Logic Machine.
#1
Hi,

The following code will allow you retrieve the MAC address of your Logic Machine.  Whether this is useful, to some, anyway here it is

Thanks,

Roger

Code:
local f = io.popen('ifconfig')
local t = f:read()
f:close()
local mac = t:match("HWaddr ([%:%x]*)") 

alert(mac)
Reply
#2
There's a faster way Smile


Code:
mac = io.readfile('/sys/class/net/eth0/address'):trim()
Reply
#3
Yep I knew that one, that works on the presence that 'eth0' always exists.
Reply
#4
Ethernet is physically present on all devices. If you need some kind of identification, you can also get unique CPU ID by reading "/proc/device-tree/uniqid"
Reply


Forum Jump: