Lua Scripting (lua.mo)

Started by dmilligan, March 29, 2015, 04:44:07 AM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

a1ex

QuoteSwitched to an EF lens with the EF to EF-M adapter and finally got through the tests.

That's right, I've tested with an EF lens, and all other continuous AF features turned off. Don't have any EF-M lenses yet; the 22mm STM seems to be the only half-decent one (for what I'd use), but that's probably not the trickiest lens for ML. On full frame, that lens is equivalent to 35mm f/3.2 - not *that* tempting in low light (but then, you can't compare its size with a Samyang 35mm/1.4).

If the EF-M lenses attempt to move, at least a tiny bit, my best guess is that ML might be checking the wrong status bits while waiting for a confirmation. If you comment out the waiting functions from lens_focus(), it might work better. For example, for a quick test, one could use prop_request_change instead of prop_request_change_wait, comment out lens_focus_wait(), and set a larger delay in the focus settings menu. If that works, we need to find out how to tell when the AF motion was finished. If that doesn't work, we need to find out how EOS utility performs the autofocus commands (that's what I did years ago on 550D iirc). Of course, assuming EOS utility can do remote focus on the EOS M (I do not have it installed).

QuoteML/SCRIPTS/API_TEST.LUA:1094: assertion failed!

First assertion (line 1094) was probably picture not taken because camera couldn't autofocus. No big deal.

QuoteNote that there is an error towards the end of the log. Not sure what it means.

I've also got that last error a few times, in LiveView, on other models. It means ML tried to set some aperture, and Canon firmware picked something a bit too different from what ML asked. In this case, the difference was 0.26 EV, and ML expected a difference smaller than 0.1875 EV. Not sure why it happens, probably not a big deal either.

dfort

Quote from: a1ex on March 20, 2019, 08:26:44 PM
Don't have any EF-M lenses yet; the 22mm STM seems to be the only half-decent one (for what I'd use), but that's probably not the trickiest lens for ML.

An interesting lens is the EF-M 28mm f/3.5 Macro IS STM. It has a built in light and has IS so it shows the shutter-bug.

Quote from: a1ex on March 20, 2019, 08:26:44 PM
If you comment out the waiting functions from lens_focus(), it might work better. For example, for a quick test, one could use prop_request_change instead of prop_request_change_wait, comment out lens_focus_wait(), and set a larger delay in the focus settings menu. If that works, we need to find out how to tell when the AF motion was finished.

Tried this and it didn't work:

src/lens.c
                /* request and wait for confirmation */
                prop_request_change_wait(PROP_LV_LENS_DRIVE_REMOTE, &focus_cmd, 4, 100000);

                /* also wait for confirmation from PROP_LV_FOCUS_DONE */
                // lens_focus_wait();


I kept adding to the timeout value until I thought it was way too much but maybe I didn't go far enough?

Quote from: a1ex on March 20, 2019, 08:26:44 PM
If that doesn't work, we need to find out how EOS utility performs the autofocus commands (that's what I did years ago on 550D iirc). Of course, assuming EOS utility can do remote focus on the EOS M (I do not have it installed).

EOS Utility can do very little on the EOSM, certainly not tethered capture or anything like that.

Here is what EOS Utility looks like without a camera connected:



And this is what happens when the EOSM is connected:



Same thing with the EOSM2.

a1ex

Quote from: dfort on March 21, 2019, 04:56:32 AM
                prop_request_change_wait(PROP_LV_LENS_DRIVE_REMOTE, &focus_cmd, 4, 100000);

Sorry, my English is broken. I wanted to say, don't use prop_request_change_wait, but replace it with prop_request_change (without wait). Then, from ML menu, you could configure a fixed delay, such as 50 ms or whatever. That one ends up as "extra_delay" in the source code.

If the lens moves after these changes, disabling our waiting for confirmation might do the trick (or, the diagnostic logs captured while attempting to focus could give further hints).

If the lens does not move at all... then all we can do is:
- capture debug logs during autofocus (need to find out who decides the direction and speed - the main CPU or the MPU?)
- disable focus functionality for EF-M lenses (easiest, but a bit messy)
- reverse engineer the MPU firmware (hard, time consuming, not a priority for me at the time of writing)

dfort

Your English is fine, my reading is broken.

Tried this:

src/lens.c
#else
                /* request and wait for confirmation */
                // prop_request_change_wait(PROP_LV_LENS_DRIVE_REMOTE, &focus_cmd, 4, 1000);
prop_request_change(PROP_LV_LENS_DRIVE_REMOTE, &focus_cmd, 4);

                /* also wait for confirmation from PROP_LV_FOCUS_DONE */
                // lens_focus_wait();
#endif




But still no focus movement. I take it that the message in the log is just from turning off the camera after letting it run several minutes.

LUATEST.LOG

===============================================================================
ML/SCRIPTS/API_TEST.LUA - 2019-3-22 12:03:33
===============================================================================

Module tests...

Testing lens focus functionality...
Focus distance: 655350
Autofocus in LiveView...
Please trigger autofocus (half-shutter / AF-ON / * ).
Autofocus triggered.
Autofocus completed.
Focus distance: 370
Focusing backward...

ML/SCRIPTS/API_TEST.LUA:1441: lens.focus() only works in LiveView.
stack traceback:
[C]: in function 'lens.focus'
ML/SCRIPTS/API_TEST.LUA:1441: in function 'test_lens_focus'
ML/SCRIPTS/API_TEST.LUA:1579: in function <ML/SCRIPTS/API_TEST.LUA:1564>
[C]: in function 'xpcall'
ML/SCRIPTS/API_TEST.LUA:1564: in function 'api_tests'
ML/SCRIPTS/API_TEST.LUA:1603: in main chunk


The EF-M lenses haven't been able to pass the lua tests for as long as I can remember. Seems like everything else works but those lenses don't seem to move the same way EF/EF-S lenses move.

a1ex

If anyone has a (working) 50mm/1.8 II lens (not the newer STM), or any other lens that does not report focus distance, I'd like you to run the Lua API test with both unified (main) build, and with latest lua_fix experimental build. Camera model doesn't matter much.

Reason: I expect lens.focus to fail on these lenses, as discussed here, but the same function is likely to work fine in mainline.

aprofiti

I have problems running on 50D with a tamron 17-50mm wich doesn't report focus distance in focus tab.

Can't run because it lock the camera in both unified and lua_fix (tested unified feb 04-18 and appears to run up to AF test then camera powered down for uknow reasons).

This is what I got in the log of lua_fix:

===============================================================================
ML/SCRIPTS/API_TEST.LUA - 2019-4-18 20:12:47
===============================================================================

Strict mode tests...
Strict mode tests passed.

Generic tests...
camera = table:
  shutter = table:
    raw = 107
    apex = 6.375
    ms = 12
    value = 0.012048
  aperture = table:
    raw = 35
    apex = 3.375
    value = 3.2
    min = table:
      raw = 32
      apex = 3.
      value = 2.799999
    max = table:
      raw = 88
      apex = 10
      value = 32
  iso = table:
    raw = 80
    apex = 6.
    value = 200
  ec = table:
    raw = 0
    value = 0
  flash_ec = table:
    raw = 0
    value = 0
  kelvin = 5500
  mode = 3
  metering_mode = 3
  drive_mode = 0
  model = "Canon EOS 50D"
  model_short = "50D"
  firmware = "1.0.9"
  temperature = 149
  state = 0
  reboot = function: p
  bulb = function: p
  shoot = function: p
event = table:
  pre_shoot = nil
  post_shoot = nil
  shoot_task = nil
  seconds_clock = nil
  keypress = nil
  custom_picture_taking = nil
  intervalometer = nil
  config_save = nil
console = table:
  hide = function: p
  clear = function: p
  show = function: p
  write = function: p
lv = table:
  enabled = false
  paused = false
  running = false
  zoom = 1
  start = function: p
  pause = function: p
  resume = function: p
  wait = function: p
  stop = function: p
  info = function: p
lens = table:
  name = "17-50mm"
  focal_length = 0
  focus_distance = 14080
  hyperfocal = 0
  dof_near = 0
  dof_far = 0
  af = true
  af_mode = 0
  focus = function: p
display = table:
  idle = true
  height = 480
  width = 720
  pixel = function: p
  screenshot = function: p
  rect = function: p
  circle = function: p
  clear = function: p
  on = function: p
  print = function: p
  line = function: p
  notify_box = function: p
  off = function: p
  draw = function: p
  load = function: p
key = table:
  last = 0
  wait = function: p
  press = function: p
menu = table:
  visible = false
  new = function: p
  get = function: p
  block = function: p
  close = function: p
  open = function: p
  set = function: p
