CHDK PTP interface - page 38 - General Discussion and Assistance - CHDK Forum

CHDK PTP interface

  • 1244 Replies
  • 533412 Views
Re: CHDK PTP interface - what is luar ?
« Reply #370 on: 18 / January / 2011, 07:16:30 »
Advertisements
So what is luar ? And how is it different than lua ?

I tried searching this forum and the CHDK wiki without finding anything that introduced this new concept. I'm guessing its something from the German forum but that's just a guess.

Ported :   A1200    SD940   G10    Powershot N    G16

Re: CHDK PTP interface - what is luar ?
« Reply #371 on: 18 / January / 2011, 09:48:16 »
So what is luar ? And how is it different than lua ?
They are commands from the ptpcam tool. One just runs a script, the other also waits for a return value. It was discussed in this thread a while ago. The reasons why they both exist (in ptpcam, mind you) were also discussed.

From what I've seen/read I really like reyalp's message-queue patch and would suggest it above his getr approach (if that's still on the table after rudi's fix). It doesn't really seem more complex and probably provides all the flexibility you'll "ever" need.

But it help not on the switch to record mode crash.

I dont know, whats diffrent, but it work, when i start a script in play mode, Camera switch to record mode, as soon a shoot command come and shoot a image.

but there seem no pb2rec use for this.
I seem to remember it being mentioned here before that some cameras work with the "normal" mode switch (i.e. without doing PB2Rec or something) in Lua.

Re: CHDK PTP interface
« Reply #372 on: 18 / January / 2011, 11:05:03 »
>I seem to remember it being mentioned here before that some cameras work with the "normal" mode >switch

I think the IX1000 can work too with normal mode switch, i test with USB cable in, it work ok.
Ixus 1000 HS

*

Offline reyalp

  • ******
  • 14125
Re: CHDK PTP interface
« Reply #373 on: 18 / January / 2011, 12:18:51 »
From what I've seen/read I really like reyalp's message-queue patch and would suggest it above his getr approach (if that's still on the table after rudi's fix). It doesn't really seem more complex and probably provides all the flexibility you'll "ever" need.
Yes, i thought getr was going to be simpler, but it didn't really turn out that way. My problem with the message stuff was it was too generic: For most cases, you probably just want to run a script and return a value, and it doesn't really distinguish those form user defined messages. Having a status available for each script invocation is also important.

Definitely going to remove the current luar method one way or the other.

Quote
I think the IX1000 can work too with normal mode switch, i test with USB cable in, it work ok.
So set_record(1) works ? This is very surprising, it doesn't work on any other recent dryos cameras
Don't forget what the H stands for.

Re: CHDK PTP interface
« Reply #374 on: 18 / January / 2011, 13:22:49 »
Yes, i thought getr was going to be simpler, but it didn't really turn out that way. My problem with the message stuff was it was too generic: For most cases, you probably just want to run a script and return a value, and it doesn't really distinguish those form user defined messages. Having a status available for each script invocation is also important.

Definitely going to remove the current luar method one way or the other.
Why all this hate towards luar? ;)

Seriously though, considering the possible usage, in a world with a message queue, I doubt there is a real need to deal with the return value in CHDK itself. People who know what they're doing will know to use write_usb_msg and "normal" users will use some GUI tool that can take care of the return value by wrapping all code in a write_usb_msg. At least, I don't expect the latter case requires something more than submitting code, possibly providing text input and having the output (messages and return value) printed in some text box.

Alternatively, you could tag messages with a type ('user', 'return value') or something. Possibly even by using some bits of the size variable. (I mean, 4GB messages seem unlikely and, if not, what about messages of size MAX_INT+1.)

Re: CHDK PTP interface
« Reply #375 on: 18 / January / 2011, 13:43:47 »
>So set_record(1) works ?

I dont understand what ypu mean.do you mean in C source or as lua command use set_record(1) ?

I have USB cable plug in camera and press when camera is in play mode and alt mode the shoot button full.this script switch then to record mode and shoot the images without problems.please read below too

rem Author - Keoeeit
rem Written for S-Series
rem Should be okay on others
rem Use Endless mode with caution
rem See documentation for important info
rem first version
@title Ultra Intervalometer
@param a Delay 1st Shot (Mins)
@default a 0
@param b Delay 1st Shot (Secs)
@default b 0
@param c Number of Shots
@default c 5
@param d Interval (Minutes)
@default d 0
@param e Interval (Seconds)
@default e 0
@param f Interval (10th Seconds)
@default f 5
@param g Endless? No=0 Yes=1
@default g 0
p=a*60000+b*1000
t=d*60000+e*1000+f*100
if c<1 then let c=5
if t<100 then let t=100
if g<0 then let g=0
if g>1 then let g=1
if p<0 then let p=0
z=t*c
y=p+z
print "1 Cycle Time:", y/60000; "min", y%60000/1000; "sec"
goto "interval"
:interval
  if p>0 then gosub "pause"
  print "Shot 1 of", c
  shoot      
  if c=1 then end
  for n=2 to c
  sleep t
  print "Shot", n, "of", c
  shoot
  next n

