| 1 | --[[ |
|---|
| 2 | @title save ROM crash log to ROMLOG.LOG |
|---|
| 3 | requires CHDK built with native function call support |
|---|
| 4 | @param a remove old files 1=yes, 0=no |
|---|
| 5 | @default a 1 |
|---|
| 6 | --]] |
|---|
| 7 | |
|---|
| 8 | LOG_NAME="A/ROMLOG.LOG" |
|---|
| 9 | ERR_NAME="A/RomLogErr.txt" |
|---|
| 10 | |
|---|
| 11 | function printf(...) |
|---|
| 12 | print(string.format(...)) |
|---|
| 13 | end |
|---|
| 14 | |
|---|
| 15 | if (type(call_event_proc) ~= "function") then |
|---|
| 16 | error("ERROR: your CHDK does not support native function calls") |
|---|
| 17 | end |
|---|
| 18 | |
|---|
| 19 | if (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 |
|---|
| 25 | end |
|---|
| 26 | |
|---|
| 27 | if 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 |
|---|
| 34 | end |
|---|
| 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 |
|---|
| 39 | r=call_event_proc("GetLogToFile",LOG_NAME,1) |
|---|
| 40 | |
|---|
| 41 | if r ~= 0 then |
|---|
| 42 | printf("GetLogToFile return %d",r) |
|---|
| 43 | end |
|---|
| 44 | |
|---|
| 45 | if (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 |
|---|
| 51 | end |
|---|
| 52 | |
|---|
| 53 | if (os.stat(LOG_NAME)) then |
|---|
| 54 | printf("%s exists",LOG_NAME) |
|---|
| 55 | else |
|---|
| 56 | printf("%s not written",LOG_NAME) |
|---|
| 57 | end |
|---|
| 58 | |
|---|
| 59 | sleep(2000) |
|---|