testmenu = userdata:
  value = 0
  name = "Script API tests"
  help = "Various tests for the Lua scripting API."
  help2 = "When adding new Lua APIs, tests for them should go here."
  advanced = 0
  depends_on = 0
  edit_mode = 0
  hidden = false
  icon_type = 5
  jhidden = false
  max = 0
  min = 0
  selected = true
  shidden = false
  starred = false
  submenu_height = 0
  submenu_width = 0
  unit = 0
  works_best_in = 0
  run_in_separate_task = 0
  select = function: p
  update = nil
  info = nil
  rinfo = nil
  warning = nil
movie = table:
  recording = false
  stop = function: p
  start = function: p
dryos = table:
  clock = 39
  ms_clock = 39732
  prefix = "IMG_"
  dcim_dir = table:
    exists = true
    create = function: p
    children = function: p
    files = function: p
    parent = table:
      exists = true
      create = function: p
      children = function: p
      files = function: p
      parent = table:
        exists = true
        create = function: p
        children = function: p
        files = function: p
        parent = nil
        path = "A:/"
      path = "A:/DCIM/"
    path = "A:/DCIM/109CANON/"
  config_dir = table:
    exists = true
    create = function: p
    children = function: p
    files = function: p
    parent = table:
      exists = true
      create = function: p
      children = function: p
      files = function: p
      parent = table:
        exists = true
        create = function: p
        children = function: p
        files = function: p
        parent = nil
        path = "A:/"
      path = "ML/"
    path = "ML/SETTINGS/"
  ml_card = table:
    cluster_size = 4096
    drive_letter = "A"
    file_number = 2409
    folder_number = 109
    free_space = 1198336
    type = "CF"
    path = "A:/"
    _card_ptr = userdata
  shooting_card = table:
    cluster_size = 4096
    drive_letter = "A"
    file_number = 2409
    folder_number = 109
    free_space = 1198336
    type = "CF"
    path = "A:/"
    _card_ptr = userdata
  date = table:
    hour = 20
    min = 12
    day = 18
    sec = 49
    month = 4
    year = 2019
    yday = 1
    wday = 2
    isdst = false
  call = function: p
  directory = function: p
  remove = function: p
interval = table:
  time = 10
  count = 0
  running = 0
  stop = function: p
battery = table:
function not available on this camera
stack traceback:
[C]: in ?
[C]: in for iterator 'for iterator'
ML/SCRIPTS/LIB/logger.lua:125: in function 'logger.serialize'
ML/SCRIPTS/API_TEST.LUA:30: in function <ML/SCRIPTS/API_TEST.LUA:29>
[C]: in function 'xpcall'
ML/SCRIPTS/API_TEST.LUA:29: in function 'print_table'
ML/SCRIPTS/API_TEST.LUA:75: in function 'generic_tests'
ML/SCRIPTS/API_TEST.LUA:634: in function 'api_tests'task = table:
  yield = function: p
  create = function: p
property = table:
Generic tests completed.

Module tests...
Copy test: autoexec.bin -> tmp.bin
Copy test OK
Append test: tmp.txt
Append test OK
Testing exposure settings, module 'camera'...
Camera    : Canon EOS 50D (50D) 1.0.9
Lens      : 17-50mm
Shoot mode: 3
Shutter   : ,80 (raw 107, 0.012048s, 12ms, apex 6.375)
Aperture  : 3.2 (raw 35, f/3.2, apex 3.375)
Av range  : 2.8..32 (raw 32..88, f/2.799999..f/32, apex 3...10)
ISO       : 200 (raw 80, 200, apex 6.)
EC        : 0.0 (raw 0, 0 EV)
Flash EC  : 0.0 (raw 0, 0 EV)
Setting shutter to random values...

===============================================================================
ML/SCRIPTS/API_TEST.LUA - 2019-4-18 20:14:43
===============================================================================

Strict mode tests...
Strict mode tests passed.

Generic tests...
camera = table:
  shutter = table:
    raw = 115
    apex = 7.375
    ms = 6
    value = 0.006024
  aperture = table:
    raw = 35
    apex = 3.375
    value = 3.2
    min = table:
      raw = 32
      apex = 3.
      value = 2.799999
    max = table:
      raw = 88
      apex = 10
      value = 32
  iso = table:
    raw = 80
    apex = 6.
    value = 200
  ec = table:
    raw = 0
    value = 0
  flash_ec = table:
    raw = 0
    value = 0
  kelvin = 5500
  mode = 3
  metering_mode = 3
  drive_mode = 0
  model = "Canon EOS 50D"
  model_short = "50D"
  firmware = "1.0.9"
  temperature = 153
  state = 0
  bulb = function: p
  reboot = function: p
  shoot = function: p
event = table:
  pre_shoot = nil
  post_shoot = nil
  shoot_task = nil
  seconds_clock = nil
  keypress = nil
  custom_picture_taking = nil
  intervalometer = nil
  config_save = nil
console = table:
  hide = function: p
  show = function: p
  write = function: p
  clear = function: p
lv = table:
  enabled = false
  paused = false
  running = false
  zoom = 1
  stop = function: p
  info = function: p
  pause = function: p
  start = function: p
  wait = function: p
  resume = function: p
lens = table:
  name = "17-50mm"
  focal_length = 0
  focus_distance = 14080
  hyperfocal = 0
  dof_near = 0
  dof_far = 0
  af = true
  af_mode = 0
  focus = function: p
display = table:
  idle = true
  height = 480
  width = 720
  pixel = function: p
  draw = function: p
  print = function: p
  screenshot = function: p
  off = function: p
  circle = function: p
  on = function: p
  load = function: p
  notify_box = function: p
  clear = function: p
  line = function: p
  rect = function: p
key = table:
  last = 0
  press = function: p
  wait = function: p
menu = table:
  visible = false
  set = function: p
  new = function: p
  get = function: p
  close = function: p
  block = function: p
  open = function: p
testmenu = userdata:
  value = 0
  name = "Script API tests"
  help = "Various tests for the Lua scripting API."
  help2 = "When adding new Lua APIs, tests for them should go here."
  advanced = 0
  depends_on = 0
  edit_mode = 0
  hidden = false
  icon_type = 5
  jhidden = false
  max = 0
  min = 0
  selected = true
  shidden = false
  starred = false
  submenu_height = 0
  submenu_width = 0
  unit = 0
  works_best_in = 0
  run_in_separate_task = 0
  select = function: p
  update = nil
  info = nil
  rinfo = nil
  warning = nil
movie = table:
  recording = false
  start = function: p
  stop = function: p
dryos = table:
  clock = 21
  ms_clock = 22024
  prefix = "IMG_"
  dcim_dir = table:
    exists = true
    create = function: p
    children = function: p
    files = function: p
    parent = table:
      exists = true
      create = function: p
      children = function: p
      files = function: p
      parent = table:
        exists = true
        create = function: p
        children = function: p
        files = function: p
        parent = nil
        path = "A:/"
      path = "A:/DCIM/"
    path = "A:/DCIM/109CANON/"
  config_dir = table:
    exists = true
    create = function: p
    children = function: p
    files = function: p
    parent = table:
      exists = true
      create = function: p
      children = function: p
      files = function: p
      parent = table:
        exists = true
        create = function: p
        children = function: p
        files = function: p
        parent = nil
        path = "A:/"
      path = "ML/"
    path = "ML/SETTINGS/"
  ml_card = table:
    cluster_size = 4096
    drive_letter = "A"
    file_number = 2409
    folder_number = 109
    free_space = 1198336
    type = "CF"
    _card_ptr = userdata
    path = "A:/"
  shooting_card = table:
    cluster_size = 4096
    drive_letter = "A"
    file_number = 2409
    folder_number = 109
    free_space = 1198336
    type = "CF"
    _card_ptr = userdata
    path = "A:/"
  date = table:
    min = 14
    isdst = false
    hour = 20
    year = 2019
    wday = 2
    month = 4
    sec = 45
    yday = 1
    day = 18
  remove = function: p
  directory = function: p
  call = function: p
interval = table:
  time = 10
  count = 0
  running = 0
  stop = function: p
battery = table:
function not available on this camera
stack traceback:
[C]: in ?
[C]: in for iterator 'for iterator'
ML/SCRIPTS/LIB/logger.lua:125: in function 'logger.serialize'
ML/SCRIPTS/API_TEST.LUA:30: in function <ML/SCRIPTS/API_TEST.LUA:29>
[C]: in function 'xpcall'
ML/SCRIPTS/API_TEST.LUA:29: in function 'print_table'
ML/SCRIPTS/API_TEST.LUA:75: in function 'generic_tests'
ML/SCRIPTS/API_TEST.LUA:634: in function 'api_tests'task = table:
  yield = function: p
  create = function: p
property = table:
Generic tests completed.

