1) DSLSTats could run a 'dummy' process immediately before sampling & end it immediately after sampling has completed.
Yes, I think I could do that. I'll have to think about what form the dummy program will take (it needs to sleep while running so it doesn't use CPU cycles) but I should be able to do that.
2) My programs could check for DSLStats running & assume that sampling will start at 35 seconds past the minute & complete by 40 seconds past.
If my programs are started just before 35 seconds past the minute they could simply wait until 40 seconds past before continuing.
If they are started as say 36 seconds past the minute i.e. after DSLStats has started sampling because it hadn't detected my programs, they could again wait until 40 seconds past before continuing.
From my viewpoint, that would be the best solution. When the "co-operation" option is set in DSLstats, I can almost guarantee that sampling won't be happening outside the times of 35-45 seconds after the minute (assuming a maximum of 5 seconds for sampling). The only exception to this would be some unexpected error condition in the program, and I'm currently enhancing the error trapping to try to eliminate this possibility. So if your programs could restrict their activities to the period from 45 seconds after the minute to the next 35 seconds after (including processing time) that would largely eliminate all clashes.
I expect I'll have some more thoughts, but I have to go off and do things now.
As a temporary measure, the programs that harvest stats (
HG612_stats.exe &
HG612_current_stats.exe) now check if DSLStats is running.
If not, they will continue as normal.
If DSLStats is running & the time is greater than 32 seconds past the minute & less than 45 seconds past, they will wait until 45 seconds past before moving on to login to the modem & harvest the stats.
e.g. if the time is 32 seconds past the minute, the programs will wait for 13 seconds.
if the time is 36 seconds past the minute, they will wait for 9 seconds
if the time is 42 seconds past the minute they will wait for 3 seonds (just in case).
My preference would still be to check for a dummy process started by DSLStats that only runs during the sampling period.
My programs would then only need to wait until DSLStats sampling had completed rather than have to wait until 45 seconds past the minute.If my programs start just before 32 seconds past the minute, they will continue as normal as DSLStats checks for them running & either waits for them to complete or aborts sampling for that minute.
If my programs do end up stuck in a loop, failing to obtain any valid data from the modem, they should exit cleanly, also freeing up the modem to be ready for the next attempt.
The only potential problem area I can think of at the moment would be if a user has sufficiently & permanently delayed the start of my programs or perhaps has 2 instances running for testing purposes or as a belt & braces back up system, one copy starting on the minute & the other copy starting at say 30 seconds past.
In those cases from a very slow PC, it is possible that one of the programs could still be running when DSLStats is due to start sampling.
For any of these checks & clash avoidance measures to work, DSLStats & HG612 Modem Stats programs do have to be running on the same machine in order to check for each other.
Using seconds past the minute alone as the criteria for clash avoidance measures would not always work if running the programs on different machines either as each machine's system time can & occasionally does drift out of sync with system time on the other machine, leading to each machine attempting to access the modem at the same time.
This can also cause clashes when running instances of the same program on separate machines.
I have attached copies of HG612_stats.exe & HG612_current_stats.exe if anyone wishes to test the clash avoidance measures.
Evidence of avoidance action should be visible in
CURRENT_ERROR.LOG_file_ERROR.TXT &
ONGOING_ERROR.LOG_file_ERROR.TXTe.g:-
**** From IsRunningVB.exe, DSLStats.exe *IS* running 1 instances - seconds past the minute = 34
**** Sleeping for 11 seconds