Are these software upgrades possible? - General Help and Assistance on using CHDK stable releases - CHDK Forum

Are these software upgrades possible?

  • 187 Replies
  • 36351 Views
Are these software upgrades possible?
« on: 02 / May / 2011, 14:54:11 »
Advertisements
Are the following requirements possible? if not, which ones and why? if so, how?
1. camera stays on permanently, indefinitely and never shuts off from running out of RAM due to memory leak (not SD card space).
2. new menu option where camera automatically formats SD card when full or at specified interval in days.
3. If 1 and 2 aren't possible, all buttons etc can be controlled from some sort of interface instead of having to have someone there to push them.

These features would be a big improvement to an existing autonomous robotics platform. I appreciate any info from knowledgeable members.

*

Offline reyalp

  • ******
  • 13673
Re: Are these software upgrades possible?
« Reply #1 on: 02 / May / 2011, 16:32:35 »
Are the following requirements possible? if not, which ones and why? if so, how?
1. camera stays on permanently, indefinitely and never shuts off from running out of RAM due to memory leak (not SD card space).
No. The canon firmware was never designed to run indefinitely. However, you can reboot the camera from script, and with lua+autostart you can have your script restart as well and save/restore state from files.

Quote
2. new menu option where camera automatically formats SD card when full or at specified interval in days.
Formatting the SD card would remove CHDK. The cameras builtin formatting functions wipe out any partitions. If you wrote your own formatting code, you could probably format the data partition of a multi-partition autoboot setup. There may also be partition aware functions lurking somewhere in the OS (I suspect this is the case in vxworks, less likely in dryos)
Quote
3. If 1 and 2 aren't possible, all buttons etc can be controlled from some sort of interface instead of having to have someone there to push them.
You can simulate button presses from script, which can be done over USB using the PTP extension: http://chdk.wikia.com/wiki/PTP_Extension

Formatting using button presses would suffer the same problems described above, although you might be able to re-copy CHDK over PTP afterward.

You can also build simple communications on the USB remote code. The USB remote simply senses the +5v signal on the USB, rather than implementing USB communication. Many people have tied this to a microcontroller.
Don't forget what the H stands for.

Re: Are these software upgrades possible?
« Reply #2 on: 02 / May / 2011, 20:00:02 »
I read through the manual, briefly read through the LUA Wiki and PTP Extension Wiki but still have a few questions.
1. what script commands set the zoom level on startup?
2. what commands will format the partition where the images are stored on startup?
3. how would I restart the OS/camera before it shuts itself off? Is there a way to monitor the memory leak and restart before it causes the OS to shutdown? Once it has shut itself down I'm fvcked unless it can somehow auto-reboot itself.
4. is it possible for a script to change modes from picture mode to video mode at a certain time of day (and then back to picture mode at a future time)?
5. is it possible to get any of the supported cameras to dually function in USB file transfer mode while also functioning as a camera so that the images could be copied and removed from the SD card while the camera is taking pictures?

*

Offline reyalp

  • ******
  • 13673
Re: Are these software upgrades possible?
« Reply #3 on: 02 / May / 2011, 23:20:03 »
I read through the manual, briefly read through the LUA Wiki and PTP Extension Wiki but still have a few questions.
1. what script commands set the zoom level on startup?
you can use script to click the zoom keys in a loop while checking zoom position get_zoom, or the set_zoom function.
Quote
2. what commands will format the partition where the images are stored on startup?
Does not exist. When I said "If you wrote your own formatting code" I meant in C or assembler, with raw disk IO functions. Doing this without upsetting the Canon OS might be tricky, but it should be possible. You might able to do it where the partition swapping happens in current code. You should be able to find FAT formatting code floating around on the net.
Quote
3. how would I restart the OS/camera before it shuts itself off? Is there a way to monitor the memory leak and restart before it causes the OS to shutdown? Once it has shut itself down I'm fvcked unless it can somehow auto-reboot itself.
Figure out how long/how many pictures is it usually takes to crash, and make sure you reboot well before that. Or pick some interval you know is OK, e.g. every hour or every day.