Module tests...
Copy test: autoexec.bin -> tmp.bin
Copy test OK
Append test: tmp.txt
Append test OK
Testing exposure settings, module 'camera'...
Camera    : Canon EOS 50D (50D) 1.0.9
Lens      : 17-50mm
Shoot mode: 3
Shutter   : ,160 (raw 115, 0.006024s, 6ms, apex 7.375)
Aperture  : 3.2 (raw 35, f/3.2, apex 3.375)
Av range  : 2.8..32 (raw 32..88, f/2.799999..f/32, apex 3...10)
ISO       : 200 (raw 80, 200, apex 6.)
EC        : 0.0 (raw 0, 0 EV)
Flash EC  : 0.0 (raw 0, 0 EV)
Setting shutter to random values...
Error: shutter set to raw=97, got 0.03125s, expected 0.028656s
Error: shutter set to raw=97, got 31ms, expected 29ms
Error: shutter set to raw=97, got Tv5, expected Tv5.125
Error: shutter set to raw=97, got 96, expected 97 (raw)


This unified Jul 03-18:


===============================================================================
ML/SCRIPTS/API_TEST.LUA - 2019-4-18 22:40:29
===============================================================================

Strict mode tests...
Strict mode tests passed.

Generic tests...
camera = table:
  shutter = table:
    raw = 83
    apex = 3.375
    ms = 96
    value = 0.096388
  aperture = table:
    raw = 32
    apex = 3.
    value = 2.799999
    min = table:
      raw = 32
      apex = 3.
      value = 2.799999
    max = table:
      raw = 88
      apex = 10
      value = 32
  iso = table:
    raw = 80
    apex = 6.
    value = 200
  ec = table:
    raw = 0
    value = 0
  flash_ec = table:
    raw = 0
    value = 0
  kelvin = 5500
  mode = 3
  metering_mode = 3
  drive_mode = 0
  model = "Canon EOS 50D"
  model_short = "50D"
  firmware = "1.0.9"
  temperature = 152
  state = 0
  reboot = function: p
  shoot = function: p
  bulb = function: p
event = table:
  pre_shoot = nil
  post_shoot = nil
  shoot_task = nil
  seconds_clock = nil
  keypress = nil
  custom_picture_taking = nil
  intervalometer = nil
  config_save = nil
console = table:
  clear = function: p
  write = function: p
  show = function: p
  hide = function: p
lv = table:
  enabled = false
  paused = false
  running = false
  zoom = 1
  start = function: p
  stop = function: p
  resume = function: p
  pause = function: p
  wait = function: p
  info = function: p
lens = table:
  name = "17-50mm"
  focal_length = 0
  focus_distance = 14080
  hyperfocal = 0
  dof_near = 0
  dof_far = 0
  af = true
  af_mode = 0
  focus = function: p
display = table:
  idle = true
  height = 480
  width = 720
  print = function: p
  clear = function: p
  on = function: p
  pixel = function: p
  rect = function: p
  line = function: p
  draw = function: p
  load = function: p
  circle = function: p
  notify_box = function: p
  screenshot = function: p
  off = function: p
key = table:
  last = 0
  press = function: p
  wait = function: p
menu = table:
  visible = false
  set = function: p
  block = function: p
  close = function: p
  open = function: p
  get = function: p
  new = function: p
testmenu = userdata:
  value = 0
  name = "Script API tests"
  help = "Various tests for the Lua scripting API."
  help2 = "When adding new Lua APIs, tests for them should go here."
  advanced = 0
  depends_on = 0
  edit_mode = 0
  hidden = false
  icon_type = 5
  jhidden = false
  max = 0
  min = 0
  selected = true
  shidden = false
  starred = false
  submenu_height = 0
  submenu_width = 0
  unit = 0
  works_best_in = 0
  run_in_separate_task = 0
  select = function: p
  update = nil
  info = nil
  rinfo = nil
  warning = nil
movie = table:
  recording = false
  start = function: p
  stop = function: p
dryos = table:
  clock = 25
  ms_clock = 25387
  prefix = "IMG_"
  dcim_dir = table:
    exists = true
    create = function: p
    children = function: p
    files = function: p
    parent = table:
      exists = true
      create = function: p
      children = function: p
      files = function: p
      parent = table:
        exists = true
        create = function: p
        children = function: p
        files = function: p
        parent = nil
        path = "A:/"
      path = "A:/DCIM/"
    path = "A:/DCIM/109CANON/"
  config_dir = table:
    exists = true
    create = function: p
    children = function: p
    files = function: p
    parent = table:
      exists = true
      create = function: p
      children = function: p
      files = function: p
      parent = table:
        exists = true
        create = function: p
        children = function: p
        files = function: p
        parent = nil
        path = "A:/"
      path = "ML/"
    path = "ML/SETTINGS/"
  ml_card = table:
    cluster_size = 4096
    drive_letter = "A"
    file_number = 2411
    folder_number = 109
    free_space = 1196608
    type = "CF"
    path = "A:/"
    _card_ptr = userdata
  shooting_card = table:
    cluster_size = 4096
    drive_letter = "A"
    file_number = 2411
    folder_number = 109
    free_space = 1196608
    type = "CF"
    path = "A:/"
    _card_ptr = userdata
  date = table:
    yday = 1
    wday = 2
    year = 2019
    month = 4
    isdst = false
    day = 18
    hour = 22
    sec = 31
    min = 40
  directory = function: p
  remove = function: p
  call = function: p
interval = table:
  time = 10
  count = 0
  running = 0
  stop = function: p
battery = table:
function not available on this camera
stack traceback:
[C]: in ?
[C]: in for iterator 'for iterator'
ML/SCRIPTS/LIB/logger.lua:125: in function 'logger.serialize'
ML/SCRIPTS/API_TEST.LUA:30: in function <ML/SCRIPTS/API_TEST.LUA:29>
[C]: in function 'globals.xpcall'
ML/SCRIPTS/API_TEST.LUA:29: in function 'globals.print_table'
ML/SCRIPTS/API_TEST.LUA:75: in function 'globals.generic_tests'
ML/SCRIPTS/API_TEST.LUA:634: in function 'globals.api_tests'task = table:
  yield = function: p
  create = function: p
property = table:
Generic tests completed.

Module tests...
Copy test: autoexec.bin -> tmp.bin
Copy test OK
Append test: tmp.txt

===============================================================================
ML/SCRIPTS/API_TEST.LUA - 2019-4-18 22:50:09
===============================================================================

Strict mode tests...
Strict mode tests passed.

Generic tests...
camera = table:
  shutter = table:
    raw = 147
    apex = 11.375
    ms = 0
    value = 0.000376
  aperture = table:
    raw = 0
    apex = 0
    value = 0
    min = table:
      raw = 0
      apex = 0
      value = 0
    max = table:
      raw = 0
      apex = 0
      value = 0
  iso = table:
    raw = 80
    apex = 6.
    value = 200
  ec = table:
    raw = 0
    value = 0
  flash_ec = table:
    raw = 0
    value = 0
  kelvin = 5500
  mode = 3
  metering_mode = 3
  drive_mode = 0
  model = "Canon EOS 50D"
  model_short = "50D"
  firmware = "1.0.9"
  temperature = 152
  state = 0
  shoot = function: p
  reboot = function: p
  bulb = function: p
event = table:
  pre_shoot = nil
  post_shoot = nil
  shoot_task = nil
  seconds_clock = nil
  keypress = nil
  custom_picture_taking = nil
  intervalometer = nil
  config_save = nil
console = table:
  clear = function: p
  show = function: p
  write = function: p
  hide = function: p
lv = table:
  enabled = false
  paused = false
  running = false
  zoom = 1
  stop = function: p
  info = function: p
  pause = function: p
  wait = function: p
  resume = function: p
  start = function: p
lens = table:
  name = ""
  focal_length = 0
  focus_distance = 14080
  hyperfocal = 0
  dof_near = 0
  dof_far = 0
  af = false
  af_mode = 3
  focus = function: p
display = table:
  idle = true
  height = 480
  width = 720
  load = function: p
  clear = function: p
  on = function: p
  pixel = function: p
  screenshot = function: p
  rect = function: p
  line = function: p
  draw = function: p
  notify_box = function: p
  print = function: p
  circle = function: p
  off = function: p
key = table:
  last = 0
  wait = function: p
  press = function: p
menu = table:
  visible = false
  open = function: p
  close = function: p
  set = function: p
  new = function: p
  block = function: p
  get = function: p
testmenu = userdata:
  value = 0
  name = "Script API tests"
  help = "Various tests for the Lua scripting API."
  help2 = "When adding new Lua APIs, tests for them should go here."
  advanced = 0
  depends_on = 0
  edit_mode = 0
  hidden = false
  icon_type = 5
  jhidden = false
  max = 0
  min = 0
  selected = true
  shidden = false
  starred = false
  submenu_height = 0
  submenu_width = 0
  unit = 0
  works_best_in = 0
  run_in_separate_task = 0
  select = function: p
  update = nil
  info = nil
  rinfo = nil
  warning = nil
