Problems with setTimeout()

138 views
Skip to first unread message

brbaltes

unread,
Jun 1, 2012, 12:45:15 PM6/1/12
to comman...@googlegroups.com
I am currently having problems with the setTimeout() command in a module.  It executes when testing but there is no delay where the setTimeout() command is called.  Any help would be greatly appreciated!

   module.setSource = function(source)
   {
  module.sendCommand('SOURCE ' + Epson8700UBTables.Sources.Commands[source]);
  setTimeout(module.requestSource(), 3000);
   };
 
   module.requestSource = function()
   {
  module.sendCommand('SOURCE?');
   };

Bryant 

Florent Pillet

unread,
Jun 1, 2012, 12:51:05 PM6/1/12
to comman...@googlegroups.com
Instead of passing the function to setTimeout, you are _executing_ the function with module.requestSource(). This is a common oversight. Here is the proper syntax:

> setTimeout(module.requestSource, 3000);

Notice the remove parenthesis. Tiny change makes a big difference :-)

Florent
> --
> You received this message because you are subscribed to the Google Groups "CommandFusion Software" group.
> To view this discussion on the web visit https://groups.google.com/d/msg/commandfusion/-/fnWWPaN4EP4J.
> To post to this group, send email to comman...@googlegroups.com.
> To unsubscribe from this group, send email to commandfusio...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/commandfusion?hl=en.

--
Florent Pillet - Software Engineering Lead
www.commandfusion.com



brbaltes

unread,
Jun 1, 2012, 1:04:19 PM6/1/12
to comman...@googlegroups.com
Awesome! Thanks a bunch!


On Friday, June 1, 2012 10:51:05 AM UTC-6, Florent Pillet wrote:
Instead of passing the function to setTimeout, you are _executing_ the function with module.requestSource(). This is a common oversight. Here is the proper syntax:

>            setTimeout(module.requestSource, 3000);

Notice the remove parenthesis. Tiny change makes a big difference :-)

Florent

On Jun 1, 2012, at 6:45 PM, brbaltes wrote:

> I am currently having problems with the setTimeout() command in a module.  It executes when testing but there is no delay where the setTimeout() command is called.  Any help would be greatly appreciated!
>
>    module.setSource = function(source)
>    {
>            module.sendCommand('SOURCE ' + Epson8700UBTables.Sources.Commands[source]);
>            setTimeout(module.requestSource(), 3000);
>    };
>  
>    module.requestSource = function()
>    {
>            module.sendCommand('SOURCE?');
>    };
>
> Bryant
>
> --
> You received this message because you are subscribed to the Google Groups "CommandFusion Software" group.
> To view this discussion on the web visit https://groups.google.com/d/msg/commandfusion/-/fnWWPaN4EP4J.
> To post to this group, send email to comman...@googlegroups.com.
> To unsubscribe from this group, send email to commandfusion+unsubscribe@googlegroups.com.

brbaltes

unread,
Jun 1, 2012, 1:26:18 PM6/1/12
to comman...@googlegroups.com
Florent, 

When we call setTimeout, it seems that while in that timeout, we are unable to receive feedback. Is this because JavaScript is single threaded and execution is stopped in the timeout, or are we doing something wrong?

Thanks!


On Friday, June 1, 2012 10:51:05 AM UTC-6, Florent Pillet wrote:
Instead of passing the function to setTimeout, you are _executing_ the function with module.requestSource(). This is a common oversight. Here is the proper syntax:

>            setTimeout(module.requestSource, 3000);

Notice the remove parenthesis. Tiny change makes a big difference :-)

Florent

On Jun 1, 2012, at 6:45 PM, brbaltes wrote:

> I am currently having problems with the setTimeout() command in a module.  It executes when testing but there is no delay where the setTimeout() command is called.  Any help would be greatly appreciated!
>
>    module.setSource = function(source)
>    {
>            module.sendCommand('SOURCE ' + Epson8700UBTables.Sources.Commands[source]);
>            setTimeout(module.requestSource(), 3000);
>    };
>  
>    module.requestSource = function()
>    {
>            module.sendCommand('SOURCE?');
>    };
>
> Bryant
>
> --
> You received this message because you are subscribed to the Google Groups "CommandFusion Software" group.
> To view this discussion on the web visit https://groups.google.com/d/msg/commandfusion/-/fnWWPaN4EP4J.
> To post to this group, send email to comman...@googlegroups.com.
> To unsubscribe from this group, send email to commandfusion+unsubscribe@googlegroups.com.

Florent Pillet

unread,
Jun 1, 2012, 4:45:34 PM6/1/12
to comman...@googlegroups.com
I don't see what you're mentioning in that code. The function you are executing in setTimeout simply does a sendCommand(), so there should not be any issue. If you don't get feedback (but again I have not seen the whole code) there may be another issue somewhere else.

Florent

On Jun 1, 2012, at 7:26 PM, brbaltes wrote:

> Florent,
>
> When we call setTimeout, it seems that while in that timeout, we are unable to receive feedback. Is this because JavaScript is single threaded and execution is stopped in the timeout, or are we doing something wrong?
>
> Thanks!

brbaltes

unread,
Jun 26, 2012, 11:59:03 PM6/26/12
to comman...@googlegroups.com
What would I do for setting a timeout on a function that passes parameters? Like module.getTie(output, "both")

Jarrod Bell

unread,
Jun 27, 2012, 2:16:10 AM6/27/12
to comman...@googlegroups.com
Something like:

setTimeout(module.getTie, 1000, output, "both");

Regards,

Jarrod Bell
CommandFusion
www.commandfusion.com


--
You received this message because you are subscribed to the Google Groups "CommandFusion Software" group.
To view this discussion on the web visit https://groups.google.com/d/msg/commandfusion/-/aEGYX8V8bcMJ.

To post to this group, send email to comman...@googlegroups.com.
To unsubscribe from this group, send email to commandfusio...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages