Jump to content

Sleep related (maybe) stupid question


Recommended Posts

It's most likely stupid question, but it seems i can't handle it

Question : What does happen with sleep() after say 3 days runtime of a gui. Is it reliable, or i can just get rid of that buggy thing and setup a timer. Does it actually count xxx ms or it's not that accurate

Problem : on a program that open connection via plink to COM1 with sdin/out etc of plink, sends some stuff, and wait 2500ms, closes the plink proccess and reads the stdout then do stuff according the reply. Since the thing that respond on COM1 is quite buggy(sadly not at this case), we left this program with the issue for a while, tested with other controller etc, but after around 24-48h controller stop giving output. Restarting the AU3 program (compiled, latest stable, no upx, no antivirus etc) cause the problem to dissapear for another 25h or so.  I did some testing and loggin, and i seems i cannot figure it out.

Why it stop giving its goddamn output and why after restart it runs as expected ? PS sorry if question / problem is stupid, but it's causing alot nerves over here :D

Posting the function, but i believe its not possible to reproduce it, since you don't have the controller to test it out. I'm 10000% sure it's not the controller itself (or the com1 connection)

Func _dummyFunc()
    Local $aTestAttempt = 0
    sleep(1000)
    If ProcessExists("plink.exe") Then
    _FileWriteLog($aLogFile,"found some plink proccess, force closing it.")
    ProcessClose("plink.exe")
    ProcessWaitClose("plink.exe")
    sleep(500)
    EndIf
    Do
    Local $iPID2, $sOutput2, $sError2
    $iPID2 = Run($plinkPath & $plinkName & " " & $plinkParams, $plinkPath, @SW_HIDE, $STDIN_CHILD + $STDOUT_CHILD + $STDERR_CHILD)
    If @error <> 0 Then
        Local $anErrorVar = @error
        Local $anErrorExtendedVar = @extended
            TCPSend($sSocket[$cSocketNum], "ERROR" & ":Cannot connect to controller Error code is " & $anErrorVar & " and extened code is " & $anErrorExtendedVar & @CRLF)
            _FileWriteLog($aLogFile, "Cannot connect to controller. Error was " & $anErrorVar & " Extended code was " & $anErrorExtendedVar)
            ProcessClose($iPID2)
;~          Return
        EndIf
    StdinWrite($iPID2, $cCommand & $cContrNum & $cDummyCommand & @CRLF)
    Sleep(2500)
    ProcessClose($iPID2)
    ProcessWaitClose($iPID2)
    $sOutput2 = StdoutRead($iPID2)
    $sError2 = StderrRead($iPID2)
    $dummyResult = StringTrimRight(StringTrimLeft(StringStripCR($sOutput2), 1), 1)
    _FileWriteLog($aLogFile, "Waking up the controller. Result - " & $dummyResult)
    $aTestAttempt = $aTestAttempt + 1
    If StringCompare(StringRight($dummyResult, $dummyLenght), $dummyValue) <> 0 And $aTestAttempt = 4 Then _simpleEmail("Cannot wake up controller after 4 attempts. Please check it.")
    Until StringCompare(StringRight($dummyResult, $dummyLenght), $dummyValue) = 0 OR $aTestAttempt = 4
    Return
EndFunc   ;==>_dummyFunc

 

Link to comment
Share on other sites

  • Moderators

@JustSomeone I would suggest, as a beginning step, that you use something like the TrayIconDebug option:

Opt("TrayIconDebug", 1)

That would tell you more, such as the line at which the script is hanging (I am guessing from your description that the script doesn't crash, just stops responding). It is obviously working for some time for you, so for someone to determine the problem at a glance without letting it run for 25 hours is going to be unlikely.

 

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

2 minutes ago, JLogan3o13 said:

@JustSomeone I would suggest, as a beginning step, that you use something like the TrayIconDebug option:

Opt("TrayIconDebug", 1)

That would tell you more, such as the line at which the script is hanging (I am guessing from your description that the script doesn't crash, just stops responding). It is obviously working for some time for you, so for someone to determine the problem at a glance without letting it run for 25 hours is going to be unlikely.

 

It does not hang, it continues it's work, so i assume sleep changed, and controller did not had enough time to respond. I cannot use bigger than 3000ms sleeps there  because the program is also doing other things, and if i delay too much it will cause error at other stuff, so i believe the sleep funct is causing it, because everything else seems to work. Restarting the autoit program fixes the problem (there is few other functions, calling the same plink program and they also behave like this, no reply from controller)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...