movie = table:
  recording = false
  stop = function: p
  start = function: p
dryos = table:
  clock = 70
  ms_clock = 71064
  prefix = "IMG_"
  dcim_dir = table:
    exists = true
    create = function: p
    children = function: p
    files = function: p
    parent = table:
      exists = true
      create = function: p
      children = function: p
      files = function: p
      parent = table:
        exists = true
        create = function: p
        children = function: p
        files = function: p
        parent = nil
        path = "A:/"
      path = "A:/DCIM/"
    path = "A:/DCIM/109CANON/"
  config_dir = table:
    exists = true
    create = function: p
    children = function: p
    files = function: p
    parent = table:
      exists = true
      create = function: p
      children = function: p
      files = function: p
      parent = table:
        exists = true
        create = function: p
        children = function: p
        files = function: p
        parent = nil
        path = "A:/"
      path = "ML/"
    path = "ML/SETTINGS/"
  ml_card = table:
    cluster_size = 4096
    drive_letter = "A"
    file_number = 2411
    folder_number = 109
    free_space = 1196608
    type = "CF"
    path = "A:/"
    _card_ptr = userdata
  shooting_card = table:
    cluster_size = 4096
    drive_letter = "A"
    file_number = 2411
    folder_number = 109
    free_space = 1196608
    type = "CF"
    path = "A:/"
    _card_ptr = userdata
  date = table:
    year = 2019
    wday = 2
    yday = 1
    min = 50
    month = 4
    hour = 22
    sec = 11
    day = 18
    isdst = false
  directory = function: p
  remove = function: p
  call = function: p
interval = table:
  time = 10
  count = 0
  running = 0
  stop = function: p
battery = table:
function not available on this camera
stack traceback:
[C]: in ?
[C]: in for iterator 'for iterator'
ML/SCRIPTS/LIB/logger.lua:125: in function 'logger.serialize'
ML/SCRIPTS/API_TEST.LUA:30: in function <ML/SCRIPTS/API_TEST.LUA:29>
[C]: in function 'globals.xpcall'
ML/SCRIPTS/API_TEST.LUA:29: in function 'globals.print_table'
ML/SCRIPTS/API_TEST.LUA:75: in function 'globals.generic_tests'
ML/SCRIPTS/API_TEST.LUA:634: in function 'globals.api_tests'task = table:
  yield = function: p
  create = function: p
property = table:
Generic tests completed.

Module tests...
Copy test: autoexec.bin -> tmp.bin
Copy test OK
Append test: tmp.txt
Append test OK
Testing exposure settings, module 'camera'...
Camera    : Canon EOS 50D (50D) 1.0.9
Lens      :
Shoot mode: 3
Shutter   : ,2500 (raw 147, 0.000376s, 0ms, apex 11.375)
Aperture  : 0.0 (raw 0, f/0, apex 0)
Av range  : 0.0..0.0 (raw 0..0, f/0..f/0, apex 0..0)
ISO       : 200 (raw 80, 200, apex 6.)
EC        : 0.0 (raw 0, 0 EV)
Flash EC  : 0.0 (raw 0, 0 EV)
Setting shutter to random values...

a1ex

To narrow down:
- comment out test_lens_focus (expecting the API tests to pass)
- run only the first half of test_lens_focus (before the calls to lens.focus)
- try a large delay in lens.focus (4th argument, which is optional); for example, 100 or 500 ms

BTW, is the 50D able to shut down cleanly with the latest lua_fix build? The 5D2 is not (it locks up with both LEDs turned on).

aprofiti

Quote from: a1ex on April 19, 2019, 03:13:07 PM
BTW, is the 50D able to shut down cleanly with the latest lua_fix build? The 5D2 is not (it locks up with both LEDs turned on).
What do you do exacly? If I use the build normally, it doesn't looks like it need a battery pull.
Camera freezes as described before if I run api_test.lua untouched and need to take battery out to power down camera.

Here are more detailed tests using lua_fix 20-03-19:

===============================================================================
ML/SCRIPTS/API_TEST.LUA - 2019-4-19 16:55:05
===============================================================================

Strict mode tests...
Strict mode tests passed.

Generic tests...
arg = table:
  [0] = "API_TEST.LUA"
camera = table:
  shutter = table:
    raw = 88
    apex = 4.
    ms = 63
    value = 0.0625
  aperture = table:
    raw = 32
    apex = 3.
    value = 2.8
    min = table:
      raw = 32
      apex = 3.
      value = 2.8
    max = table:
      raw = 88
      apex = 10.
      value = 32
  iso = table:
    raw = 80
    apex = 6.
    value = 200
  ec = table:
    raw = 0
    value = 0
  flash = true
  flash_ec = table:
    raw = 0
    value = 0
  kelvin = 5500
  mode = 3
  metering_mode = 3
  drive_mode = 0
  model = "Canon EOS 50D"
  model_short = "50D"
  firmware = "1.0.9"
  temperature = 149
  gui = table:
    menu = false
    play = false
    play_photo = false
    play_movie = false
    qr = false
    idle = true
  shoot = function: 0x9f1194
  bulb = function: 0x9f13c8
  reboot = function: 0x9f1168
  burst = function: 0x9f1448
  wait = function: 0x9f00c0
event = table:
  pre_shoot = nil
  post_shoot = nil
  shoot_task = nil
  seconds_clock = nil
  keypress = nil
  custom_picture_taking = nil
  intervalometer = nil
  config_save = nil
console = table:
  show = function: 0x9eea54
  write = function: 0x9eeae8
  hide = function: 0x9eea44
  clear = function: 0x9eea34
lv = table:
  enabled = false
  paused = false
  running = false
  zoom = 1
  overlays = false
  stop = function: 0x9f15e0
  resume = function: 0x9f1c68
  info = function: 0x9f1974
  start = function: 0x9f15d0
  pause = function: 0x9f1c78
  wait = function: 0x9f2038
lens = table:
  name = "17-50mm"
  focal_length = 17
  focus_distance = 0
  hyperfocal = 5466
  dof_near = 11139225
  dof_far = 1000000
  af = true
  af_mode = 0
  autofocus = function: 0x9f2b1c
  focus = function: 0x9f2ce4
display = table:
  idle = nil
  height = 480
  width = 720
  print = function: 0x9f4990
  load = function: 0x9f3854
  screenshot = function: 0x9f348c
  notify_box = function: 0x9f3624
  draw = function: 0x9f370c
  off = function: 0x9f3560
  on = function: 0x9f3570
  clear = function: 0x9f347c
  line = function: 0x9f44fc
  circle = function: 0x9f3ec8
  pixel = function: 0x9f47c4
  rect = function: 0x9f4198
key = table:
  last = 20
  press = function: 0x9f5168
  wait = function: 0x9f4ea0
menu = table:
  visible = false
  new = function: 0x9f7590
  get = function: 0x9f6934
  block = function: 0x9f56d0
  open = function: 0x9f54e0
  select = function: 0x9f6680
  set = function: 0x9f6754
  close = function: 0x9f54c8
movie = table:
  recording = false
  stop = function: 0x9f30e4
  start = function: 0x9f3178
