CHDK WiFi Remote - Creative Uses of CHDK - CHDK Forum supplierdeeply

CHDK WiFi Remote

  • 21 Replies
  • 14455 Views
CHDK WiFi Remote
« on: 31 / December / 2013, 02:15:40 »
Advertisements
Greetings,

For some time I've been searching for CHDK remote control method to satisfy my astrophotography interest, without having to stand outside in the cold and babysit the camera, yet have the ability to change camera settings. I have an Adruino controlled barn door tracker (a simple equatorial mount) that provides about 2-hours of pretty close tracking when properly aligned, but it's the numb fingers (cold outside) and constant bumping of the camera that's been bothering me. Using an Eye-Fi card helped a little, but I could only view the images and not be able to change the camera settings, since the cards will only transmit images, not receive any files. This changed recently, when I stumbled across a discussion in which a bot was controlled using a Toshiba FlashAir SD card. To make a long story short, I have purchased one and used it successfully to remotely control my Canon S95 running CHDK. For those of you who are interested in this approach, you'll need a Toshiba FlashAir wireless SD card, I am using the 8GB class 6 model #PFW008U-1ABW, along with the following scripts (as examples):

The following primary Lua script (called FLASHAIR.LUA) to be placed in A/CHDK/SCRIPTS:

Code: [Select]
--[[
@title FlashAir Remote
]]
repeat
  f=loadfile('A/CHDK/SCRIPTS/SLAVE.LUA')
  if not f then
    print("loadfile failed.")
  else
    f()
  end
  sleep(1000)
until(false)
And secondary Lua script (called SLAVE.LUA) to be also placed in A/CHDK/SCRIPTS:

Code: [Select]
--[[
@title Remote Commands
]]
shoot()
-----------------------------------------------------------
NOTES: Below are couple issues I've ran into.
  • For whatever reason, I have not had any luck loading the secondary (slave.lua) script, if the filename was alphabetically above the primary script.
  • If additional commands will be added anywhere above the last comment line, the slave.lua script must have plenty of comment padding at the end, otherwise it will not be reloaded properly.

Once the camera is powered up, and network connection with the FlashAir card established, you can upload changes to slave.lua either via the web interface or shell (command line in Windows) using curl or wget (not tested), even if flashair.lua is already running. I have used the following Bash script (OS X 10.6.8 ) to upload slave.lua changes:

Code: [Select]
#!/bin/bash
#
# FlashAir upload script
#
if [ "$1" == "" ] || [ "$2" == "" ] || [ "$3" == "" ]; then
  echo -e "\flashair-s95 - Upload files to FlashAir card\n\n  Usage:  flashair <FAIP> <UPDIR> <FILE>\n\n"
  exit
fi

if [ ! -f $3 ]; then
  echo "Unable to locate $PWD/$3. Aborting!!!"
  exit
fi

echo "Changing upload path to $2"
curl http://$1/upload.cgi?UPDIR=$2
sleep 1
echo -e "\nUploading file $PWD/$3 to $1 ($2)..."
#curl -F file=@$3 -F submit=submit http://$1/upload.cgi
curl -F file=@$3 http://$1/upload.cgi
echo -e "\nDone."
Using the following syntax:

Code: [Select]
./flashair-s95 <FlashAirIP> /CHDK/SCRIPTS slave.luaNOTES: Things to consider with FlashAir upload process.

Below are links to resources which may come in handy:

FlashAir Developers API Guide
http://www.extrud3d.com/flashair

Enjoy!

Re: CHDK WiFi Remote
« Reply #1 on: 31 / December / 2013, 11:05:59 »
I received Toshiba & Transcend cards for Christmas this year.  I'll give your code a try on one of my cameras.

Looking at the code, it seems like FLASHAIR.LUA calls SLAVE.LUA repeatedly once a second?  This might be okay for continuous shooting but there might need to be a mechanism to only call it once each time it's loaded?  Not quite sure how to make that work - probably need some scheme to pass parameters between the main function and the called function?  Either that or maybe have the main function delete SLAVE.LUA after it's called it once ?
Ported :   A1200    SD940   G10    Powershot N    G16

Re: CHDK WiFi Remote
« Reply #2 on: 31 / December / 2013, 11:32:03 »
Looking at the code, it seems like FLASHAIR.LUA calls SLAVE.LUA repeatedly once a second?  This might be okay for continuous shooting but there might need to be a mechanism to only call it once each time it's loaded?  Not quite sure how to make that work - probably need some scheme to pass parameters between the main function and the called function?  Either that or maybe have the main function delete SLAVE.LUA after it's called it once ?
The one second wait is included just as an example. If I understand your other question(s) correctly, then I suppose one could define a global variable that changes once a picture is taken, so another trigger will not be activated during the loop. The other option is to have flashair.lua not do a loop, and just load the slave.lua once, but that would defeat the purpose of using it as a remote control and would be much easier just to consolidate everything into one script.

