How can I parse that a device returns nothing / is switched off?

37 views
Skip to first unread message

Klaus

unread,
Dec 7, 2018, 3:26:45 PM12/7/18
to CommandFusion Software
I want to check whether a RS-232 device (audio mixer) is powered on or not.

If the mixer is on I can send a command "SET 8 1F 1B 0" and get a feedback "SET 8 1F 1B 0" from the mixer.
But how to parse if nothing is returned (the mixer is switched off)?

Maybe I am completely on the wrong path?

Barry Gordon

unread,
Dec 7, 2018, 4:32:58 PM12/7/18
to comman...@googlegroups.com

set a timer to time the response.  If the timer (let's say 2-3 seconds) expires then you could assume the device is powered off

--
You received this message because you are subscribed to the Google Groups "CommandFusion Software" group.
To unsubscribe from this group and stop receiving emails from it, send an email to commandfusio...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Klaus

unread,
Dec 11, 2018, 2:13:32 PM12/11/18
to CommandFusion Software
Great, Barry! Sounds so easy. But I guess it needs some coding (I am still a "one-line-programmer" ...).

So I tried an "old-fashioned" way, which did the job:

Sent a command SET 8 1F 1B 0 to the mixer.
Receive a feedback with Regex (SET 8 1F 1B 0), OnMatch sets target d99 to 1.
With a start delay of 2 sec I send a command and JavaScript: CF.getJoin("d99" function(j,v) {CF.runCommand(null, (v=="1")? "command name to call home-page" : "Command name to call error-page"); });

I am just curious (want to learn) how it would look like using a timer and some coding. Easy?

Vladimir Shabunin

unread,
Dec 15, 2018, 6:26:24 AM12/15/18
to comman...@googlegroups.com
It can be done with JS. The deal is to declare some timerObject = null in global scope, on command sending use timerObject = setTimeout(<do thing in case if device is switched off>, timeoutInMs);   register FeedbackMatchEvent for your feedback regexp, that will contain code in case if you have receive reponse from device and if (timerObject !== null) { clearTimeout(timerObject); } 

So, study setTimeout/clearTimeout/CF.watch/CF.send if you want to implement it in js code.

вторник, 11 декабря 2018 г., 22:13:32 UTC+3 пользователь Klaus написал:
Reply all
Reply to author
Forward
0 new messages