Need Help! Windows service get stuck and spike cpu usage on calling FOCAS cnc_allclibhndl3 funct


Results 1 to 5 of 5

Thread: Windows service get stuck and spike cpu usage on calling FOCAS cnc_allclibhndl3 funct

  1. #1
    Member fabriziocs's Avatar
    Join Date
    Oct 2022
    Posts
    4
    Downloads
    0
    Uploads
    0

    Default Windows service get stuck and spike cpu usage on calling FOCAS cnc_allclibhndl3 funct

    Hi to everybody!

    I made a windows service that each 5 second call the cnc_allclibhndl3 function to get the handle, then call cnc_statinfo/cnc_rddynamic2/cnc_rdsvmeter/cnc_rdspmeter/cnc_sysinfo/cnc_rdparar/cnc_rdalmmsg2, finally release the handle with cnc_freelibhndl.
    After running fine for 2-3 hours I notice from the task manager that the service show 100% cpu using.
    From the log I can see that the service is stuck on calling the cnc_allclibhndl3 function.
    Restarting the service solve the problem for the next 2-3 hours.
    The service it's write in C#.

    Many thank's to anyone can give usefull tip

    Similar Threads:


  2. #2
    Member fabriziocs's Avatar
    Join Date
    Oct 2022
    Posts
    4
    Downloads
    0
    Uploads
    0

    Default Re: Windows service get stuck and spike cpu usage on calling FOCAS cnc_allclibhndl3 f

    I have a follow up on this, I changed the service to leave the handle open until the end of the program or an error from an api call occurred.
    Now the service it's stable and it's up and running from some days but I notice a lot of errors on the log calling cnc_statinfo that return -8 "Windows library handle error"
    Each time that cnc_statinfo return this error I call cnc_freelibhndl to release the current handle and then cnc_allclibhndl3 to get a new one. With the new handle I can successfully call cnc_statinfo for 2-3 times, with a delay of 5 seconds between each, before I get a -8 error again.

    I'm out of ideas, someone have an hint?



  3. #3
    Member freakycnc's Avatar
    Join Date
    Apr 2012
    Location
    USA
    Posts
    85
    Downloads
    0
    Uploads
    0

    Default Re: Windows service get stuck and spike cpu usage on calling FOCAS cnc_allclibhndl3 f

    fabriziocs,

    Have you tried varying the "timeout" in your handle call?

    cnc_allclibhndl3( "IP ADDRESS", 8193, 10, &h ) --- in this case it's 10 seconds -----

    timeout [ in ]

    Specify seconds for timeout. If specify 0, timeout process is ignored and the library functions wait infinity.

    The best timeout value is different according as system. For example, in case of the hi-speed network system, 10 seconds is sufficient for timeout. But in case of relaying by low-speed telephone line, more than 60 seconds is well for timeout.So you must specify the timeout value after the measurement of your communication time.



  4. #4
    Member fabriziocs's Avatar
    Join Date
    Oct 2022
    Posts
    4
    Downloads
    0
    Uploads
    0

    Default Re: Windows service get stuck and spike cpu usage on calling FOCAS cnc_allclibhndl3 f

    Hi freakycnc,

    I'm going to increasing the timeout from 6 to 10 seconds, even if the error is returned from the cnc_statinfo and looking at the trace log the -8 error is returned in less than a second after the function call.
    The system is on a hi-speed network.

    Thank's for the help



  5. #5
    Member fabriziocs's Avatar
    Join Date
    Oct 2022
    Posts
    4
    Downloads
    0
    Uploads
    0

    Default Re: Windows service get stuck and spike cpu usage on calling FOCAS cnc_allclibhndl3 f

    Unlucky, increase the timeout didn't fix the issue



  6. #6
    Member Versex's Avatar
    Join Date
    May 2020
    Posts
    8
    Downloads
    0
    Uploads
    0

    Default Re: Windows service get stuck and spike cpu usage on calling FOCAS cnc_allclibhndl3 f

    Just in case someone else runs into this issue in the future.... A fanuc handle is only good on the thread in which it is called. So if you are using a timer, task, backgroundworker, etc.... then you are going to run into the -8 error. using something like a timer results in C# grabbing a thread from the thread pool, so every time it elapses it could potentially execute on a different thread which will invalidate your fanuc handle. The way around this is to make the Focas calls in a loop.

    If anyone is looking for Focas tutorials, I have a youtube channel and website you can check out.

    https://hierthinking.com

    https://www.youtube.com/channel/UCyz...PJFMvSZXkqGAmw



Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


About CNCzone.com

    We are the largest and most active discussion forum for manufacturing industry. The site is 100% free to join and use, so join today!

Follow us on


Our Brands

Windows service get stuck and spike cpu usage on calling FOCAS cnc_allclibhndl3 funct

Windows service get stuck and spike cpu usage on calling FOCAS cnc_allclibhndl3 funct