Hello reyalp and thanks for your long post..
I actually need luminance so I can control the shutter speed dynamically while the camera works.
For example, depending on the luminance my shutter should close fast or slow..
Then you should probably just do all your calculation in the cameras native APEX * 96 units.
Then you can just use the APEX equation (see the PDF I linked earlier) to calculate the correct epxosure directly in the cameras native units, using simple integer arithmetic.
luminance_x10 = bit_shl(1, get_bv96()/96) * 34, however it tells me "calling a global function with a nil value"
Oops, sorry about that, as waterwingz says, the shift function is bitshl.
Yes it is 27.2. But still far from OSD misc values..
What units are the OSD values in ? If I've understood correctly, the calculation is not correct for candelas/m^2, so it produces a value in some completely non-standard units.
Unless you have shutter speed, ISO etc in equivalent units, then you can't do any useful calculation with it. You could do a lookup table or something, but that would work just as well with bv96 values. Much simpler and more precise to use APEX values rather than converting.
Anyway, thanks for bringing this up, it looks like it exposed a bug.
I highly recommend you look at user fbonomi's posts about the stratospera project. The site is here http://www.stratospera.com/
(in Italian). If you search his posts, I think you can find some scripts and descriptions in English.