.......


so maybe can call what this script do too with C functions ?

I add

 set_record(1);

in C source, but give error

wrappers.c:(.text+0x1254): undefined reference to `set_record'

#ifdef CAM_CHDK_PTP
    if ( mode == 0 ) {
        _Rec2PB();
        _set_control_event(0x80000902); // 0x10A5 ConnectUSBCable
    } else if ( mode == 1 ) {
        //_set_control_event(0x902); // 0x10A6 DisconnectUSBCable
        //_PB2Rec();
          set_record(1);
    } else return 0;
    return 1;
#else
Ixus 1000 HS

*

Offline reyalp

  • ******
  • 14125
Re: CHDK PTP interface
« Reply #376 on: 18 / January / 2011, 15:44:47 »
>So set_record(1) works ?

I dont understand what ypu mean.do you mean in C source or as lua command use set_record(1) ?
This is the lua function that switches between record and play normally, when PTP isn't involved. This also works in PTP for most vxworks cameras.

I'm pretty sure this is what mweerden was referring to.
Quote
I have USB cable plug in camera and press when camera is in play mode and alt mode the shoot button full.this script switch then to record mode and shoot the images without problems.please read below too
If I understand correctly, this would also be very unusual. Normally when the camera is connected by USB, it doesn't respond to any canon buttons. CHDK alt buttons are expected to work.
Don't forget what the H stands for.

Re: CHDK PTP interface
« Reply #377 on: 18 / January / 2011, 16:27:57 »
I'm pretty sure this is what mweerden was referring to.
Me too.

so maybe can call what this script do too with C functions ?

I add

 set_record(1);

in C source, but give error
Try levent_set_record() (and levent_set_play() for set_record(0)).

Re: CHDK PTP interface
« Reply #378 on: 19 / January / 2011, 09:22:33 »
I try now with ptpcam(with the lua fix) this line

C:\Users\pc>e:\chdk\ptpcam --chdk="lua set_record(1)"

Camera do nothing.
I also try now this C Code and Camera do nothing

        //_set_control_event(0x902); // 0x10A6 DisconnectUSBCable
        //_PB2Rec();
       levent_set_record();

when i try out this C code and set_control_event is execute, camera crash in same way as with _pb2rec.
it move out lens and then crash.

  _set_control_event(0x902); // 0x10A6 DisconnectUSBCable
        //_PB2Rec();
       levent_set_record();

maybe Camera have diffrent values for diconnect USB cable ?

But what does levent_ mean ?

is this the code lua execute.

What C code do the basic script execute ?
It seems diffrent because the basic script switch when call shoot from play mode to record mode and shoot correct when USB cable is plug in.LUA do this not.

C:\Users\pc>e:\chdk\ptpcam --chdk="lua shoot()"

do nothing

I find out, when i have chdk run and USB cable is in, after 2-3 minutes do no action Camera switch off complete.
Is this ok, or is maybe a function call to display off wrong ?

I have now do a lua script, but this bring eof expected near end on last line.but demo scripts in chdk scripts folder work. but maybe is something wrong with the Camera port, i have upload the script here

http://www.zshare.net/download/854432334e4ec216/

source is this, i want test if lua switch with USB cable plug in with that script same as basic script in record mode.
I ghave do this script on windowseditor which add 0xd and 0xa
 


--[[

@title interval

]]
set_record(1)
repeat    
   press("shoot_full")
   release("shoot_full")
   sleep(5000)
        press("shoot_full")
   release("shoot_full")
   sleep(5000)
until false
end
« Last Edit: 19 / January / 2011, 09:56:43 by Bernd R »
Ixus 1000 HS

*

Offline reyalp

  • ******
  • 14125
Re: CHDK PTP interface
« Reply #379 on: 19 / January / 2011, 12:10:00 »
I try now with ptpcam(with the lua fix) this line

C:\Users\pc>e:\chdk\ptpcam --chdk="lua set_record(1)"
As I told you before, this method only works on old cameras, it would be very surprising if it worked on yours.

Quote
       levent_set_record();
Pointless, this is the same thing is the lua call would do. If the lua version doesn't work, then this also will not work.
Quote
  _set_control_event(0x902); // 0x10A6 DisconnectUSBCable
        //_PB2Rec();
       levent_set_record();

maybe Camera have diffrent values for diconnect USB cable ?
Random mixing and matching code is unlikely to help. It's possible the value for set control event is wrong.

Quote
But what does levent_ mean ?
"logical event"  from the camera functions PostLogicialEvent
Quote
is this the code lua execute.

What C code do the basic script execute ?
Why don't you look and find out for yourself ?
Quote
It seems diffrent because the basic script switch when call shoot from play mode to record mode and shoot correct when USB cable is plug in.LUA do this not.
It's not different, shoot uses exactly the same code. Shoot does not switch any other camera to record mode with USB connected that I know of.
Don't forget what the H stands for.

 

Related Topics


SimplePortal © 2008-2014, SimplePortal