Magic Lantern Forum

Developing Magic Lantern => Scripting Corner => Scripting Q&A => Topic started by: Fortuna Wolf on February 19, 2019, 05:28:42 AM

Title: Is there a way to get the lens serial number?
Post by: Fortuna Wolf on February 19, 2019, 05:28:42 AM
Sketching out a script I plan on writing. Is there a way to get the serial number for a lens? I see there's a way to get the lens name, but I assume this means "50mm 1.8 STM" only.
Title: Re: Is there a way to get the lens serial number?
Post by: a1ex on February 19, 2019, 07:31:27 AM
Like this (https://www.magiclantern.fm/nav.php?seq=ERRRLLLLLDDDSDDD) ?
menu.get (https://builds.magiclantern.fm/lua_api/modules/menu.html#get)("Lens info", "Serial num")
Yes, making this info available to Lua is not a bad idea. Meanwhile, you can extract info from anywhere in the ML menu.
Title: Re: Is there a way to get the lens serial number?
Post by: aprofiti on February 19, 2019, 12:08:30 PM
You can use "lens.serial" in a lua script if using "Non-CPU lens info" from the experimental builds (https://builds.magiclantern.fm/experiments.html).

Notice that the serial number returned is an integer and may be different from the one showed in the Lens Info menu (exiftool version).

Edit: Tried it and return "0" because ML lens_info.serial (https://bitbucket.org/hudson/magic-lantern/src/0de7b671c52c9bee7ac291bcc9ff8a88f3de9f38/src/lens.c?at=manual_lens_info&fileviewer=file-view-default#lens.c-1275) field is not updated automatically with my lens (also show "(none)" in Lens Info menu).
I imagine that with a Canon's lens it should be retrieved correctly from ML.
Title: Re: Is there a way to get the lens serial number?
Post by: Fortuna Wolf on February 21, 2019, 05:45:59 AM
Thanks! I'll try these out.