dryos = table:
  clock = 15
  ms_clock = 15996
  image_prefix = "IMG_"
  config_dir = table:
    exists = true
    create = function: 0x9f88b4
    children = function: 0x9f873c
    files = function: 0x9f8620
    parent = table:
      exists = true
      create = function: 0x9f88b4
      children = function: 0x9f873c
      files = function: 0x9f8620
      parent = table:
        exists = true
        create = function: 0x9f88b4
        children = function: 0x9f873c
        files = function: 0x9f8620
        parent = nil
        path = "A:/"
      path = "ML/"
    path = "ML/SETTINGS/"
  ml_card = table:
    drive_letter = "A"
    dcim_dir = table:
      exists = true
      create = function: 0x9f88b4
      children = function: 0x9f873c
      files = function: 0x9f8620
      parent = table:
        exists = true
        create = function: 0x9f88b4
        children = function: 0x9f873c
        files = function: 0x9f8620
        parent = table:
          exists = true
          create = function: 0x9f88b4
          children = function: 0x9f873c
          files = function: 0x9f8620
          parent = nil
          path = "A:/"
        path = "A:/DCIM/"
      path = "A:/DCIM/109CANON/"
    file_number = 2411
    folder_number = 109
    free_space = 1168
    image_path = function: 0x9f8a90
    type = "CF"
    _card_ptr = userdata
    path = "A:/"
  shooting_card = table:
    drive_letter = "A"
    dcim_dir = table:
      exists = true
      create = function: 0x9f88b4
      children = function: 0x9f873c
      files = function: 0x9f8620
      parent = table:
        exists = true
        create = function: 0x9f88b4
        children = function: 0x9f873c
        files = function: 0x9f8620
        parent = table:
          exists = true
          create = function: 0x9f88b4
          children = function: 0x9f873c
          files = function: 0x9f8620
          parent = nil
          path = "A:/"
        path = "A:/DCIM/"
      path = "A:/DCIM/109CANON/"
    file_number = 2411
    folder_number = 109
    free_space = 1168
    image_path = function: 0x9f8a90
    type = "CF"
    _card_ptr = userdata
    path = "A:/"
  cf_card = table:
    drive_letter = "A"
    dcim_dir = table:
      exists = true
      create = function: 0x9f88b4
      children = function: 0x9f873c
      files = function: 0x9f8620
      parent = table:
        exists = true
        create = function: 0x9f88b4
        children = function: 0x9f873c
        files = function: 0x9f8620
        parent = table:
          exists = true
          create = function: 0x9f88b4
          children = function: 0x9f873c
          files = function: 0x9f8620
          parent = nil
          path = "A:/"
        path = "A:/DCIM/"
      path = "A:/DCIM/109CANON/"
    file_number = 2411
    folder_number = 109
    free_space = 1168
    image_path = function: 0x9f8a90
    type = "CF"
    _card_ptr = userdata
    path = "A:/"
  sd_card = nil
  date = table:
    sec = 7
    month = 4
    hour = 16
    day = 19
    isdst = false
    min = 55
    wday = 3
    year = 2019
    yday = 1
  remove = function: 0x9f8114
  rename = function: 0x9f8040
  directory = function: 0x9f8180
  call = function: 0x9f7e3c
interval = table:
  time = 10
  count = 0
  running = false
  stop = function: 0x9f94d0
battery = table:
function not available on this camera
stack traceback:
[C]: in ?
[C]: in for iterator 'for iterator'
ML/SCRIPTS/LIB/logger.lua:125: in function 'logger.serialize'
ML/SCRIPTS/API_TEST.LUA:45: in function <ML/SCRIPTS/API_TEST.LUA:44>
[C]: in function 'globals.xpcall'
ML/SCRIPTS/API_TEST.LUA:44: in function 'globals.print_table'
ML/SCRIPTS/API_TEST.LUA:90: in function 'globals.generic_tests'
ML/SCRIPTS/API_TEST.LUA:1568: in function <ML/SCRIPTS/API_TEST.LUA:1564>
[C]: in function 'globals.xpcall'
ML/SCRIPTS/API_TEST.LUA:1564: in function 'globals.api_tests'
ML/SCRIPTS/API_TEST.LUA:1603: in main chunktask = table:
  yield = function: 0x9f9b38
  create = function: 0x9f9cb8
property = table:
Generic tests completed.

Module tests...
Testing file I/O...
Copy test: autoexec.bin -> tmp.bin
Copy test OK
Append test: tmp.txt
Append test OK
Rename test: apple.txt -> banana.txt
Rename test OK
Rename test: apple.txt -> ML/banana.txt

Camera Locks, battery pull required.

Running with test_io() disabled:

===============================================================================
ML/SCRIPTS/API_TEST.LUA - 2019-4-19 17:02:29
===============================================================================

Strict mode tests...
Strict mode tests passed.

Generic tests...
arg = table:
  [0] = "API_TEST.LUA"
camera = table:
  shutter = table:
    raw = 88
    apex = 4.
    ms = 63
    value = 0.0625
  aperture = table:
    raw = 32
    apex = 3.
    value = 2.8
    min = table:
      raw = 32
      apex = 3.
      value = 2.8
    max = table:
      raw = 88
      apex = 10.
      value = 32
  iso = table:
    raw = 80
    apex = 6.
    value = 200
  ec = table:
    raw = 0
    value = 0
  flash = true
  flash_ec = table:
    raw = 0
    value = 0
  kelvin = 5500
  mode = 3
  metering_mode = 3
  drive_mode = 0
  model = "Canon EOS 50D"
  model_short = "50D"
  firmware = "1.0.9"
  temperature = 149
  gui = table:
    menu = false
    play = false
    play_photo = false
    play_movie = false
    qr = false
    idle = true
  bulb = function: 0x9f1368
  shoot = function: 0x9f1134
  reboot = function: 0x9f1108
  wait = function: 0x9f0060
  burst = function: 0x9f13e8
event = table:
  pre_shoot = nil
  post_shoot = nil
  shoot_task = nil
  seconds_clock = nil
  keypress = nil
  custom_picture_taking = nil
  intervalometer = nil
  config_save = nil
console = table:
  hide = function: 0x9ee9e4
  show = function: 0x9ee9f4
  clear = function: 0x9ee9d4
  write = function: 0x9eea88
lv = table:
  enabled = false
  paused = false
  running = false
  zoom = 1
  overlays = false
  pause = function: 0x9f1c18
  info = function: 0x9f1914
  start = function: 0x9f1570
  wait = function: 0x9f1fd8
  resume = function: 0x9f1c08
  stop = function: 0x9f1580
lens = table:
  name = "17-50mm"
  focal_length = 32
  focus_distance = 0
  hyperfocal = 19312
  dof_near = -934934500
  dof_far = 1000000
  af = true
  af_mode = 0
  focus = function: 0x9f2c84
  autofocus = function: 0x9f2abc
display = table:
  idle = nil
  height = 480
  width = 720
  line = function: 0x9f449c
  off = function: 0x9f3500
  circle = function: 0x9f3e68
  on = function: 0x9f3510
  print = function: 0x9f4930
  notify_box = function: 0x9f35c4
  screenshot = function: 0x9f342c
  draw = function: 0x9f36ac
  pixel = function: 0x9f4764
  load = function: 0x9f37f4
  clear = function: 0x9f341c
  rect = function: 0x9f4138
key = table:
  last = 20
  wait = function: 0x9f4e40
  press = function: 0x9f5108
menu = table:
  visible = false
  new = function: 0x9f7530
  close = function: 0x9f5468
  get = function: 0x9f68d4
  select = function: 0x9f6620
  open = function: 0x9f5480
  block = function: 0x9f5670
  set = function: 0x9f66f4
movie = table:
  recording = false
  stop = function: 0x9f3084
  start = function: 0x9f3118
dryos = table:
  clock = 19
  ms_clock = 19920
  image_prefix = "IMG_"
  config_dir = table:
    exists = true
    create = function: 0x9f8854
    children = function: 0x9f86dc
    files = function: 0x9f85c0
    parent = table:
      exists = true
      create = function: 0x9f8854
      children = function: 0x9f86dc
      files = function: 0x9f85c0
      parent = table:
        exists = true
        create = function: 0x9f8854
        children = function: 0x9f86dc
        files = function: 0x9f85c0
        parent = nil
        path = "A:/"
      path = "ML/"
    path = "ML/SETTINGS/"
  ml_card = table:
    drive_letter = "A"
    dcim_dir = table:
      exists = true
      create = function: 0x9f8854
      children = function: 0x9f86dc
      files = function: 0x9f85c0
      parent = table:
        exists = true
        create = function: 0x9f8854
        children = function: 0x9f86dc
        files = function: 0x9f85c0
        parent = table:
          exists = true
          create = function: 0x9f8854
          children = function: 0x9f86dc
          files = function: 0x9f85c0
          parent = nil
          path = "A:/"
        path = "A:/DCIM/"
      path = "A:/DCIM/109CANON/"
    file_number = 2411
    folder_number = 109
    free_space = 1168
    image_path = function: 0x9f8a30
    type = "CF"
    path = "A:/"
    _card_ptr = userdata
  shooting_card = table:
    drive_letter = "A"
    dcim_dir = table:
      exists = true
      create = function: 0x9f8854
      children = function: 0x9f86dc
      files = function: 0x9f85c0
      parent = table:
        exists = true
        create = function: 0x9f8854
        children = function: 0x9f86dc
        files = function: 0x9f85c0
        parent = table:
          exists = true
          create = function: 0x9f8854
          children = function: 0x9f86dc
          files = function: 0x9f85c0
          parent = nil
          path = "A:/"
        path = "A:/DCIM/"
      path = "A:/DCIM/109CANON/"
    file_number = 2411
    folder_number = 109
    free_space = 1168
    image_path = function: 0x9f8a30
    type = "CF"
    path = "A:/"
    _card_ptr = userdata
  cf_card = table:
    drive_letter = "A"
    dcim_dir = table:
      exists = true
      create = function: 0x9f8854
      children = function: 0x9f86dc
      files = function: 0x9f85c0
      parent = table:
        exists = true
        create = function: 0x9f8854
        children = function: 0x9f86dc
        files = function: 0x9f85c0
        parent = table:
          exists = true
          create = function: 0x9f8854
          children = function: 0x9f86dc
          files = function: 0x9f85c0
          parent = nil
          path = "A:/"
        path = "A:/DCIM/"
      path = "A:/DCIM/109CANON/"
    file_number = 2411
    folder_number = 109
    free_space = 1168
    image_path = function: 0x9f8a30
    type = "CF"
    path = "A:/"
    _card_ptr = userdata
  sd_card = nil
  date = table:
    sec = 30
    year = 2019
    wday = 3
    day = 19
    hour = 17
    isdst = false
    min = 2
    yday = 1
    month = 4
  directory = function: 0x9f8120
  rename = function: 0x9f7fe0
  call = function: 0x9f7ddc
  remove = function: 0x9f80b4
