MLGenericDevice - HELP!!

Repository of MainLobby Server plug-ins and updates not available in the current installation.
monteourdog
Senior Member
Senior Member
Posts: 174
Joined: Sat May 20, 2006 5:03 am
Location: Vancouver
Contact:

MLGenericDevice - HELP!!

Postby monteourdog » Thu Sep 22, 2011 6:38 am

I am at my wits end. I cannot get the results I want from MLGD and I hope someone can help.

I am trying to control a Sharp LCD which does the following:
1) when I send a specific command (which works, no problem), the device returns an "OK" for all commands,
2) I need to send the same command without "switches" but "????" instead to get a status.

Example:

MLGenericDevice|Sharp~poweron (MLGD sends the code "POWR1 ")
response = OK
and the power goes on
MLGenericDevice|Sharp~powerstatus (MLGD sends the code "POWR????")
response = 1

So this, obviously, is not the problem, the problem is capturing the response.

I have set the command "poweron" with an MLS variable "sharp_command_status" and the results as <<VAR>> which gives me an MLS variable "sharp_command_status~OK"
But then I add another with the command "powerstatus" and a variable of "sharp_status" and "sharp_command_status" is set to "OK" even though the <<VAR>> is "1" and "sharp_status" is not even created.

Can someone please step me through the process of how to manage the results?

ricks
Is there life beyond Cinemar?
Is there life beyond Cinemar?
Posts: 1127
Joined: Wed Oct 27, 2004 7:01 pm
Location: Latham, Massachusetts
Contact:

Re: MLGenericDevice - HELP!!

Postby ricks » Thu Sep 22, 2011 10:22 am

Hopefully I understand your question but you may want to use the script section of Device Response and solving for Case. Sounds like you have 2 commands: poweron and powerstatus. In the Device Response section try:

Command Name: powerstatus
MLS Variable: sharp_status
Device Response: <<VAR>> * double-check the Events section to ensure you're capturing the full response of the sharp. Seems odd it would return just a "1" or a "0" without other characters. With logging turned on you should see something like: testing command - your command and then Processing Return String - your return string. Make sure you use the entire return string found in this section and replacing the desired character (0 or 1) with <<VAR>>.

In the Data Evaluation Method, check "Use Script" and then type

Function Return()
Select Case <<VAR>>
Case 0
ReturnValue = "Off"
Case 1
ReturnValue = "On"
End Select
End Function

Then, whenever you use the poweron or poweroff command, follow it with a powerstatus command. In many cases with serial commands you may need to add a brief delay between the poweron command and the powerstatus command to allow the device enough time to reply to poweron with "OK". So your poweron command in MLS may look like: Macro|MLGenericDevice|Sharp~poweron!MLPause|.2!MLGenericDevice|Sharp~powerstatus.

Hope this helps.
Rick

monteourdog
Senior Member
Senior Member
Posts: 174
Joined: Sat May 20, 2006 5:03 am
Location: Vancouver
Contact:

Re: MLGenericDevice - HELP!!

Postby monteourdog » Fri Sep 23, 2011 9:00 am

Rick,

Thanks for the tips - I did have some success...but then failure. By the way, I have checked and the response is a single digit for most case (volume will report 2 digits).

I created as you suggested and ended up with the response I had hoped for but then I created another command and then things got messed up. This is what I have:

command: poweron
command: powerstatus
command: mutetoggle
command: mutestatus

As mentioned before, when I send "MLGD|Sharp~poweron", I get a response "OK" (same for "MLGD|Sharp~mutetoggle", response="OK").
I send "MLGD|Sharp~powerstatus", I get a reponse "1" for on and "0" for off (similar for "MLDG|Sharp~mutestatus", reponse is "1" for on, "2" for off).

In the repsonse section of the plugin, I created 2:
Command Name: powerstatus, variable "Sharp_Power",
Command Name: mutestaus, variable "Sharp_Mute",

Both above using a script to convert the response to "on" or "off" but this is where the problem begins,

The responses are sorted alphabetically so "mutestatus" is before "powerstatus" and despite firing "MLGD|Sharp~powerstatus", the reponse for mutestatus is always returned including the variable "Sharp_Mute" is the only one updated.

Are the responses supposed to be tied to the commands? Or are all commands for one "family" all routed through one response script? I hope that makes sense. Simply, it does not matter how many responses I create and "link" (if linking is to create a response to a command) to a command, the first response script in the list is the one that provides the response.

By the way, in case anyone else follows in our footsteps, there is an error in your script:

Function ReturnValue()
Select Case <<VAR>>
Case 0
ReturnValue = "Off"
Case 1
ReturnValue = "On"
End Select
End Function

Hope you (or anyone) can help. It seems like the logic is in the plugin but either I am doing something wrong or the plugin is....

Cheers!

ricks
Is there life beyond Cinemar?
Is there life beyond Cinemar?
Posts: 1127
Joined: Wed Oct 27, 2004 7:01 pm
Location: Latham, Massachusetts
Contact:

Re: MLGenericDevice - HELP!!

Postby ricks » Fri Sep 23, 2011 9:57 pm

Sorry about the typo. That's what I get for trying to rely on memory.

That's why I was surprised the Sharp only returns 1 digit. Unfortunately since the Sharp only returns 1 digit, either a 1 or a 0 for both of these commands, MLGD can't differentiate between which function is being returned, power or mute.

Without seeing the Sharp serial protocol I would probably try this work-around.

Create a macro in Command Maps for each function which would include setting the function name, the command and the status request like:

Sharp.Power.On
Macro|
SetVariable|Sharp_function~Power!
MLGenericDevice|Sharp~PowerOn!
MLPause|.2!
MLGenericDevice|Sharp~Status

You will then need only one Device Response in MLGD. Leave its name as Status, for MLS Variable use Sharp_{{sharp_function}}. Leave the script as is.

When you run Sharp.Power.On you should get the variable sharp_power as On or Off. Do the same for Mute

Sharp.Mute.Toggle
Macro|
SetVariable|Sharp_function~mute!
MLGenericDevice|Sharp~MuteToggle!
MLPause|.2!
MLGenericDevice|Sharp~Status

Should return sharp_mute as On or Off

Its a bit ugly but it should work.

Does the Sharp TV offer a status command for every variable in one response? It seems unlikely but there are scripting options for that which can be handled entirely within MLGD.

Let me know if this works.

Rick

monteourdog
Senior Member
Senior Member
Posts: 174
Joined: Sat May 20, 2006 5:03 am
Location: Vancouver
Contact:

Re: MLGenericDevice - HELP!!

Postby monteourdog » Sat Sep 24, 2011 10:33 am

Thanks for confirming - I will stop trying to make this work and use the work-around.

I had actually done something like what you suggested with a few changes and it seems to be working for the most part. Sadly, there is no over-all update command and I cannot use a macro to check all the different settings status due to how MLS handles the variables. It seems that if I set a junk variable, then initiate the status update and repeat for all settings, MLS will not forward the junk variable until the macro ends which results in only the last command status updating. I have tried this with macros and scripting with and without pauses - same results. So far, this might be the only reason to upgrade to MLS4.

Thanks for your help!


Return to “MLServer Plug-Ins”

Who is online

Users browsing this forum: No registered users and 1 guest