I kept going over and over the stubs and it seemed like they were correct. One thing I did to make it easier to find in the disassembly was to write some of them like this:
#define CURRENT_GUI_MODE (*(int*)(0x92860+0x5C)) // in SetGUIRequestMode
This shouldn't make a difference but it allowed the lua test to complete instead of getting stuck when it tried to switch to LiveView.
#define CURRENT_GUI_MODE (*(int*)0x928BC) // in SetGUIRequestMode (0x92860+0x5C)
Here is the first complete lua api test:
===============================================================================
ML/SCRIPTS/API_TEST.LUA - 2018-2-6 11:20:00
===============================================================================
Strict mode tests...
Strict mode tests passed.
Generic tests...
camera = table:
shutter = table:
raw = 96
apex = 5
ms = 31
value = 0.03125
aperture = table:
raw = 40
apex = 4
value = 4
min = table:
raw = 24
apex = 2
value = 2
max = table:
raw = 80
apex = 9
value = 22.6
iso = table:
raw = 72
apex = 5
value = 100
ec = table:
raw = 0
value = 0
flash_ec = table:
raw = 0
value = 0
kelvin = 6500
mode = 20
metering_mode = 5
drive_mode = 0
model = "Canon EOS M2"
model_short = "EOSM2"
firmware = "1.0.3"
temperature = 196
state = 0
shoot = function: p
bulb = 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
hide = function: p
clear = function: p
show = function: p
lv = table:
enabled = true
paused = false
running = true
zoom = 1
pause = function: p
stop = function: p
start = function: p
resume = function: p
wait = function: p
info = function: p
lens = table:
name = "EF-M22mm f/2 STM"
focal_length = 22
focus_distance = 190
hyperfocal = 6412
dof_near = 186
dof_far = 193
af = true
af_mode = 0
focus = function: p
display = table:
idle = false
height = 480
width = 720
line = function: p
circle = function: p
on = function: p
off = function: p
load = function: p
clear = function: p
notify_box = function: p
rect = function: p
draw = function: p
pixel = function: p
screenshot = function: p
print = function: p
key = table:
last = 0
press = function: p
wait = function: p
menu = table:
visible = false
new = function: p
block = function: p
set = function: p
open = function: p
get = function: p
close = 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 = 20
ms_clock = 20650
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 = "B:/"
path = "B:/DCIM/"
path = "B:/DCIM/100CANON/"
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 = "B:/"
path = "ML/"
path = "ML/SETTINGS/"
ml_card = table:
cluster_size = 32768
drive_letter = "B"
file_number = 7211
folder_number = 100
free_space = 31112864
type = "SD"
_card_ptr = userdata
path = "B:/"
shooting_card = table:
cluster_size = 32768
drive_letter = "B"
file_number = 7211
folder_number = 100
free_space = 31112864
type = "SD"
_card_ptr = userdata
path = "B:/"
date = table:
sec = 2
min = 20
month = 2
yday = 37
isdst = false
hour = 11
day = 6
year = 2018
wday = 3
call = function: p
remove = function: p
directory = 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 M2 (EOSM2) 1.0.3
Lens : EF-M22mm f/2 STM
Shoot mode: 20
Shutter : Ç30 (raw 96, 0.03125s, 31ms, apex 5)
Aperture : Å4.0 (raw 40, f/4, apex 4)
Av range : Å2.0..Å22 (raw 24..80, f/2..f/22.6, apex 2..9)
ISO : 100 (raw 72, 100, apex 5)
EC : 0.0 (raw 0, 0 EV)
Flash EC : 0.0 (raw 0, 0 EV)
Please switch to M mode.
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 module 'lv'...
Starting LiveView...
Setting zoom to x1...
Setting zoom to x5...
Setting zoom to x10...
Setting zoom to x5...
Setting zoom to x1...
Setting zoom to x10...
Setting zoom to x1...
Pausing LiveView...
Resuming LiveView...
Stopping LiveView...
LiveView tests completed.
Focus distance: 170
Focusing backward...
Focus distance: 655350
Focusing forward with step size 3, wait=true...
...
Focus distance: 140
Focusing backward with step size 3, wait=true...
................
Focus distance: 655350
Focus range: 173 steps forward, 16 steps backward.
Focusing forward with step size 3, wait=false...
...
Focus distance: 655350
Focusing backward with step size 3, wait=false...
Focus distance: 655350
Focus range: 3 steps forward, 0 steps backward.
Focusing forward with step size 2, wait=true...
Focus distance: 655350
Focusing backward with step size 2, wait=true...
Focus distance: 655350
Focus range: 0 steps forward, 0 steps backward.
Focusing forward with step size 2, wait=false...
Focus distance: 655350
Focusing backward with step size 2, wait=false...
Focus distance: 655350
Focus range: 0 steps forward, 0 steps backward.
Focusing forward with step size 1, wait=true...
Focus distance: 655350
Focusing backward with step size 1, wait=true...
Focus distance: 655350
Focus range: 0 steps forward, 0 steps backward.
Focusing forward with step size 1, wait=false...
Focus distance: 655350
Focusing backward with step size 1, wait=false...
Focus distance: 655350
Focus range: 0 steps forward, 0 steps backward.
Focus test completed.
Done!