interval = table:
  time = 10
  count = 0
  running = false
  stop = function: 0x9f9470
battery = table:
function not available on this camera
stack traceback:
[C]: in ?
[C]: in for iterator 'for iterator'
ML/SCRIPTS/LIB/logger.lua:125: in function 'logger.serialize'
ML/SCRIPTS/API_TEST.LUA:45: in function <ML/SCRIPTS/API_TEST.LUA:44>
[C]: in function 'globals.xpcall'
ML/SCRIPTS/API_TEST.LUA:44: in function 'globals.print_table'
ML/SCRIPTS/API_TEST.LUA:90: in function 'globals.generic_tests'
ML/SCRIPTS/API_TEST.LUA:1568: in function <ML/SCRIPTS/API_TEST.LUA:1564>
[C]: in function 'globals.xpcall'
ML/SCRIPTS/API_TEST.LUA:1564: in function 'globals.api_tests'
ML/SCRIPTS/API_TEST.LUA:1603: in main chunktask = table:
  create = function: 0x9f9c58
  yield = function: 0x9f9ad8
property = table:
Generic tests completed.

Module tests...
Testing Canon GUI functions...
Enter MENU mode...
Enter PLAY mode...
Enter MENU mode...
Enter MENU mode...
Enter MENU mode...
Enter PLAY mode...
Enter PLAY mode...
Enter PLAY mode...
Exit PLAY mode...
Enter PLAY mode...
Exit PLAY mode...
Start LiveView...
Pause LiveView...
Enter MENU mode...
Enter PLAY mode...
Enter PLAY mode...
Enter MENU mode...
Exit MENU mode...
Pause LiveView...
Resume LiveView...
Enter PLAY mode...
Enter MENU mode...
Enter PLAY mode...
Exit PLAY mode...
Stop LiveView...
Start LiveView...
Enter MENU mode...
Enter PLAY mode...
Enter PLAY mode...
Enter PLAY mode...
Enter MENU mode...
Exit MENU mode...
Pause LiveView...
Enter PLAY mode...
Exit PLAY mode...
Pause LiveView...
Enter MENU mode...
Exit MENU mode...
Enter MENU mode...
Enter MENU mode...
Enter MENU mode...
Enter MENU mode...
Enter PLAY mode...
Enter PLAY mode...
Exit PLAY mode...
Enter PLAY mode...
Enter PLAY mode...
Exit PLAY mode...
Pause LiveView...
Enter MENU mode...
Exit MENU mode...
Pause LiveView...
Resume LiveView...
Enter MENU mode...
Enter MENU mode...
Enter PLAY mode...
Enter PLAY mode...
Enter PLAY mode...
Exit PLAY mode...
Enter MENU mode...
Enter MENU mode...
Enter PLAY mode...
Enter MENU mode...
Enter PLAY mode...
Exit PLAY mode...
Pause LiveView...
Resume LiveView...
Enter PLAY mode...
Enter PLAY mode...
Exit PLAY mode...
Enter MENU mode...
Exit MENU mode...
Pause LiveView...
Resume LiveView...
Enter PLAY mode...
Enter MENU mode...
Enter PLAY mode...
Exit PLAY mode...
Pause LiveView...
Enter PLAY mode...
Exit PLAY mode...
Pause LiveView...
Canon GUI tests completed.

Testing ML menu API...
Menu tests completed.

Testing picture taking functions...
Snap simulation test...
Single picture...
A:/DCIM/109CANON/IMG_2412.CR2: 20937882
A:/DCIM/109CANON/IMG_2412.JPG not found.
Two burst pictures...
Ideally, the camera should be in some continuous shooting mode (not checked).
A:/DCIM/109CANON/ABC_2413.CR2: 21029918
A:/DCIM/109CANON/ABC_2413.JPG not found.
A:/DCIM/109CANON/ABC_2414.CR2: 21038890
A:/DCIM/109CANON/ABC_2414.JPG not found.
Bracketed pictures...
A:/DCIM/109CANON/IMG_2415.CR2: 18218930
A:/DCIM/109CANON/IMG_2415.JPG not found.
A:/DCIM/109CANON/IMG_2416.CR2: 20825360
A:/DCIM/109CANON/IMG_2416.JPG not found.
A:/DCIM/109CANON/IMG_2417.CR2: 21973768
A:/DCIM/109CANON/IMG_2417.JPG not found.
Bulb picture...
Elapsed time: 11847
A:/DCIM/109CANON/IMG_2418.CR2: 12013692
A:/DCIM/109CANON/IMG_2418.JPG not found.
Picture taking tests completed.

Testing multitasking...
Only one task allowed to interrupt...
Main task yielding.
Task C started.
Task C finished.
Main task back.
Main task yielding.
Task C started.
Task C finished.
Main task back.
Main task yielding.
Task C started.
Task C finished.
Main task back.
Main task yielding.
Task C started.
Task C finished.
Main task back.
Main task yielding.
Task C started.
Task C finished.
Main task back.
Main task yielding.
Task C started.
Task C finished.
Main task back.
Main task yielding.
Task C started.
Task C finished.
Main task back.
Main task yielding.
Task C started.
Task C finished.
Main task back.
Main task yielding.
Task C started.
Task C finished.
Main task back.
Main task yielding.
Task C started.
Task C finished.
Main task back.
Multitasking tests completed.

Testing half-shutter...
warning: last key not half-shutter, but 20
warning: last key not half-shutter, but 20
warning: last key not half-shutter, but 20
warning: last key not half-shutter, but 20
warning: last key not half-shutter, but 20
warning: last key not half-shutter, but 20
warning: last key not half-shutter, but 20
warning: last key not half-shutter, but 20
warning: last key not half-shutter, but 20
warning: last key not half-shutter, but 20
Half-shutter test OK.

Testing module 'lv'...
Starting LiveView...

ML/SCRIPTS/API_TEST.LUA:1246: assertion failed!
stack traceback:
[C]: in function 'globals.assert'
ML/SCRIPTS/API_TEST.LUA:1246: in function 'globals.test_lv'
ML/SCRIPTS/API_TEST.LUA:1578: in function <ML/SCRIPTS/API_TEST.LUA:1564>
[C]: in function 'globals.xpcall'
ML/SCRIPTS/API_TEST.LUA:1564: in function 'globals.api_tests'
ML/SCRIPTS/API_TEST.LUA:1603: in main chunk


Starting from test_lens_focus():

===============================================================================
ML/SCRIPTS/API_TEST.LUA - 2019-4-19 17:15:26
===============================================================================

Module tests...

Testing lens focus functionality...
Autofocus outside LiveView...
Focus distance: 0
Autofocus in LiveView...
Is there something to focus on?
29...28...27...26...Please trigger autofocus (half-shutter / AF-ON / * ).
59...58...57...56...55...54...53...52...51...50...49...48...Autofocus triggered.
Autofocus completed.
Focus distance: 0
Focusing backward...

Here autofocus can't be triggered with Half-Shutter, I used AF-ON.
Script was running in an infinite loop and Lens AF was stuck trying go over infinity

Only test_camera_exposure() and test_movie():

===============================================================================
ML/SCRIPTS/API_TEST.LUA - 2019-4-19 17:21:42
===============================================================================

Module tests...
Testing exposure settings...
Camera    : Canon EOS 50D (50D) 1.0.9
Lens      : 17-50mm
Shoot mode: 3
Shutter   : �5 (raw 75, 0.192776s, 193ms, apex 2.375)
Aperture  : �2.8 (raw 32, f/2.8, apex 3.)
Av range  : �2.8..�32 (raw 32..88, f/2.8..f/32, apex 3...10.)
ISO       : �1600 (raw 104, 1600, apex 9.)
EC        : 0.0 (raw 0, 0 EV)
Flash EC  : 0.0 (raw 0, 0 EV)
Setting shutter to random values...
Setting ISO to random values...
Setting aperture to random values...
Please switch to Av mode.
Setting EC to random values...
Setting Flash EC to random values...
Exposure tests completed.


