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

CHDK WiFi Remote

  • 21 Replies
  • 14451 Views
*

Offline reyalp

  • ******
  • 14118
Re: CHDK WiFi Remote
« Reply #10 on: 09 / August / 2015, 22:00:06 »
Advertisements
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.
This means there is something wrong with your script. There is nothing special that happens with the file system when you start / stop a script. If you post the actual code, we might be able to help you.

edit:
Or maybe there's some strange problem with CHDK, but in that case we still need a specific example to figure it out.
« Last Edit: 09 / August / 2015, 22:05:54 by reyalp »
Don't forget what the H stands for.

Re: CHDK WiFi Remote
« Reply #11 on: 09 / August / 2015, 22:21:55 »
Thanks for the quick response. Will post my scripts tonight.

Re: CHDK WiFi Remote
« Reply #12 on: 10 / August / 2015, 08:20:23 »
Here are my scripts.

CHDK script which tries to remove a file:
Code: [Select]
done= false
repeat
status= os.remove("A/lua/quit.cmd")
if status~= nil then
done= true
end
sleep(2000)
until (done== true)

play_sound(2)
sleep(100)
play_sound(2)
Web server script, it's executed when user clicks on a button on a web page. It writes a file QUIT.CMD:
Code: [Select]
local function wFile( fName, txt)
    local file = io.open("lua/"..fName..".cmd", "w" )
    file:write( txt)
    file:close()
end
----------------------------------------------
args={...}
param= parse_url( args[1])
wFile( param["c"],"")

After executing the web server script, the CHDK script kept on running. I stopped it manually and ensured the QUIT.CMD was actually created. The QUIT.CMD file got removed when I restarted the CHDK script.

*

Offline reyalp

  • ******
  • 14118
Re: CHDK WiFi Remote
« Reply #13 on: 10 / August / 2015, 17:43:25 »
That seems like it should work. As I said before, there starting / stopping a script shouldn't do anything special with the file system.

FWIW the following works for me with chdkptp on D10.
Code: [Select]
lua while not os.remove('A/quit.txt') do sleep(500) print'.' end print'done'
u -nolua quit.txt

The only thing I can think of is that there is something weird about how the canon firmeware sees changes made by the flashair. It isn't anything intentional in the script system, but starting/stopping the script may trigger something that makes it see the changes. Starting a script does probably trigger some IO, maybe the camera only sees the changes after some particular calls have been done. Have you tried using os.stat or io.open instead of remove?
Don't forget what the H stands for.


Re: CHDK WiFi Remote
« Reply #14 on: 10 / August / 2015, 19:38:24 »
Have you tried using os.stat or io.open instead of remove?
Yes, I did without luck. I also tried with directory. But somehow FlashAir mkdir() creates corrupted directory (as I posted before, it couldn't be removed).  I couldn't even remove it from laptop and ended up to run chkdsk to fix the issue.

I wanted to try the reverse, CHDK generates the file and FlashAir removes it. But for some reason FlashAir doesn't like os.remove()  :(

I think MrVas' issue was also that the changes were not detected.

*

Offline reyalp

  • ******
  • 14118
Re: CHDK WiFi Remote
« Reply #15 on: 10 / August / 2015, 22:29:19 »
Yes, I did without luck. I also tried with directory. But somehow FlashAir mkdir() creates corrupted directory (as I posted before, it couldn't be removed).  I couldn't even remove it from laptop and ended up to run chkdsk to fix the issue.
It's not too surprising, the camera firmware doesn't expect SD contents to change outside it's control. So if it keeps some information in memory, it might not notice when the flashair updates, and if it writes and isn't aware of what the flashair did, things could get corrupted.

That doesn't explain why you see the change only after you stop and restart the script though.

What camera and CHDK version are you using?

My impression from MrVas post is that it worked for him, but
Quote
For whatever reason, I have not had any luck loading the secondary (slave.lua) script, if the filename was alphabetically above the primary script.
suggests there is something weird.

edit:
also  from
Quote
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.
small / empty files may be problematic?
« Last Edit: 10 / August / 2015, 22:59:50 by reyalp »
Don't forget what the H stands for.

Re: CHDK WiFi Remote
« Reply #16 on: 10 / August / 2015, 22:46:49 »
small / empty files may be problematic?
Good idea, will try with a longer file   :)

Re: CHDK WiFi Remote
« Reply #17 on: 11 / August / 2015, 07:43:36 »
No luck with a (10k) larger file  :(


Re: CHDK WiFi Remote
« Reply #18 on: 13 / August / 2015, 08:53:58 »
Have you tried using os.stat or io.open instead of remove?
I just tried os.stat() again. It didn't see the written file even though I restarted the CHDK script few times. But as soon as I refreshed ptpclient to confirm the existence of the file then os.stat() worked.

*

Offline reyalp

  • ******
  • 14118
Re: CHDK WiFi Remote
« Reply #19 on: 13 / August / 2015, 17:14:35 »
I just tried os.stat() again. It didn't see the written file even though I restarted the CHDK script few times. But as soon as I refreshed ptpclient to confirm the existence of the file then os.stat() worked.
Try running listdir on the directory before checking for the file maybe?
Don't forget what the H stands for.

 

Related Topics


SimplePortal 2.3.6 © 2008-2014, SimplePortal