lua set_record() for script and ptp - General Discussion and Assistance - CHDK Forum

lua set_record() for script and ptp

  • 2 Replies
  • 2807 Views
*

Offline rudi

  • ***
  • 129
  • A590IS_101B, SX260HS_100B
lua set_record() for script and ptp
« on: 27 / March / 2013, 07:53:22 »
Advertisements
Here is a tested easy way for lua set_record() command. This is not very nice, but for discussion ok. Also the result values need a new common definition.

*

Offline reyalp

  • ******
  • 14128
Re: lua set_record() for script and ptp
« Reply #1 on: 09 / April / 2013, 00:34:56 »
This seems like a good idea
Don't forget what the H stands for.

*

Offline reyalp

  • ******
  • 14128
Re: lua set_record() for script and ptp
« Reply #2 on: 20 / July / 2013, 21:36:23 »
I implemented a version of this in trunk changeset 2971

set_record in both ubasic and lua should do the right thing whether or not a USB connection is present.

I haven't changed switch_mode_usb in lua, in case someone wants to call it directly for some reason.

I added "get_usb_bit_physw" in C code, to return (effectively) the value of the USB bit *after* CHDK is done masking. It would be better to actually get this from the bit in kbd.c, but I didn't feeling like touching >100 files right now. This could be useful elsewhere, for example in some of the PTP related code as proxy for whether a USB connection could be present. It might also be useful in script.

edit:
Slightly related, I completely removed the return value from switch_mode_usb in lua, in both the trunk and stable branches, because it didn't actually work.

Returning values from C to lua is done by pushing the values on the stack. The return value of the C function simply indicates the *number* of values returned. The old switch_mode_usb code returned 0 or 1 depending on the status of (C) switch_mode_usb, so it would either return nothing or one nil or possibly garbage? value.
« Last Edit: 20 / July / 2013, 21:40:37 by reyalp »
Don't forget what the H stands for.

 

Related Topics


SimplePortal © 2008-2014, SimplePortal