One thing I forgot to mention in my original post, is that one can remark out the "shoot()" function in slave.lua, even if the loop is running, and the script will keep on processing, without the camera taking any pictures. Once ready to take pictures with additional/different settings, then just reenable shoot().

Re: CHDK WiFi Remote
« Reply #3 on: 02 / August / 2015, 08:37:57 »
I'm trying to do similar thing, i.e. flashAir web server writes to a file and CHDK script monitor the file.
I noticed if the CHDK already running and web server creates/modifies the file, the CHDK script doesn't see the changes until next start  :-(
I also tried to load new script in the script etc. without any luck.



Re: CHDK WiFi Remote
« Reply #4 on: 03 / August / 2015, 01:31:51 »
When I used the web browser to generate a file on the SD card I could see the file with the browser. But the CHDK script didn't detect that until next run.
Anyone has any idea what's the reason or how can I work around that?

My idea is to use the browser to trigger an CHDK action. Since I don't know how to make the web server to talk to the CHDK script I'm trying to use a file. btw, the web server can execute a LUA script, too.

*

Offline reyalp

  • ******
  • 14118
Re: CHDK WiFi Remote
« Reply #5 on: 03 / August / 2015, 02:30:37 »
When I used the web browser to generate a file on the SD card I could see the file with the browser. But the CHDK script didn't detect that until next run.
If you upload a new file, can you see it in the CHDK file browser?

How exactly are you trying to use the file you upload in the script?

edit:
see also http://chdk.setepontos.com/index.php?topic=11262.0
« Last Edit: 03 / August / 2015, 02:32:57 by reyalp »
Don't forget what the H stands for.

Re: CHDK WiFi Remote
« Reply #6 on: 03 / August / 2015, 03:22:10 »
How exactly are you trying to use the file you upload in the script?
My initial script (for testing purpose) is very simple. It runs in a loop and tries to delete a file. If successful exit the script. Since the file doesn't exist at the beginning the script will remain in the loop.
Then I use the web browser to kick off a LUA script (running on FlashAir) to generate the file. I hope the CHDK script will find the file. But it remains in the loop.
I can see the file from web browser. When I restart the script the file gets deleted and it exits the loop immediately.

Is it possible to trigger a restart of a script?
« Reply #7 on: 09 / August / 2015, 21:02:59 »
What I'm trying to do is similar to this thread:
http://chdk.setepontos.com/index.php?topic=11082.0

I'm using a FlashAir card which provides its own Wifi and web server.

My goal:
To use the web server to trigger a CHDK action.

My idea:
To use the file system to communicate, e.g. the web server generates a file. When the CHDK script detects the existence of the file it performs a task.

Problem:
The CHDK doesn't seem to detect any file changes (of another system, in this case FlashAir) after the script started. When I restarts the script then it detects the file.
I've tried many different things, e.g. using directories, rename, load(), dofile() etc. without luck.

Basically, I want FlashAir talking to CHDK. Any suggestions are welcome.

Thanks,
Phuoc


*

Offline reyalp

  • ******
  • 14118
Re: CHDK WiFi Remote
« Reply #8 on: 09 / August / 2015, 21:20:42 »
I merged this back into the original topic. Having the discussion scattered over multiple thread just makes it harder for everyone to follow, it won't get you a better answer. The people who might be able to help you will see it no matter which sub-forum you post in.

If CHDK script cannot see the changes made by flashair, that mean the Canon OS doesn't see it, which means that restarting the script isn't going to help.

Since you haven't provided any specific examples of how you tried to do this (with actual code) we can't say if you are doing something wrong, or if the what you are trying to do just can't be done.

I asked before
Quote
If you upload a new file, can you see it in the CHDK file browser?
If it shows in the CHDK file browser (not a web browser) then there is probably something wrong with the way you've tried to do it in script. If not, then the canon firmware just isn't seeing your changes, or you are not actually creating the files in a place where the firmware could see them.
Don't forget what the H stands for.

Re: CHDK WiFi Remote
« Reply #9 on: 09 / August / 2015, 21:45:51 »
I merged this back into the original topic. Having the discussion scattered over multiple thread just makes it harder for everyone to follow, it won't get you a better answer. The people who might be able to help you will see it no matter which sub-forum you post in.
Thanks
I asked before
Quote
If you upload a new file, can you see it in the CHDK file browser?
If it shows in the CHDK file browser (not a web browser) then there is probably something wrong with the way you've tried to do it in script. If not, then the canon firmware just isn't seeing your changes, or you are not actually creating the files in a place where the firmware could see them.
Sorry, I misunderstood and thought the web browser.
When the script is running I don't know. I have to stop the script to browse the file and it's there.
As soon as I restart the same script it detects the file.

 

Related Topics


SimplePortal 2.3.6 © 2008-2014, SimplePortal