root/trunk/CHDK/SCRIPTS/TEST/romlog.lua

Revision 997, 1.5 KB (checked in by pixeldoc2000, 18 months ago)

romlog.lua updated to support DryOS rel 43 and later (SystemEventInit? isn't supported anymore)

Line 
1--[[
2@title save ROM crash log to ROMLOG.LOG
3requires CHDK built with native function call support
4@param a remove old files 1=yes, 0=no
5@default a 1
6--]]
7
8LOG_NAME="A/ROMLOG.LOG"
9ERR_NAME="A/RomLogErr.txt"
10
11function printf(...)
12    print(string.format(...))
13end
14
15if (type(call_event_proc) ~= "function") then
16    error("ERROR: your CHDK does not support native function calls")
17end
18
19if (call_event_proc("SystemEventInit") == -1) then
20    -- Newest cams (DryOS rel 43 and later) only have System.Create()
21    -- on older dryos cams SystemEventInit is an alias for System.Create()
22    if (call_event_proc("System.Create") == -1) then
23        error("ERROR: SystemEventInit and System.Create failed")
24    end
25end
26
27if a ~= 0 then
28    if (os.stat(LOG_NAME)) then
29        printf("rm %s: %s",LOG_NAME,tostring(os.remove(LOG_NAME)));
30    end
31    if (os.stat(ERR_NAME)) then
32        printf("rm %s: %s",ERR_NAME,tostring(os.remove(ERR_NAME)));
33    end
34end
35
36-- first arg: filename, NULL for ROMLOG.TXT (dryos) or ROMLOG (vxworks)
37-- second arg: if 0, shutdown camera after writing log
38-- note, on vxworks the exception code, registers and stack trace are binary
39r=call_event_proc("GetLogToFile",LOG_NAME,1)
40
41if r ~= 0 then
42    printf("GetLogToFile return %d",r)
43end
44
45if (os.stat(ERR_NAME)) then
46    if a ~= 0 then
47        printf("FAIL check %s",ERR_NAME)
48    else
49        printf("%s exists",ERR_NAME)
50    end
51end
52
53if (os.stat(LOG_NAME)) then
54    printf("%s exists",LOG_NAME)
55else
56    printf("%s not written",LOG_NAME)
57end
58
59sleep(2000)
Note: See TracBrowser for help on using the browser.