CHDK PTP interface

  • 1136 Replies
  • 147297 Views
  • Publish
    Re: CHDK PTP interface
    « Reply #420 on: 18 / February / 2011, 16:15:34 »
    Advertisements
    Hi all, sorry for the interruption. I am very new to PTP extension and I am trying to get my computer to control the camera A710IS. Right now I have the lastest build from CHDKDE and loaded onto my SD card, but when I try to issue the command "ptpcam.exe --chdk" in windows console, it says "Could not find any device matching given bus/dev numbers, retrying in 1 s...". It seems that somehow the connection is not setup between my computer and the camera. Can someone tell me which part I did it wrong?
    Thanks
    JL

    I just posted a new thread about the questions I have, so please ignore above. Thanks
    JL
    « Last Edit: 19 / February / 2011, 20:00:28 by mirriro »

  • Publish
    Re: CHDK PTP interface
    « Reply #421 on: 21 / February / 2011, 12:02:17 »
    I test newest ptpcamgui with image download button, Ixus 1000 seem crash when write ptpgui.txt. File is then 0 byte in size.
    This happen only when exmem is enable.
    I do a test to limit buffer, in ptp.c

    buf_size= 4096; //core_get_free_memory()>>1;

    but this does not help.
    have somebody test with exmem enable.does it work or not ?

    when exmem is not enable, then i get transfer rate in raw around 2  megabyte.
    The card can read 12 megabyte.

    Is there no way that transfer can be faster ?
    what other camera get for transfer rate.

    EDIT:

    Problem solved, i have in wrappers.c static char de[50];
    because i want try smaller.

    this was too small.i use 100 again and it work stable

    void* readdir(void *d) {
    # if !CAM_DRYOS
        return _readdir(d);
    #else
    // for DRYOS cameras  A650, A720  do something with this!  - sizeof(de[]) must be >= sizeof(struct dirent): 'static char de[40];'
      static char de[100];
      _ReadFastDir(d, &de);
      return de[0]? &de : (void*)0;
    #endif
    }
    « Last Edit: 22 / February / 2011, 14:17:54 by Bernd R »
    Ixus 1000 HS

  • Publish
    Re: CHDK PTP interface
    « Reply #422 on: 26 / February / 2011, 05:01:08 »
    I do now some more test with the non working switch to record mode on my Ixus 1000 HS.

    I add in wrapper.c when should switch to record mode a keyb_stopusb = 1 in a global variable that is access from keyboard task too.
    This tell the keyboard task  my_kbd_read_keys() function that it should do action.

    This code work, without crash and switch to record mode, but when the time is over to clear the USB bit, then the Camera move in Lens and go to playback mode.

      if ((keyb_stopusb >= 1) && (keyb_stopusb <= 399)){physw_status[2] = physw_status[2] & ~(SD_READONLY_FLAG | USB_MASK);

    when i remove this line

      if ((keyb_stopusb >= 1) && (keyb_stopusb <= 399)){physw_status[2] = physw_status[2] & ~(SD_READONLY_FLAG | USB_MASK);

    complete, then crash happen, same as original Code.

    if(keyb_stopusb == 50).....

    is need because the USB bit need clear earlier or mode switch do nothing.

    Code: [Select]

    void my_kbd_read_keys() {

    ......

    if(keyb_stopusb == 400){keyb_stopusb = 0;}
        if (keyb_stopusb == 1){
            sprintf(osd_buf, "want switch");
            draw_txt_string(28, 14,osd_buf, conf.osd_color);
            physw_status[2] = physw_status[2] & ~(SD_READONLY_FLAG | USB_MASK);
        }
        if (keyb_stopusb == 50){ _set_control_event(0x902);_PB2Rec();
         sprintf(osd_buf, "call _PB2Rec");
            draw_txt_string(28, 14,osd_buf, conf.osd_color);}
        if ((keyb_stopusb >= 1) && (keyb_stopusb <= 399)){physw_status[2] = physw_status[2] & ~(SD_READONLY_FLAG | USB_MASK);

        }
        if(keyb_stopusb)keyb_stopusb++;

    really strange wy this Camera crash in fsionotify, look as a task race condition.same errors IX1000 get on boot without msleep fix , or when call mkdir on second RAW shoot.

     
    i get only in mind maybe something with this code is wrong, but how is it possible to see if the values are correct ?

     *(int*)0x1938=(int)taskHook;   //was 1934 in sx200 if 1938 hangs
       *(int*)0x193C=(int)taskHook;

    Can somebody please explain more what this should do, and how i can verify if ox1938 0x193c is really the correct value ?
    « Last Edit: 26 / February / 2011, 05:04:28 by Bernd R »
    Ixus 1000 HS

    *

    Offline achillies

    • ***
    • 227
    • SX130IS
  • Publish
    Re: CHDK PTP interface
    « Reply #423 on: 03 / March / 2011, 22:27:54 »
    I am trying to modify PTPCamGUI (simply changing ptpcamgui.au3) to allow for deleting of files after transfer.  I have added a checkbox which when checked deletes the files you are transferring to your computer.  I have tested it with all of the download options (all, new, number of pics), and because it works from the same file list as downloading, shouldn't interfere with anything.. BUT it does reboot the camera to accurately reflect the current number of pictures.  If checked you will also get the "Download and Delete these files now" confirmation/cancel dialog.  

    Also, I was having trouble with the timelapse "STOP" button not really stopping anything but ptpcamgui.  I changed some lines and fixed that too. (at least for myself!)  I'm using an SX130IS, and everything works like a charm!

    As of build #82, the line numbers in this text file were accurate to make changes in the ptpcamgui.au3 and ptpcamgui_obfuscated.au3 files, but the notation is written so that I understand it.  If you try to use this file, I hope you can figure it out.  
     EDIT Attachment removed to avoid confusion
    « Last Edit: 19 / March / 2011, 16:28:37 by achillies »
    Don't let the sands of time get in your lunch.


    *

    Offline rudi

    • ***
    • 123
    • A590IS_101B, SX260HS_100B
  • Publish
    Re: CHDK PTP interface
    « Reply #424 on: 04 / March / 2011, 14:55:55 »
    Hi

    I noticed what I think is a typing error around line 1260
    '  if fd~=nli and #fd>0 then' & @LF & _
    I think should be '  if fd~=nil and #fd>0 then' & @LF & _
    Yes, that's true. I've change in ptpcamGUI rev.#80. Thanks achillies!

    Usually, I write the routine for new feature at first and chage then the GUI. Sorry, but delete files on cam is not the topmost feature for implement in moment.

    an other theme: "table results with ptpcam.exe"
    I provide a solution for return results from simple lua-tables with ptpcam. The most tables have one or two dimensions. My code convert tables to a formatted string for retrieve.

    Code: [Select]
    format: key 1st dimension \t value or values 2nd dimension sparated by \t and \n

    values for 1st dimension: BOOL, INT, STRING (NIL is not enumerated)
    values for 2nd dimension: NIL, BOOL, INT, STRING

    same examples:
    Code: [Select]
    <conn> luar get_buildinfo()
    platformid      12662
    platform        a590
    version CHDK
    platsub 101b
    build_number    0.9.9-1077
    os      dryos
    build_date      Mar  4 2011
    build_time      19:08:04

    <conn> luar {1,2,3,4}
    1       1
    2       2
    3       3
    4       4

    <conn> luar {X=44,G=2}
    G       2
    X       44

    <conn> luar {"Monday","Tuesday","Wednesday","Thursday","Friday"}
    1       Monday
    2       Tuesday
    3       Wednesday
    4       Thursday
    5       Friday

    <conn> luar {{3,8,55},G=2}
    1       3       8       55
    G       2

    <conn> luar {{3,8,55}, D={"S","M","D"},G=2,"value",678}
    1       3       8       55
    2       value
    3       678
    G       2
    D       S       M       D

    <conn> luar {U={3,8,55}, D={"S","M","D"},G=2}
    U       3       8       55
    D       S       M       D
    G       2

    <conn> luar {}

    <conn> luar {{},{}}

    <conn> luar {A={},{}}

    <conn> luar {A={},B={}}

    <conn> luar {A={1},B={33}}
    A       1
    B       33

    <conn> luar {A={1,2},B={33}}
    A       1       2
    B       33

    <conn> luar {A={1,2},B={33,{},44}}
    A       1       2
    B       33              44

    <conn> luar {A={1,2,"true",false},B={33,{},44}}
    A       1       2       true    false
    B       33              44

    <conn> luar {A={1,2,true,"false"},B={33,{},44}}
    A       1       2       true    false
    B       33              44

    <conn> luar {3,4,nil,5,6,true,7}
    1       3
    2       4
    4       5
    5       6
    6       true
    7       7

    <conn> luar {{3,4,nil,5,6,true,7}}
    1       3       4       nil     5       6       true    7

    <conn> luar require("capmode")
    mode_to_name    AUTO    P       TV      AV      M       PORTRAIT        NIGHT_SC
    ENE     LANDSCAPE       VIDEO_STD       VIDEO_SPEED     VIDEO_COMPACT   VIDEO_MY
    _COLORS VIDEO_COLOR_ACCENT      VIDEO_COLOR_SWAP        STITCH  MY_COLORS
    SCN_UNDERWATER  SCN_NIGHT_SNAPSHOT      LONG_SHUTTER    SCN_LANDSCAPE   COLOR_SW
    AP      SCN_SNOW        SCN_BEACH       SCN_FIREWORK    SCN_COLOR_ACCENT
    SCN_COLOR_SWAP  VIDEO_HIRES     SCN_AQUARIUM    COLOR_ACCENT    SCN_NIGHT_SCENE
    SCN_ISO_3200    SCN_SPORT       SCN_KIDS_PETS   INDOOR  KIDS_PETS       NIGHT_SN
    APSHOT  DIGITAL_MACRO   SCN_FOLIAGE     VIDEO_TIME_LAPSE        SCN_INDOOR
    SCN_PORTRAIT    SUPER_MACRO     VIDEO_PORTRAIT  VIDEO_NIGHT     VIDEO_INDOOR
    VIDEO_FOLIAGE   VIDEO_SNOW      VIDEO_BEACH     VIDEO_AQUARIUM  VIDEO_SUPER_MACR
    O       VIDEO_STITCH    VIDEO_MANUAL    SPORTS  QUICK   SCN_SUNSET      SCN_CREA
    TIVE_EFFECT     EASY    SCN_DIGITAL_MACRO       SCN_STITCH      SCN_LONG_SHUTTER
            LOWLIGHT        SCN_NOSTALGIC   SCN_SMART_SHUTTER       SCN_LOWLIGHT
    SCN_SUPER_VIVID SCN_POSTER_EFFECT       SCN_FISHEYE     SCN_MINIATURE   SCN_HDR

    I think we can this also use in future get_lua_result implementations. If we can use tables with ptpcam, then we can update ptpcamGUI with more effective code.

    rudi
    « Last Edit: 04 / March / 2011, 14:58:45 by rudi »

    *

    Offline fudgey

    • *****
    • 1705
    • a570is
  • Publish
    Re: CHDK PTP interface
    « Reply #425 on: 05 / March / 2011, 09:48:10 »
    This thing: http://www.akond.net/index.php?issue_id=292 came up in another thread... (http://chdk.setepontos.com/index.php?topic=6180.0).

    From some clues (A480 needs to be a specific fw version, SD card needs to be dealt with some wizard) I'm temped to guess that they didn't get any help from Canon, but are instead selling modified or rewritten CHDK and CHDK PTP.

    "inPhoto ID PS works only with Canon A480, Canon A495, Canon SX200 IS and Canon SX210 IS cameras. Next camera will be Canon SX130 IS."

    http://www.akond.net/?issue_id=262

    *

    Offline reyalp

    • ******
    • 9810
  • Publish
    Re: CHDK PTP interface
    « Reply #426 on: 05 / March / 2011, 22:48:03 »
    an other theme: "table results with ptpcam.exe"
    I provide a solution for return results from simple lua-tables with ptpcam. The most tables have one or two dimensions. My code convert tables to a formatted string for retrieve.
    Good. This is important.

    Some thoughts:
    C code seems complex, could be better to do this in lua. We can have lua code in a C string if we want hardcoded in CHDK.

    Would be good to have a standard library of lua functions to use with PTP somehow. Not sure the best way to do this, loading from SD card every time would be slow, sending over PTP every time not so nice either.

    Format is OK to display values, but it's ambiguous in some cases and quite limited. Doesn't support non-numeric keys in second level table, e.g. {t={a='a',b='b'}}, showing nil in one and not the other is a bit odd.

    OK for now, but I think we'll want to revisit, real work crunch is over for a while.

    My plan was to format table returns as a string of lua code, using lua (but only simple types as you have, and no cyclic references etc.) When the PC side has lua this is very convenient. It's also quite readable on it's own, but maybe not easy to parse in autoit.

    I'll have a little more time to work on CHDK now.

    lua version of table format code. Could be simpler, but I was trying to match output of rudi's code as closely as possible. There are probably some minor differences still
    Code: [Select]
    function t_to_s(t)
    local v2s=function(v)
    local t=type(v)
    if t=='string' then
    return v
    end
    if t=='number' or t=='boolean' or t=='nil' then
    return tostring(v)
    end
    return ""
    end
    local r=""
    for k,v in pairs(t) do
    local s,vs=""
    if type(v)=='table' then
    for i=1,table.maxn(v) do
    s=s..'\t'..v2s(v[i])
    end
    else
    vs=v2s(v)
    if #vs then
    s=s..'\t'..vs
    end
    end
    vs=v2s(k)
    if #vs>0 and #s>0 then
    r=r..vs..s..'\n'
    end
    end
    return r
    end
    test (! is pc side lua in my client)
    Code: [Select]
    ___> !print(t_to_s({1,2,3,4}))
    1       1
    2       2
    3       3
    4       4

    ___> !print(t_to_s({X=44,G=2}))
    G       2
    X       44

    ___> !print(t_to_s({"Monday","Tuesday","Wednesday","Thursday","Friday"}))
    1       Monday
    2       Tuesday
    3       Wednesday
    4       Thursday
    5       Friday

    ___> !print(t_to_s({{3,8,55},G=2}))
    1       3       8       55
    G       2

    ___> !print(t_to_s({{3,8,55}, D={"S","M","D"},G=2,"value",678}))
    1       3       8       55
    2       value
    3       678
    G       2
    D       S       M       D

    ___> !print(t_to_s({U={3,8,55}, D={"S","M","D"},G=2}))
    U       3       8       55
    D       S       M       D
    G       2

    ___> !print(t_to_s({}))

    ___> !print(t_to_s({{},{}}))

    ___> !print(t_to_s({A={},{}}))

    ___> !print(t_to_s({A={},B={}}))

    ___> !print(t_to_s({A={1},B={33}}))
    A       1
    B       33

    ___> !print(t_to_s({A={1,2},B={33}}))
    A       1       2
    B       33

    ___> !print(t_to_s({A={1,2},B={33,{},44}}))
    A       1       2
    B       33              44

    ___> !print(t_to_s({A={1,2,"true",false},B={33,{},44}}))
    A       1       2       true    false
    B       33              44

    ___> !print(t_to_s({A={1,2,true,"false"},B={33,{},44}}))
    A       1       2       true    false
    B       33              44

    ___> !print(t_to_s({3,4,nil,5,6,true,7}))
    1       3
    2       4
    4       5
    5       6
    6       true
    7       7

    ___> !print(t_to_s({{3,4,nil,5,6,true,7}}))
    1       3       4       nil     5       6       true    7
    Don't forget what the H stands for.

    *

    Offline reyalp

    • ******
    • 9810
  • Publish
    Re: CHDK PTP interface
    « Reply #427 on: 06 / March / 2011, 01:01:42 »
    Patch implementing the above. One possible danger, we probably don't want to trigger the call hook sleep from ptp task.

    This danger will go away when I get the alternative luar code done. More on that soon.
    Don't forget what the H stands for.


    *

    Offline reyalp

    • ******
    • 9810
  • Publish
    Re: CHDK PTP interface
    « Reply #428 on: 07 / March / 2011, 00:48:14 »
    I've created a temporary branch for PTP improvements, because it's a bit complicated to keep track of without version control.
    http://tools.assembla.com/chdk/browser/branches/reyalp-ptp

    I intend this branch to a short lived. If no one says this is a horrible idea, it will go into the trunk after a few things are cleaned up. I want to give everyone (especially chdkde / ptpcamgui developers) a chance to comment first.

    This basically merges my earlier ptp script message and result code.

    Highlights:
    - all lua script return values are returned as messages (the way luar adds return(...) doesn't support multiple return so e.g. luar get_mode() will only return the first value, and luar 1,2 fails.)
    - messages from script->pc now have lua types, like old result code. Tables are returned as string, in rudi's format using lua as described in previous post.
    - lua compile and runtime error messages are returned as messages. Return values, script generated messages, and error message are all identified, so the pc software can ignore whatever it isn't interested in.
    - protocol is changed, but ptpcam commands/output are almost 100% compatible.
    - scripts now have a 'process id', returned when you start the script. This allows camera and pc side to discard messages that were from/to a previous script invocation.

    Other stuff
    - ptpcam doesn't take advantage of all the new features, new client will use them.
    - error messages can be lost if queue is full.
    - would probably be better to flush all messages when a new script starts.

    attached patch against chdkde ptpcam source implements pc side.
    attached ptpmsg script demonstrates sending/recieving messages within script.

    some examples
    Code: [Select]
    <conn> lua return get_mode()
    <conn> getm
    false
    false
    513 (201)
    <conn> lua foo()
    <conn> getm
    runtime error: :1: attempt to call global 'foo' (a nil value)
    <conn> lua 'blah
    syntax error: :1: unfinished string near '<eof>'
    execution failed!
    <conn> luar get_mode
    unsupported data type: function

    Don't forget what the H stands for.

    *

    Offline rudi

    • ***
    • 123
    • A590IS_101B, SX260HS_100B
  • Publish
    Re: CHDK PTP interface
    « Reply #429 on: 09 / March / 2011, 13:20:23 »
    Hi reyalp,
    very good work and implementation!
    Now I had some time for tests only with modified ptpcam.exe and reyalp-brunch/modified CHDK-DE (identical results) - my result: great! more informations about states and errors, more result values. On this time 'ptpmsg.lua' untested.

    some comments:
    TEST 'function usb_msg_table_to_string(arg)':
    The function fails is arg not a table.
    Code: [Select]
    <conn> lua return usb_msg_table_to_string(os.stat('A/ptpmsg.lua'))
    <conn> getm
    dev     2
    attrib  32
    ctime   1299672574
    atime   1299628800
    blksize 512
    blocks  6
    mtime   1299585998
    is_file true
    mode    33279
    is_dir  false
    size    2683

    <conn> lua return usb_msg_table_to_string(os.stat('A/ptpmsgB.lua'))
    <conn> getm
    runtime error: :1: bad argument #1 to 'pairs' (table expected, got nil)
    a small change for all types -> attachment
    Code: [Select]
    <conn> lua return usb_msg_table_to_string(os.stat('A/ptpmsgB.lua'))
    <conn> getm
    nil
    A/ptpmsgB.lua: error
    0 (0)

    TEST script id and results:
    Very good idea, but how much results are from current id and how much from script-id 24?
    For example we can use a text 'message' to separate old id from current id?
    Code: [Select]
    <conn> lua return '1'
    <conn> lua return '1\n2'
    <conn> lua return '1\n2\n3'
    <conn> lua return '1\n2\n3\n4'
    <conn> getm
    message from unexpected script id 22
    1
    message from unexpected script id 23
    1
    2
    message from unexpected script id 24
    1
    2
    3
    1
    2
    3
    4

    TEST 'lua return'-commands after CHDK-start/reboot
    It looks like the luar-problem from CHDK-rev.1032 to 1033. My fast solution at that time 'return(...)' in ptpcam.exe. But I know that is not the real cause. Is it back again? Lua initialisation fails?
    Code: [Select]
    <conn> reboot
    Could not find any device matching given bus/dev numbers, retrying in 1 s...
    <conn> lua return usb_msg_table_to_string(get_buildinfo())
    <conn> getm
    runtime error: :1: attempt to call global 'usb_msg_table_to_string' (a nil value
    )
    <conn> lua return usb_msg_table_to_string(get_buildinfo())
    <conn> getm
    platformid      12662
    platform        a590
    version CHDK
    platsub 101b
    build_number    0.9.9-1083
    os      dryos
    build_date      Mar  9 2011
    build_time      12:56:47

    <conn> shutdown
    <    > r
    <conn> lua return usb_msg_table_to_string(get_buildinfo())
    <conn> getm
    runtime error: :1: attempt to call global 'usb_msg_table_to_string' (a nil value
    )
    <conn> lua return usb_msg_table_to_string(get_buildinfo())
    <conn> getm
    platformid      12662
    platform        a590
    version CHDK
    platsub 101b
    build_number    0.9.9-1083
    os      dryos
    build_date      Mar  9 2011
    build_time      12:56:47
    a solution with a dummy-command (type 'lua'+space)
    Code: [Select]
    <conn> reboot
    Could not find any device matching given bus/dev numbers, retrying in 1 s...
    <conn> lua return 1
    syntax error: :1: malformed number near '1 '
    execution failed!
    <conn> getm
    <conn> lua return 1
    syntax error: :1: malformed number near '1 '
    execution failed!
    <conn> getm
    <conn> reboot
    Could not find any device matching given bus/dev numbers, retrying in 1 s...
    <conn> lua return (1)
    <conn> getm
    1 (1)
    <conn> reboot
    Could not find any device matching given bus/dev numbers, retrying in 1 s...
    <conn> lua
    <conn> lua return 1
    <conn> getm
    1 (1)

    To witch time is ptp-handler destroyed. I'm looking for a solution to switch the powersavemode for ptp-duration to 'always'.

    rudi

     

    Related Topics