John Public
Posts: 90
Joined: Thu Jan 16, 2014 2:16 pm

Five second lag from samba to Windows 7

Mon Oct 10, 2016 8:36 pm

I am testing RPi 3 with camera and I want to distribute jpg images created by Raspistill.
I have a script on Windows 7which does the following:
1) deletes file "mypic.jpg" (if it exists) on the RPi folder "/myfolder/"
2) creates a file "ready.dat" there
3) then goes on a loop with 1 sec intervals checking if a new "mypic.jpg" has materialized in "/myfolder/".

The RPi on the other hand keeps looking at the same folder. If its sees a "ready.dat" it copies "mypic.jpg" from another folder to "/myfolder/mypic.jpg"

All goes well sees the "ready.dat" and immediately RPi creates the jpg. The Windows 7 on the other sees that "mypic.jpg" has become available.

The problem is that there is 5-7 second lag after cp has finished and the Windows program actually sees the file. These are small files, about 75kb. On the windows side I am running a simple C program and use "access()" function to determine if the file exists over at the RPi folder. I am not sure what causes the lag. Both are connected by a router (not WiFI) and I copy stuff all the time with no lag. The lag presents when the "mypic.jpg" has been deleted and then created again. If it is just overwritten by Raspistill there is no lag.

mutley
Posts: 61
Joined: Sat Jan 02, 2016 8:06 pm

Re: Five second lag from samba to Windows 7

Fri Oct 14, 2016 4:20 pm

Sounds like something is being cached in the directory access. Probably on the windows side, so it may be worth reading about shared folders and local caching on windows.
Quick google turned up this.
http://stackoverflow.com/questions/5159 ... or-some-pe

But, is there a need to actually delete and create files? Can't your poll loops just look at the last access time? If that changes then assume it's a new file. Since you said there is no delay when the file is modified only when it's created, it seems this would also fix that.

John Public
Posts: 90
Joined: Thu Jan 16, 2014 2:16 pm

Re: Five second lag from samba to Windows 7

Sat Oct 15, 2016 2:26 pm

Thank you for your reply.
I tried using file creation date. It has the same lag problem. I have solved it used another way - just use a TCP connection to get the file.

Return to “Networking and servers”