Testing movie recording...
Please switch to Movie mode.

ML/SCRIPTS/API_TEST.LUA:1550: assertion failed!
stack traceback:
[C]: in function 'assert'
ML/SCRIPTS/API_TEST.LUA:1550: in function 'test_movie'
ML/SCRIPTS/API_TEST.LUA:1581: in function <ML/SCRIPTS/API_TEST.LUA:1564>
[C]: in function 'xpcall'
ML/SCRIPTS/API_TEST.LUA:1564: in function 'api_tests'
ML/SCRIPTS/API_TEST.LUA:1603: in main chunk

Movie record (no raw and record key not set in ML menu) stopped automatically and then assertion was triggered.
Blue Led was ON but went OFF when switching back to photo mode and camera powered down normally.

Running test_lens_focus() in nightly Jul03-18:

===============================================================================
ML/SCRIPTS/API_TEST.LUA - 2019-4-19 17:45:18
===============================================================================

Module tests...
Focus distance: 0
Focusing backward...
Focus distance: 0
Focusing forward with step size 3, wait=true...
......................
Focus distance: 0
Focusing backward with step size 3, wait=true...
.....
Focus distance: 0
Focus range: 22 steps forward, 5 steps backward.
Focusing forward with step size 3, wait=false...
......
Focus distance: 0
Focusing backward with step size 3, wait=false...
.....
Focus distance: 0
Focus range: 6 steps forward, 5 steps backward.
Focusing forward with step size 2, wait=true...
...........................................
Focus distance: 0
Focusing backward with step size 2, wait=true...
.....
Focus distance: 0

Camera shutdown automatically after AF test went back and forth up to Soft Autofocus limits

All test up to  test_io():

===============================================================================
ML/SCRIPTS/API_TEST.LUA - 2019-4-19 17:57:11
===============================================================================

Strict mode tests...
Strict mode tests passed.

Generic tests...
camera = table:
  shutter = table:
    raw = 0
    apex = -7.
    ms = 0
    value = 0
  aperture = table:
    raw = 32
    apex = 3.
    value = 2.799999
    min = table:
      raw = 32
      apex = 3.
      value = 2.799999
    max = table:
      raw = 88
      apex = 10
      value = 32
  iso = table:
    raw = 104
    apex = 9
    value = 1600
  ec = table:
    raw = -3
    value = -0.375
  flash_ec = table:
    raw = 0
    value = 0
  kelvin = 5500
  mode = 2
  metering_mode = 3
  drive_mode = 0
  model = "Canon EOS 50D"
  model_short = "50D"
  firmware = "1.0.9"
  temperature = 158
  state = 0
  bulb = function: p
  shoot = function: p
  reboot = function: p
event = table:
  pre_shoot = nil
  post_shoot = nil
  shoot_task = nil
  seconds_clock = nil
  keypress = nil
  custom_picture_taking = nil
  intervalometer = nil
  config_save = nil
console = table:
  write = function: p
  clear = function: p
  hide = function: p
  show = function: p
lv = table:
  enabled = false
  paused = false
  running = false
  zoom = 1
  stop = function: p
  pause = function: p
  wait = function: p
  info = function: p
  start = function: p
  resume = function: p
lens = table:
  name = "17-50mm"
  focal_length = 0
  focus_distance = 14080
  hyperfocal = 0
  dof_near = 0
  dof_far = 0
  af = true
  af_mode = 0
  focus = function: p
display = table:
  idle = true
  height = 480
  width = 720
  line = function: p
  clear = function: p
  circle = function: p
  on = function: p
  screenshot = function: p
  rect = function: p
  pixel = function: p
  notify_box = function: p
  draw = function: p
  print = function: p
  load = function: p
  off = function: p
key = table:
  last = 0
  press = function: p
  wait = function: p
menu = table:
  visible = false
  new = function: p
  set = function: p
  block = function: p
  close = function: p
  get = function: p
  open = function: p
testmenu = userdata:
  value = 0
  name = "Script API tests"
  help = "Various tests for the Lua scripting API."
  help2 = "When adding new Lua APIs, tests for them should go here."
  advanced = 0
  depends_on = 0
  edit_mode = 0
  hidden = false
  icon_type = 5
  jhidden = false
  max = 0
  min = 0
  selected = true
  shidden = false
  starred = false
  submenu_height = 0
  submenu_width = 0
  unit = 0
  works_best_in = 0
  run_in_separate_task = 0
  select = function: p
  update = nil
  info = nil
  rinfo = nil
  warning = nil
movie = table:
  recording = false
  start = function: p
  stop = function: p
dryos = table:
  clock = 18
  ms_clock = 18579
  prefix = "IMG_"
  dcim_dir = table:
    exists = true
    create = function: p
    children = function: p
    files = function: p
    parent = table:
      exists = true
      create = function: p
      children = function: p
      files = function: p
      parent = table:
        exists = true
        create = function: p
        children = function: p
        files = function: p
        parent = nil
        path = "A:/"
      path = "A:/DCIM/"
    path = "A:/DCIM/109CANON/"
  config_dir = table:
    exists = true
    create = function: p
    children = function: p
    files = function: p
    parent = table:
      exists = true
      create = function: p
      children = function: p
      files = function: p
      parent = table:
        exists = true
        create = function: p
        children = function: p
        files = function: p
        parent = nil
        path = "A:/"
      path = "ML/"
    path = "ML/SETTINGS/"
  ml_card = table:
    cluster_size = 4096
    drive_letter = "A"
    file_number = 2419
    folder_number = 109
    free_space = 1052512
    type = "CF"
    _card_ptr = userdata
    path = "A:/"
  shooting_card = table:
    cluster_size = 4096
    drive_letter = "A"
    file_number = 2419
    folder_number = 109
    free_space = 1052512
    type = "CF"
    _card_ptr = userdata
    path = "A:/"
  date = table:
    wday = 3
    month = 4
    day = 19
    isdst = false
    min = 57
    hour = 17
    sec = 14
    yday = 1
    year = 2019
  directory = function: p
  call = function: p
  remove = function: p
interval = table:
  time = 10
  count = 0
  running = 0
  stop = function: p
battery = table:
function not available on this camera
stack traceback:
[C]: in ?
[C]: in for iterator 'for iterator'
ML/SCRIPTS/LIB/logger.lua:125: in function 'logger.serialize'
ML/SCRIPTS/API_TEST.LUA:30: in function <ML/SCRIPTS/API_TEST.LUA:29>
[C]: in function 'xpcall'
ML/SCRIPTS/API_TEST.LUA:29: in function 'print_table'
ML/SCRIPTS/API_TEST.LUA:75: in function 'generic_tests'
ML/SCRIPTS/API_TEST.LUA:634: in function 'api_tests'task = table:
  create = function: p
  yield = function: p
property = table:
Generic tests completed.

Module tests...
Copy test: autoexec.bin -> tmp.bin
Copy test OK
Append test: tmp.txt
Append test OK
Done!

a1ex

Quote from: aprofiti on April 19, 2019, 05:48:24 PM
What do you do exacly?

It freezes whenever I turn off the camera (no matter how - from power switch or from card/battery doors). Repeatable. Default settings, no modules loaded.

QuoteML/SCRIPTS/API_TEST.LUA:1550: assertion failed!

