Page 1 of 3 123 LastLast
Results 1 to 10 of 25

Thread: Get variable values from serial plugin

  1. #1

    Default Get variable values from serial plugin

    I've managed to use Netremote to communicate with Girder, which sends commands to my Onkyo PR-SC886 processor. I use the Onkyo gml/lua file in the download section. All the commands work great, and when I for instance send the master volume request, I get:

    Serial: Onkyo-Ts-Sr-804 : Command queued: 21 31 4D 56 4C 51 53 54 4E !1MVLQSTN at postion 1
    Serial: Onkyo-Ts-Sr-804 : Simple Send: 21 31 4D 56 4C 51 53 54 4E 0D !1MVLQSTN.
    Serial: Onkyo-Ts-Sr-804 : Simple Receive: Data Code: 0
    Serial: Onkyo-Ts-Sr-804 : Simple Receive: Data 21 31 4D 56 4C 33 31 1A !1MVL31. Code: 8192
    Serial: Onkyo-Ts-Sr-804 : ERROR: Incomplete response to last command


    The feedback (here "!1MVL31") is correct. I don't know why I get the last error message.

    I just started learning this, and what I need your help on is to get this feedback message back into Netremote and display this in a slider/button. How do I get this value into a variable in Netremote.

    I appreciate any help.

  2. #2

    Default

    Here's a little more about the problem (I have renamed the Onkyo device from the earlier post):

    To get the power status, I shall use this script:

    Onkyo: PowerState()

    From the lua code I see this is executed:

    PowerState = function (self)
    return self:SendCommand ('PW?')
    end,

    From lua console:

    Serial: Onkyo-PR-SC886 : Command queued: 50 57 3F PW? at postion 1
    Serial: Onkyo-PR-SC886 : Simple Send: 50 57 3F 0D PW?.
    Serial: Onkyo-PR-SC886 : Simple Receive: Data Code: 0

    This does not make sence. The Onkyo cannot interpret the "PW?" since the actual code for that request is "!1PWRQSTN".

    Do I need to change this in the lua file for all these procedures? Where is my variable with the response value??
    Attached Files Attached Files

  3. #3
    Join Date
    Jul 2007
    Location
    Netherlands
    Posts
    370

    Default

    Do you have a manual with the command codes the Onkyo supports? you should look up there how to 'build' a command string for whatever action you want the device to perform and also what answer to expect in return.
    Using: Win7 MCE, Girder, xPL, RFXcom, HomeEasy

    http://www.thijsschreijer.nl

  4. #4

    Default

    The manual is an Excel spreadsheet. I'm unable to upload it, but it's from the download website, and I cannnot post links yet. It's the ONKYO TX-SR804 plugin found under Girder 5, and the zip contains the Excel file with all the info.


    This is what I used to determine what to send to Onkyo, which works great, but I can't figure out the return variable.
    Last edited by thunderstorm77; June 13th, 2011 at 03:59 AM.

  5. #5
    Join Date
    Jul 2007
    Location
    Netherlands
    Posts
    370

    Default

    Couldn't find the PR-SC886 in the spreadsheet as a supported device, but the PR-SC885 seems close enough and it seems to be a very generic protocol.

    What wasn't in the protocol is the error returned when an illegal command is send. Probably best to use a simple terminal app to directly connect to the Onkyo and manually send commands and verify their results according to the spreadsheet. If correct, then compare those results to the lua console to see where it goes wrong.

    One note though; I wrote a driver for an RFXmitter device and we noticed that the Girder serial implementation seems to be not 100% reliable (see this post), it just returned some extra bytes that where never send by the actual device. We decided to live with that, because the device was working anyway.
    The core problem for this device was that it was an ethernet based device using a virtual com port that was redirected over the lan (so basically Girder was talking to the com-port). Something was wrong and we couldn't get it fixed, only after using a different com port redirector (the virtual com port provider) it suddenly worked. That was another indication for me that the Girder serial implementation has some quirks.
    Using: Win7 MCE, Girder, xPL, RFXcom, HomeEasy

    http://www.thijsschreijer.nl

  6. #6

    Default

    Thanks for the help. That sound a little difficult to me...

    The SC-886 is very close to the 885, so that should not be an issue. I do get an error message, but the communication is working perfectly. If I increase the volume, I get a message back with the new volume level.

    Since It seems that I'm so close, I don't understand why Girder just can't put the response into a variable that I can show in NetRemote.

    It's a great product even without the feedback, but it would be so much nicer and user friendly.

  7. #7
    Join Date
    Jul 2007
    Location
    Netherlands
    Posts
    370

    Default

    Its the plugin your dealing with in this case, not as much Girder.

    Had a quick look at the lua code, for one; the '?' seems to be a shortcut for 'QSTN' as its all over the place. Commands and responses are easily identified in the code;

    Commands (straight from the lua file);
    Code:
    -- Power
    PowerOn = function (self) 
        return self:SendCommand ('PWON')
    end,
     
    PowerOff = function (self) 
        return self:SendCommand ('PWSTANDBY')
    end,
     
    PowerState = function (self) 
        return self:SendCommand ('PW?')
    end,
     
    MZOn = function (self)
        return self:SendCommand ('ZMON')
    end,
     
    MZOff = function (self)
        return self:SendCommand ('ZMOFF')
    end,
    The globalname for the plugin is 'Onkyo', so executing these commands is as simple as creating a script action with the following line;
    Code:
    Onkyo.PowerOff  -- as per above send 'PWSTANDBY' command
    or any other command, see the lua file for that.
    The GML file basically has serial commands being send with the raw ASCII data in there, which also works ofcourse.

    As for responses; the lua file also has a long list for those, here are some;
    Code:
            self.Responses['PW'] = function(Settings, data)                 
                _, _, self.PowerMain = string.find (data,"PW(.-)$")
                print ("Power:",(self.PowerMain))
                NetRemote.SendLabel ('power', (self.PowerMain))
            end
     
            self.Responses['MV'] = function(Settings, data)                 
                _, _, self.RawVolume = string.find (data,"MV(.-)$")
                self.Volume = OnkyoVolumeTodb(self.RawVolume)
                print ("Main Volume:",(self.Volume))
                NetRemote.SendLabel ('OnkyoMainVolume', self.Volume)
                NetRemote.SendLabel ('OnkyoRawVolume', self.RawVolume)
            end
    From the code it appears to me (though I don't use NetRemote) that the data is already being forwarded to NetRemote.


    Besides that the code shows that the data is available in the variables;
    • self.RawVolume can be accessed from lua as Onkyo.RawVolume
    • self.Volume can be accessed from lua as Onkyo.Volume
    • self.PowerMain can be accessed from lua as Onkyo.PowerMain
    You could try to use the variable inspector (menu view|variable inspector). Refresh the contents and scroll to 'Onkyo', which should have sub-values 'RawVolume', 'Volume', etc. for which you can inspect the current values (don't forget to refresh the view after making changes)


    And yes, you're right, you won't get very far with Girder unless you understand its scripting.... so hang in there, learn, and (almost) anything will be possible
    Using: Win7 MCE, Girder, xPL, RFXcom, HomeEasy

    http://www.thijsschreijer.nl

  8. #8

    Default

    Thanks a lot for the long response!

    I still have some issues though, as some of the variables don't show up in the Variable Inspector. I have attached a screenshot.

    If I run

    Onkyo:PowerState() , I get:

    Serial: Onkyo-PR-SC886 : Command queued: 50 57 3F PW? at postion 1
    Serial: Onkyo-PR-SC886 : Simple Send: 50 57 3F 0D PW?.
    Serial: Onkyo-PR-SC886 : Simple Receive: Data Code: 0



    If I change the "PW?" to "!1PWRQSTN" and run

    Onkyo:PowerState() , I get:

    Serial: Onkyo-PR-SC886 : Command queued: 21 31 50 57 52 51 53 54 4E !1PWRQSTN at postion 1
    Serial: Onkyo-PR-SC886 : Simple Send: 21 31 50 57 52 51 53 54 4E 0D !1PWRQSTN.
    Serial: Onkyo-PR-SC886 : Simple Receive: Data Code: 0
    Serial: Onkyo-PR-SC886 : Simple Receive: Data 21 31 50 57 52 30 31 1A !1PWR01. Code: 8192
    Serial: Onkyo-PR-SC886 : ERROR: Incomplete response to last command


    In either case, the Variable Inspector does not change (only lastcommand and lastresponse). The response "!1PWR01 is correct ("On").
    Attached Thumbnails Attached Thumbnails Click image for larger version. 

Name:	Variable View.jpg 
Views:	186 
Size:	72.7 KB 
ID:	6247  

  9. #9
    Join Date
    Jul 2007
    Location
    Netherlands
    Posts
    370

    Default

    just once more (just to be sure); the variable inspector does not automatically update its display, you must click refresh!!

    replace the lua file with the attached one and restart Girder. Please post the same screenprint again from this lua file.
    In the interactive lua console type the command 'Onkyo.PowerState' (without the quotes) and press enter. Also return the output from that one.
    Last edited by Tieske8; June 13th, 2011 at 04:29 PM. Reason: removed attachment
    Using: Win7 MCE, Girder, xPL, RFXcom, HomeEasy

    http://www.thijsschreijer.nl

  10. #10

    Default

    I have attached the updated variable inspector screenshot.

    When running

    Onkyo.PowerState

    I get:

    [string "Interactive"]:1: `=' expected near `<eof>'


    When running

    Onkyo:PowerState()

    I get:

    Serial: Onkyo-Ts-Sr-804 : Command queued: 50 57 51 53 54 4E PWQSTN at postion 1
    Serial: Onkyo-Ts-Sr-804 : Simple Send: 50 57 51 53 54 4E 0D PWQSTN.
    ONKYO plugin received some data:
    Data received: nil
    Timer (pcall): ...\Promixis\Girder5\/plugins/serial/Onkyo-Tx-Sr804.lua:1012: attempt to concatenate local `data' (a nil value)
    stack traceback:
    ...\Promixis\Girder5\/plugins/serial/Onkyo-Tx-Sr804.lua:1012: in function `ReceiveResponse'
    ...iles (x86)\Promixis\Girder5\/plugins/serial/init.lua:338: in function <...iles (x86)\Promixis\Girder5\/plugins/serial/init.lua:333>


    When running

    Onkyo:PowerState()

    a second time I got:

    Serial: Onkyo-Ts-Sr-804 : Command queued: 50 57 51 53 54 4E PWQSTN at postion 1
    Serial: Onkyo-Ts-Sr-804 : Response pending, que size 1





    I see the startup is different for this file:

    Welcome to Promixis Girder 5.0.1 build 535
    Registering NR client from 192.168.50.119:59807
    Serial: Onkyo-Ts-Sr-804 : Opened Device: Onkyo-Ts-Sr-804 Port: 1 Settings: 9600 N 0 8 0
    Serial: Onkyo-Ts-Sr-804 : Callback Installed 2
    ONKYO plugin received some data:
    Data received: 0
    Code received: 0
    Just raised an event 'Onkyo ...'
    Serial: Onkyo-Ts-Sr-804 : Simple Receive: Data 30 0 Code: 65536
    Attached Thumbnails Attached Thumbnails Click image for larger version. 

Name:	Variable View v2.jpg 
Views:	167 
Size:	86.2 KB 
ID:	6250  

Page 1 of 3 123 LastLast

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
  •