Adding the ability to find out how much memory is free is in the works, but that's not necessarily the only possible cause of a crash.
Quote
4. is it possible for a script to change modes from picture mode to video mode at a certain time of day (and then back to picture mode at a future time)?
Yes. Mode setting can be done with http://chdk.wikia.com/wiki/LUA/Scripts:Standard/Lualib/Capmode (or the low level functions it calls)

Date/Time can can be obtained from os.date(), see http://www.lua.org/manual/5.1/manual.html#5.8 and http://chdk.wikia.com/wiki/Lua#Lua_standard_libraries:_io.2C_os.2C_string.2C_and_math

Quote
5. is it possible to get any of the supported cameras to dually function in USB file transfer mode while also functioning as a camera so that the images could be copied and removed from the SD card while the camera is taking pictures?
The CHDK PTP interface (download/upload commands) can be used to transfer files in either mode. I would expect regular PTP transfer to work as well, but I don't think I've ever tried it. Trying to transfer while camera is in the middle of capturing an image would probably be bad, but doing it in rec mode is no problem.
Don't forget what the H stands for.


Re: Are these software upgrades possible?
« Reply #4 on: 03 / May / 2011, 12:56:22 »
Since it is not possible to reliably predict when the camera will shut itself off, I think it would be better to change the function of the power button so that it can only turn the camera on but not off. That way, I can have something pushing it at some interval and I won't ever have to worry about whether the camera is off or not. The logic for the power button would be like this: camera on? do nothing, camera off? power on.
1. How would I change the way the power button functions so that it no longer turns the camera off if pressed (it would only be able to turn it on)?

When the USB cable is plugged in all of the camera's I've tried automatically change to file transfer mode and won't allow camera operation.
2. How do I override that so I can copy and delete the stored images while the camera prepared to take pictures? (I understand you can't expect the camera to save images while you're downloading them.)
« Last Edit: 03 / May / 2011, 15:05:41 by John1234 »

*

Offline reyalp

  • ******
  • 13673
Re: Are these software upgrades possible?
« Reply #5 on: 03 / May / 2011, 16:14:31 »
1. How would I change the way the power button functions so that it no longer turns the camera off if pressed (it would only be able to turn it on)?
Holding down the power button all the time may work. I know some people have used this in conjunction with external power supplies to ensure the camera comes back on after a power outage, not sure if it works with a crash. Or you could rig up a servo.

If you want to change how the camera software handles the power button, you would download the CHDK source, dump your camera firmware, disassemble it, and start hacking. taskPhySw / kbd_task would probably be a good place to start. You might just be able to mask out the power button bit like we already do with SD card write protect.