That line of code should not execute on 50D; maybe the test contains a typo or something? I did not test that change (388e84b, included in the December 23 build, reply #438).

Quote from: aprofiti on April 19, 2019, 05:48:24 PM
Camera Locks, battery pull required.

Running with test_io() disabled [...]

The I/O test appears to be working in QEMU...

Testing file I/O...
Copy test: autoexec.bin -> tmp.bin
Copy test OK
Append test: tmp.txt
Append test OK
Rename test: apple.txt -> banana.txt
Rename test OK
Rename test: apple.txt -> ML/banana.txt
Rename test OK
CF card (A:/) present
- free space: 212 MiB
- next image: A:/DCIM/100CANON/IMG_3429.CR2
- DCIM dir. : A:/DCIM/100CANON/
- A:/DCIM/
  - A:/DCIM/EOSMISC/
  - A:/DCIM/100CANON/
- A:/MISC/
- A:/ML/
  - A:/ML/MODULES/
...
- A:/AUTOEXEC.BIN
- A:/ML-SETUP.FIR
File I/O tests completed.


Quote
Script was running in an infinite loop and Lens AF was stuck trying go over infinity

Yes, this is what I was afraid it might happen, with the new heuristics.

This part of the test appeared to work, to some extent, in unified, so... it's a regression.

While it's stuck trying to focus over infinity, are there "Lens moving" messages on the console? These are not logged; they are just printed. If yes, can you show me a few values? (a screenshot would be fine)

aprofiti

Quote from: a1ex on April 19, 2019, 06:11:00 PM
It freezes whenever I turn off the camera (no matter how - from power switch or from card/battery doors). Repeatable. Default settings, no modules loaded.
No problems over here

Quote from: a1ex on April 19, 2019, 06:11:00 PM
That line of code should not execute on 50D; maybe the test contains a typo or something? I did not test that change (it was in the December 23 build, reply #438).
Yes is a typo. Test runs fine if I change the string.
From test logs:

camera = table:
  model = "Canon EOS 50D"
  model_short = "50D"


Quote from: a1ex on April 19, 2019, 06:11:00 PM
This part of the test appeared to work, to some extent, in unified, so... it's a regression.
Don't understand why camera shutdown immediatly during the test.
This appen also with an older unified build (Feb04-18), I don't remember if this was an issue with older build than these ones

Quote from: a1ex on April 19, 2019, 06:11:00 PM
While it's stuck trying to focus over infinity, are there "Lens moving" messages on the console? These are not logged; they are just printed. If yes, can you show me a few values? (a screenshot would be fine)
Yes a lot of them... Even if I manually move the autofocus ring in the opposite direction, some hits and then agin stuck.
Give me a few minutes to take the sceenshoot

a1ex

Old cameras will shutdown if the delay between focus commands is "too small" (Canon knows what exactly is "too small"). Your test log shows some successful focus commands, though.

If the limit detection (on Canon's side) is relying solely on motor current, lens.focus() will keep trying as long as the motor encoder (lens.focus_pos) shows some movement. If the motor "keeps trying", that might result in some movement (back and forth) at the focus limits (either macro or infinity), but lens.focus() will think the lens is still moving. That's the edge case I wanted to check, and I know for sure the 50mm/1.8 II has no limit switches; it only looks at the motor current. If user would stop the focus ring forcefully, ML would show the same error, i.e. "Focus: soft limit reached".

If the "Lens moving" messages are showing numbers with sign changing all the time (i.e. showing the encoder going back and forth), I should update the heuristic to interpret that sign change as "focus limit reached".

aprofiti

Autofocusing works in the tfirst stage (before pressing AF-ON) and then first second of the second stage, then reach infinity and get stuck



a1ex

That 1000 (a status bit) is what I interpret as "error". The odd part is - why does it always show movement in the same (positive) direction?!

If you enable Follow Focus (without loading the Lua module) and try to move the focus with the joystick, does that work? Similar messages on the console?

aprofiti

Quote from: a1ex on April 19, 2019, 06:59:11 PM
If you enable Follow Focus (without loading the Lua module) and try to move the focus with the joystick, does that work? Similar messages on the console?
Yes similiar messages.



Positive values with left direction (infinity) and negative in the opposite (macro); also 1000 pop off immediatly when limit is reached, but stuck message after some tryes

a1ex

Interesting.

Is the motor still trying to move after reaching the limit? The first number (encoder delta) from the "Lens moving" message shows it might be. Or maybe the encoder value (as reported by this lens) is simply bogus?

aprofiti

It still try to move over the limits, but first it goes back a little bit and then change again in the selected direction...
Also the motor make a different noise than normal

a1ex

Understood. The lens firmware might be counting the encoder steps only when power is applied (i.e. when actively trying, not when it goes back after the motor stops).

BTW, this investigation was for solving this issue. The current heuristics from lua_fix appear to do the trick, at the expense of working only with "new" lenses (my only AF lens is 24mm/2.8 STM).

rabarar

Is there a LiveView lua script to prevent the LiveView from timing out on 5d2? I am trying to use an external HDMI recording and the timeout after a minute is less than optimal. I tried a simple Lua script mentioned in the forum but that left the script running in an infinite loop overlaying on the screen making the video useless. Thoughts?

Danne

Possibly asked and explained before but I can´t find any info.
Question around reboot and boot function in ml. Can it be controlled in lua in such a way that we can delay a reboot process? Reason being it would save up on battery.
Been messing with this lately https://www.magiclantern.fm/forum/index.php?topic=9741.msg223238#msg223238 and battery drains of course and if I would like to for example do a two day timelapse I have to have camera turned on for the whole job but what if reboot process could be delayed early in boot process?
In lua_camera.c:
/***
Restart the camera.
@function reboot
*/
static int luaCB_camera_reboot(lua_State * L)
{
    int reboot = 0;
    prop_request_change(PROP_REBOOT, &reboot, 4);
    return 0;

    /* shutdown is probably done in a similar way, but I had no success with nearby properties */
}

Reboot is called with this in lua camera.reboot() if I´m correct.

So before I try something shitty and soft brick my eosm for the third time I would simply know if it´s something to even consider  :D 8). Hopefully @a1ex or ©dmilligan checks in here or anyone else with some knowledge around this.

Full shut down not possible yet if this is correct?
/* shutdown is probably done in a similar way, but I had no success with nearby properties */

Walter Schulz

Not the answer you are looking for ...
- use an external power supply with sufficient capacity

I dream of making use of cam's internal watchdog timers ... but - as a1ex mentions frequently - we don't know that much about cam's DSP.

a1ex

Not possible to program a timed reboot, to my knowledge. Assuming you are looking for something like the "deep sleep" mode in ESP8266.

The lowest-power mode, to my knowledge, is outside LiveView (e.g. in PLAY mode), with display turned off, and then: call("EnablePowerSave"). The last item, after you turn off the display, will probably cut the power draw in half, but not much more. With display on, it probably won't make much of a difference. Some numbers here (measurements done several years ago).

In that power saving state, msleep is not going to work any more (it will sleep indefinitely afaik, or until the CPU wakes up for some reason). You could probably hope for some interrupt to wake up DryOS every now and then, and that's when you might be able to check the real-time clock. I didn't explore it, as it interferes with the regular intervalometer and all other ML functions that use polling. And since it didn't seem to make much of a difference (IMO), it was much easier to just turn off this kind of powersaving globally.

This might be a good use case for reprogramming the MPU (hard, possibly risky), or for a hardware mod that would wake up the camera every now and then (such as, once every 10 minutes or whatever). The idea of having enough battery power for a 24-hour timelapse is quite tempting, but these options are not exactly straightforward.

Another "simple" optimization: since LiveView itself draws much more power, compared to e.g. PLAY mode, so it might be worth trying to record one frame as soon possible after entering LiveView (possibly before the screen even turns on), and to close LiveView right away, before the frame is saved to card.

You may consider the "classic" full-res silent picture + regular intervalometer; that one operates outside LiveView, with display turned off whenever possible, but without the CPU powersaving. That should give you a rough idea of what to expect, regarding battery life. On cameras with LP-E6 batteries, you even get a real-time battery estimation during the timelapse, on top of the image review (if you enable it in Canon menu). Even so, one battery is not going to last 24 hours, at least not on DIGIC 4/5 cameras.

See also this topic for an even longer answer.

Danne

So no "prolonged" reboot hack that I missed  :P.
Useful information and since I approached this from movie mode(mainly for convenience reasons) I could now benefit from working the full res silent picture  angle. Might have some tinkering time again over xmas.
Thanks for sharing links and info.

mrducksworth

I installed the lua_fix branch because I'm trying to stream on OBS and wanted the 30 minute timer fix for LiveView.

However I can't seem to be able to change ISO and Shutterspeed using my camera buttons or the menu. On the menu it changes, but the hdmi output doesn't change. I set ISO to a number instead of of AUTO. Do I need to turn off auto exposure somewhere else? Are button defaults different on the lua_fix branch? Hmm actually whilst writing this, liveview turned off and I turned it back on, and it would let me do ISO with the button, but I can see ML smooth exposure.

Walter Schulz

You are off-topic. This is "Scripting Corner" related to Lua scripting language.

By default ML doesn't change button defaults other than trashcan.
If you haven't found out how to handle your issue you might want to do a follow-up. Please mention your camera type.

30-minute timer setting: Prefs tab/screen -> PowerSave in LiveView -> 30-minute timer Disabled
Expo settings: Expo tab/screen -> ExpSim OFF

FTP

Quote from: Walter Schulz on March 17, 2021, 10:25:15 AM
You are off-topic. This is "Scripting Corner" related to Lua scripting language.
Well... I can understand why he ended up here. Maybe you should update this link attached to Lua_fix builds in general or create a dedicated topic/space for Lua_fix builds discussion...  ::)


Latest Lua updates + fixes (please review)
Latest Lua updates (details).
Includes many other backend changes, e.g. focus, menu, Q button handling, fonts etc.
Therefore, it's important to give it a good try on all functions, not just Lua, so we can include it in the nightly builds.
Also includes lens.focus_pos and dynamic-my-menu.
-> Forum discussion

https://builds.magiclantern.fm/experiments.html