Jump to content

Mathscript node timeout


Argold

Recommended Posts

I'm writing an application where users can plug in their own matlab code via a Mathscript "wrapper".  I need a way of timing out the matlab in case the user creates an infinite loop.

Does anyone know if mathscript provides a native timeout (google didn't find anything when searching "mathscript timeout").

If not, does anyone have any good (hopefully simple) suggestions?

Thanks!

Link to post

I've never used the mathscript node so I can't speak to that but some options that come to mind would be:

-Use VI server to launch the VI that actually runs the mathscript in the background, then kill the VI if it takes to long to return.
-Build the runner VI into an exe and call it, then use windows to kill the exe if it takes to long.
-Allow your user to learn why they shouldn't make infinite loops.

I'm partial to the third but the other two should work if nobody else chimes in with a better way.

Link to post
5 hours ago, smithd said:

I've never used the mathscript node so I can't speak to that but some options that come to mind would be:

-Use VI server to launch the VI that actually runs the mathscript in the background, then kill the VI if it takes to long to return.
-Build the runner VI into an exe and call it, then use windows to kill the exe if it takes to long.
-Allow your user to learn why they shouldn't make infinite loops.

I'm partial to the third but the other two should work if nobody else chimes in with a better way.

Yes +10 :thumbup1:

No. Just because you can doesn't mean you should. :nono:

No. That's Linux thinking and should be derided at every opportunity..:frusty:

:D

Edited by ShaunR
  • Like 1
Link to post
On 8/25/2016 at 11:39 PM, ShaunR said:

No. Just because you can doesn't mean you should. :nono:

No. That's Linux thinking and should be derided at every opportunity..:frusty:

I guess I was thinking if he doesn't trust his user not to make infinite loops they probably shouldn't be trusted with anything else, so an isolated executable would be beneficial...but I guess mathscript can't really do anything?

Also I'm fairly sure anything approaching linux thinking would involve the words "grep", "vim", "fork", "bash", "sudo", and "just follow these 99 very easy steps", and I included none of those words in my proposal :)

Edited by smithd
  • Like 1
Link to post
9 hours ago, smithd said:

Also I'm fairly sure anything approaching linux thinking would involve the words "grep", "vim", "fork", "bash", "sudo", and "just follow these 99 very easy steps", and I included none of those words in my proposal :)

That's after you have been told to go away and learn thermodynamics and molecular physics when all you want to do is make a cup of coffee. :D

Link to post

O.K. so it sounds like the preferred answer is to launch it with a VI server and time that out.

On ‎8‎/‎28‎/‎2016 at 6:31 PM, smithd said:

I guess I was thinking if he doesn't trust his user not to make infinite loops they probably shouldn't be trusted with anything else, so an isolated executable would be beneficial...but I guess mathscript can't really do anything?

It is not a matter of trust, I cannot control who the users are.  I'm just trying to provide them an environment where they can develop their matlab scripts with some decent error handling.

Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Similar Content

    • By ThomasGutzler
      Hi,
      I'm connecting to a Rigol DZ1000 Oscilloscope via USB and using the :DISP:DATA? ON,0,PNG command to grab a screenshot. Reading out the data in blocks of 65535 bytes until there is no more (see attached vi).
      This normally works fine but yesterday I was getting a timeout error. I fired up IO Trace and got this:
      > 783. viRead (USB0::0x1AB1::0x04CE::DS1ZA201305475::INSTR (0x00000001), "#9000045852‰PNG.......", 65536 (0x10000), 45864 (0xB328)) > Process ID: 0x000039C8 Thread ID: 0x00001760 > Start Time: 13:13:54.1169 Call Duration 00:00:10.4323 > Status: 0xBFFF0015 (VI_ERROR_TMO) You can see that 45864 bytes were received, which is exactly what was specified by the binary data header (45852 data bytes + 11 header bytes + 1 termination char)
      I dumped the reply string into a binary file and set the scope to run so it show something else on the screen. Sure enough the error went away. I also dumped a good result into a file. Then I tried to figure out what the problem may have been but I didn't get anywhere. Any ideas? Sure looks like a bug in VISA read or perhaps an incorrectly escaped reply from the scope?
      It's very easy to "convert" the reply into the screenshot - just remove the leading 15 bytes (4 bytes from WriteBinayFile and 11 bytes from the scope header). And yes, both data files display just fine as PNG. I don't think PNG does internal checksum so byte errors would be hard to spot.
      Any ideas what could have caused that timeout?

    • By farzane lk
      Hello
      I have received a LabVIEW dll and the corresponding header files so that I can send a trigger to a skin stimulation device.

      when I use the loadlibrary command in my Matlab script, I receive these two errors:  "We don't know the Compiler" and "We don't know the ProcessorType architecture"
      Which means while reading the "platdefines.h", the Compiler and the ProcessorType does not match the ones listed in ifs.
      I have set c++ compiler to visual studio 2015 in Matlab. (also tried MinGW). the system I`m using is Windows 10 (tried on 7, too), 64bit.
      I read somewhere that manually defining the ProcessorType and the compiler might solve the issue. But the problem is I Don`t know what they are. (when these two conditions below are not accepted.)
      #elif defined(_MSC_VER) || defined(_NI_VC_)
              #define Compiler        kVisualC
      #elif defined(_M_X64)
              #define ProcessorType    kX64
      --------------------------------------------------
      How should I find out the ProcessorType and the compiler I have? 
      I`d be EXTREMELY THANKFUL for any solutions you can think of.
      P.S.1 I attached all the headers and the Matlab error.jpg
      P.S.2 The code seems to work fine on manufacturers system with Matlab 2011. so it may be Matlab-related, but I don`t get how since the error is from platdefines header file.
       
      extcode.h
      fundtypes.h
      hosttype.h
      ILVDataInterface.h
      ILVTypeInterface.h
      lv_epilog.h
      lv_prolog.h
      platdefines.h
      STIM.aliases
      STIM.dll
      STIM.h
      STIM.ini
      STIM.lib

    • By Manudelavega
      Dear all,
       
      My company is starting a project where some Matlab files (.m) need to be executed by LabVIEW. The 2 obvious solutions are Matlab script nodes and MathScript nodes. Unfortunately, even though the latter one is the most cost-effective and light in terms of installation, many of the functions we need are not supported by the Run Time Engine, so it's kind of a deal breaker.
       
      For the Matlab script nodes, I know Matlab needs to be installed since LabVIEW will request Matlab to execute the scripts through ActiveX. What I don't know is: what version of Matlab? Is there a cheaper "Run Time Engine" of Matlab we can use instead of buying the full-blown developement version of Matlab?
       
      Any other comment, remark, suggestion, alternatives?
       
      Thanks!
    • By drjdpowell
      I have a request to make an EXE be able to dynamically call a .m file with Mathscript.   The .m file is User supplied and not knowable at build time.   But my understanding is that the EXE compiles in the Mathscript, so this cannot work, and that other dynamic mathscript options (such as “evalâ€) do not work in an EXE.  Has anyone encountered this issue before? 
    • By piZviZ
      In my project i have 2 task
       
      (1).Read data of sensor (attached to arduino board) serially  and display on LabVIEW.
      (2).Control output(just ON-OFF) pins of arduino using LabVIEW.
       
       
      So,for that i am using TAB in labview.created 2 TAB called Oscillospe and Input.
       
      If i first start Oscilloscope it work well.
      But when i come to Oscilloscope tab after using Input tab.
       
      It gives Time out error (VISA read)
       
      If i am executing in Highlight mode it works well
       
      tab--event.vi
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.