Alternately, you could attempt to diagnose the causes the crashes (perhaps using the ROMLOG http://chdk.wikia.com/wiki/Debugging#Camera_crash_logs_.28romlog.29 ) and figure out how to eliminate or predict them.

Depending on the causes of the crashes, you might also be able to modify the exception handlers to reboot instead of shutting down. This would be a worthwhile feature for CHDK.

If you aren't fairly well versed in C and assembler, only the first option (and similar electromechanical solutions) applies to you.
Quote
When the USB cable is plugged in all of the camera's I've tried automatically change to file transfer mode and won't allow camera operation.
2. How do I override that so I can copy and delete the stored images while the camera prepared to take pictures? (I understand you can't expect the camera to save images while you're downloading them.)
You would use the CHDK PTP interface to put it back into record mode after connecting USB.
Don't forget what the H stands for.

Re: Are these software upgrades possible?
« Reply #6 on: 04 / May / 2011, 18:59:46 »
1. Is it possible to tell the camera to turn on from the CHDK PTP interface? The camera would be off but plugged into a PC. Could it be told to turn on while off besides pressing the power button?

Keeping the power button held down doesn't work. I just finished testing that.

2. Can you elaborate on this:? "You might just be able to mask out the power button bit like we already do with SD card write protect."

Diagnosing the crashes doesn't sound like the path of least resistance to me. There must be a simpler way to accomplish the goal of having the camera stay on all the time, no matter what.

3. Do I have to have CHDK running on the camera to be able to get the additional PTP options like the ability to put it back into record mode after connecting USB or can it be done with ptpCamGui alone?

*

Offline reyalp

  • ******
  • 13673
Re: Are these software upgrades possible?
« Reply #7 on: 04 / May / 2011, 23:04:33 »
1. Is it possible to tell the camera to turn on from the CHDK PTP interface? The camera would be off but plugged into a PC. Could it be told to turn on while off besides pressing the power button?
No. A few very old canons will wake up if plugged into USB power, but if yours doesn't do that, it's nothing that can be changed.
Quote
2. Can you elaborate on this:? "You might just be able to mask out the power button bit like we already do with SD card write protect."
You can find this in platform/<camera>/kbd.c in the CHDK source http://tools.assembla.com/chdk/browser/trunk

If it's not fairly obvious what needs to be done there, this is not the method for you.

This thread about the battery door provide some ideas http://chdk.setepontos.com/index.php?topic=5744.0

The code in sub/<version>/boot.c to select the correct power up mode in cameras with a play button may give you a hint as to which bit is the power button.
Quote
3. Do I have to have CHDK running on the camera to be able to get the additional PTP options like the ability to put it back into record mode after connecting USB or can it be done with ptpCamGui alone?
Yes, the ability to do that is in CHDK code, except for some (mostly older) cameras that support remote shooting already with the canon SDK. Edit: ptpcamgui cannot talk to a camera unless CHDK is installed.
Don't forget what the H stands for.


Re: Are these software upgrades possible?
« Reply #8 on: 05 / May / 2011, 09:41:12 »
The power button is not masked out in any of the cameras I checked but just about every other button was:
48            { 0, KEY_SHOOT_FULL     , 0x00000300 },
49            { 0, KEY_SHOOT_HALF     , 0x00000100 },
50            { 1, KEY_UP                   , 0x00000100 },
51            { 1, KEY_DOWN           , 0x00001000 },
52            { 1, KEY_LEFT           , 0x00000200 },
53            { 1, KEY_RIGHT          , 0x00002000 },
54            { 1, KEY_SET            , 0x00000400 },
55            { 1, KEY_ZOOM_IN        , 0x00000080 },
56            { 1, KEY_ZOOM_OUT       , 0x00000020 },
57            { 1, KEY_MENU           , 0x00000800 },
58            { 1, KEY_DISPLAY              , 0x00008000 },
59            { 1, KEY_PRINT          , 0x00004000 },

1. Am I supposed to try to figure out/guess what value for the power button is?

To recap, you have almost solved all of the problems;
2. camera randomly shuts off: not solved yet
3. automatically set zoom when powered on: use lua script
4. sd card runs out of space: use ptpcam dll and custom software to autonomously copy and delete images when camera is not taking pictures.
5. change mode autonomously: lua script
« Last Edit: 05 / May / 2011, 10:31:08 by John1234 »

*

Offline reyalp

  • ******
  • 13673
Re: Are these software upgrades possible?
« Reply #9 on: 05 / May / 2011, 12:30:19 »
1. Am I supposed to try to figure out/guess what value for the power button is?
Yes, that would be an essential first step. I suggested where you might want to look, if your camera is new enough to have a "play" button that can power on the camera. Also, what you quoted was defines the keys, what your really want to look at is the SD card and USB power stuff, that's more similar to what you want to do.
Quote
To recap, you have almost solved all of the problems;
2. camera randomly shuts off: not solved yet
I think you already said you weren't interested in debugging this ? If you are, you need to
- tell us which model camera you are using
- tell us what you are doing when it crashes
- get ROMLOGs from the crash
The canon firmware can't be expected to run indefinitely, but it shouldn't just crash randomly under normal usage in a short period of time. Many people take all day timelapses without any problem.

If you are using this for a robotic project, how about making the power switch electronically controlled instead ? E.g. cut out the switch and wire it directly into some output controlled by your robot ?
Don't forget what the H stands for.

 

Related Topics