Help with first plug in controling Sony Receiver with a GC100 bij RS232

Hi,

I’have been reading, searching, trying for days, but still no go. So i will post my findings here and hope that someone wil help me.

I’m trying to control a Sony receiver by RS232 with a CG100. (this hardware setup up works perfectly, so no problem here)
The CG100 has ip 192.168.1.70 an port 4999.

At the moment just simple commands like power on-power off
I have to send following command to power the receiver on: x02,x04,xa0,x60,x00,x01,xfb,x03 or \x02\x04\xa0\x60\x00\x01\xfb\x03

I have following I and D files

Could someone give me some help?

thanks

What in particular are you looking for help with ?

It is not working and I have no idea why!

The first thing to do is to verify your XML files pass a strict XML syntax … There are online syntax checkers.
Next look in the log file for any errors related to your device. There should be some time of error during a restart.

The implementation file that you uploaded is riddled with RTF markup. If that is the file you put on your Vera it is certainly not XML.

You will also need a static JSON file D_foo.json if you want the device to have a user interface on the dashboard.

Edit: it also looks like you are using your own service S_foo.xml files. These will need to be created too. Maybe just start with one service and then add others when you’ve got that one working.

[quote=“futzle, post:5, topic:180275”]The implementation file that you uploaded is riddled with RTF markup. If that is the file you put on your Vera it is certainly not XML.

You will also need a static JSON file D_foo.json if you want the device to have a user interface on the dashboard.

Edit: it also looks like you are using your own service S_foo.xml files. These will need to be created too. Maybe just start with one service and then add others when you’ve got that one working.[/quote]

Futzle,

Thanks for you reply,
I did not see the RTF markups, i corrected this.
Why is is the Json file needed, i dont see any Json file in all the plugins.
What had to be in this Jsaon file
As for the S_foo.xml, i just did the same as the pioneer plugin, is the S file mandotory?

Ok i tried again by following your advice, but no go

Here a part of the log when i launch the scene
08 01/15/00 6:53:42.625 JobHandler_LuaUPnP::HandleActionRequest device: 0 service: urn:micasaverde-com:serviceId:HomeAutomationGateway1 action: e[36;1mRunScenee[0m <0x2d94b680>
08 01/15/00 6:53:42.625 JobHandler_LuaUPnP::HandleActionRequest argument SceneNum=9 <0x2d94b680>
08 01/15/00 6:53:42.625 Scene::RunScene running 9 Sony On <0x2d94b680>
08 01/15/00 6:53:42.626 JobHandler_LuaUPnP::HandleActionRequest device: 38 service: urn:micasaverde-com:serviceId:DiscretePower1 action: e[36;1mOne[0m <0x2d94b680>
02 01/15/00 6:53:42.626 e[33;1mDevice_LuaUPnP::HandleActionRequest 38 not ready 0x8fae38e[0m <0x2d94b680>
02 01/15/00 6:53:42.626 e[33;1mJobHandler_LuaUPnP::RunAction device 38 action urn:micasaverde-com:serviceId:DiscretePower1/On failed with -911/Device not readye[0m <0x2d94b680>
02 01/15/00 6:54:15.103 e[33;1mZW_Send_Data node 3 NO ROUTE (nil)e[0m <0x2bb31680>
02 01/15/00 6:54:17.236 e[33;1mZW_Send_Data node 3 NO ROUTE (nil)e[0m <0x2bb31680>
06 01/15/00 6:54:17.365 Device_Variable::m_szValue_set device: 6 service: urn:micasaverde-com:serviceId:EnergyMetering1 variable: e[35;1mWattse[0m was: 0 now: 0 #hooks: 0 upnp: 0 v:0x92c058/NONE duplicate:1 <0x2b931680>

Files are attached.
I just took the pionner plugin, changed the protocal to RAW, changed the port, and the command to be send as wel as this line
if( false == luup.io.write(string.char(code … )))
to send the HEX code

any idea?

Capture the log when you reload the Vera web UI. There will be an error message then. The error you have while running a scene (“device not ready”) is consequential.

Wich log do you mean? not the luaupnp.log?
where to find it?

Wich log do you mean? not the luaupnp.log?
where to find it?[/quote]
Yes - LuaUPnP.log is where you should look. See Logs.

wel did and this is what i get after i execute the secen poweron
08 01/17/00 4:32:21.509 JobHandler_LuaUPnP::HandleActionRequest argument SceneNum=9 <0x2e04b680>
08 01/17/00 4:32:21.510 Scene::RunScene running 9 Sony On <0x2e04b680>
08 01/17/00 4:32:21.510 JobHandler_LuaUPnP::HandleActionRequest device: 38 service: urn:micasaverde-com:serviceId:DiscretePower1 action: On <0x2e04b680>
02 01/17/00 4:32:21.510 Device_LuaUPnP::HandleActionRequest 38 not ready 0x780158 <0x2e04b680>
02 01/17/00 4:32:21.564 JobHandler_LuaUPnP::RunAction device 38 action urn:micasaverde-com:serviceId:DiscretePower1/On failed with -911/Device not ready <0x2e04b680>
02 01/17/00 4:33:09.156 ZW_Send_Data node 3 NO ROUTE (nil) <0x2c231680>
02 01/17/00 4:33:11.386 ZW_Send_Data node 3 NO ROUTE (nil) <0x2c231680>
06 01/17/00 4:33:11.555 Device_Variable::m_szValue_set device: 6 service: urn:micasaverde-com:serviceId:EnergyMetering1 variable: Watts was: 0 now: 0 #hooks: 0 upnp: 0 v:0x7a8b10/NONE duplicate:1 <0x2be31680>
06 01/17/00 4:33:11.556 Device_Variable::m_szValue_set device: 6 service: urn:micasaverde-com:serviceId:EnergyMetering1 variable: ActualUsage was: 1 now: 1 #hooks: 0 upnp: 0 v:0x7b1460/NONE duplicate:1 <0x2be31680>
02 01/17/00 4:33:13.557 ZW_Send_Data node 3 NO ROUTE (nil) <0x2c231680>
06 01/17/00 4:33:13.695 Device_Variable::m_szValue_set device: 6 service: urn:micasaverde-com:serviceId:EnergyMetering1 variable: KWH was: 0.0000 now: 0.0000 #hooks: 0 upnp: 0 v:0x7a9168/NONE duplicate:1 <0x2be31680>
06 01/17/00 4:33:13.696 Device_Variable::m_szValue_set device: 6 service: urn:micasaverde-com:serviceId:EnergyMetering1 variable: KWHReading was: 948079813 now: 948079993 #hooks: 0 upnp: 0 v:(nil)/NONE duplicate:0 <0x2be31680>
02 01/17/00 4:33:15.704 ZW_Send_Data node 3 NO ROUTE (nil) <0x2c231680>
06 01/17/00 4:33:15.835 Device_Variable::m_szValue_set device: 6 service: urn:micasaverde-com:serviceId:EnergyMetering1 variable: Watts was: 0 now: 0 #hooks: 0 upnp: 0 v:0x7a8b10/NONE duplicate:1 <0x2be31680>
06 01/17/00 4:33:15.835 Device_Variable::m_szValue_set device: 6 service: urn:micasaverde-com:serviceId:EnergyMetering1 variable: ActualUsage was: 1 now: 1 #hooks: 0 upnp: 0 v:0x7b1460/NONE duplicate:1 <0x2be31680>
04 01/17/00 4:33:15.837 <0x2be31680>
06 01/17/00 4:33:18.118 Device_Variable::m_szValue_set device: 7 service: urn:futzle-com:serviceId:UPnPProxy1 variable: Status was: 1 now: 1 #hooks: 0 upnp: 0 v:0x7a76c0/NONE duplicate:1 <0x2c831680>
06 01/17/00 4:33:18.119 Device_Variable::m_szValue_set device: 7 service: urn:futzle-com:serviceId:UPnPProxy1 variable: StatusText was: Running now: Running #hooks: 0 upnp: 0 v:(nil)/NONE duplicate:1 <0x2c831680>
06 01/17/00 4:33:18.119 Device_Variable::m_szValue_set device: 7 service: urn:futzle-com:serviceId:UPnPProxy1 variable: API was: 3 now: 3 #hooks: 0 upnp: 0 v:(nil)/NONE duplicate:1 <0x2c831680>
08 01/17/00 4:34:21.108 JobHandler_LuaUPnP::HandleActionRequest device: 0 service: urn:micasaverde-com:serviceId:HomeAutomationGateway1 action: RunScene <0x2e04b680>
08 01/17/00 4:34:21.108 JobHandler_LuaUPnP::HandleActionRequest argument SceneNum=9 <0x2e04b680>
08 01/17/00 4:34:21.108 Scene::RunScene running 9 Sony On <0x2e04b680>
08 01/17/00 4:34:21.109 JobHandler_LuaUPnP::HandleActionRequest device: 38 service: urn:micasaverde-com:serviceId:DiscretePower1 action: On <0x2e04b680>
02 01/17/00 4:34:21.109 Device_LuaUPnP::HandleActionRequest 38 not ready 0x780158 <0x2e04b680>
02 01/17/00 4:34:21.109 JobHandler_LuaUPnP::RunAction device 38 action urn:micasaverde-com:serviceId:DiscretePower1/On failed with -911/Device not ready <0x2e04b680>
02 01/17/00 4:34:27.616 luvd_get_info mg conn can’t read /etc/cmh-ludl//toolbox.js or /etc/cmh-lu//toolbox.js from filename /toolbox.js pPtrFile (null) <0x2e44b680>
02 01/17/00 4:34:39.203 ZW_Send_Data node 3 NO ROUTE (nil) <0x2c231680>
02 01/17/00 4:34:41.346 ZW_Send_Data node 3 NO ROUTE (nil) <0x2c231680>
06 01/17/00 4:34:41.532 Device_Variable::m_szValue_set device: 6 service: urn:micasaverde-com:serviceId:EnergyMetering1 variable: Watts was: 0 now: 0 #hooks: 0 upnp: 0 v:0x7a8b10/NONE duplicate:1 <0x2be31680>
06 01/17/00 4:34:41.533 Device_Variable::m_szValue_set device: 6 service: urn:micasaverde-com:serviceId:EnergyMetering1 variable: ActualUsage was: 1 now: 1 #hooks: 0 upnp: 0 v:0x7b1460/NONE duplicate:1 <0x2be31680>
02 01/17/00 4:34:43.535 ZW_Send_Data node 3 NO ROUTE (nil) <0x2c231680>
06 01/17/00 4:34:43.666 Device_Variable::m_szValue_set device: 6 service: urn:micasaverde-com:serviceId:EnergyMetering1 variable: KWH was: 0.0000 now: 0.0000 #hooks: 0 upnp: 0 v:0x7a9168/NONE duplicate:1 <0x2be31680>
06 01/17/00 4:34:43.666 Device_Variable::m_szValue_set device: 6 service: urn:micasaverde-com:serviceId:EnergyMetering1 variable: KWHReading was: 948079993 now: 948080083 #hooks: 0 upnp: 0 v:(nil)/NONE duplicate:0 <0x2be31680>
02 01/17/00 4:34:45.673 ZW_Send_Data node 3 NO ROUTE (nil) <0x2c231680>

You need to look further back - just after Vera restarted. There should be an error like …implementation failed… with a diagnostic message and line number. It is generally red. Note the line number is not exact due to the way implementation files are converted to Lua but it will be close to where the error is.

ok i understood, these are the line where device 38 is
is this info you can use?

09 01/17/00 8:30:54.656 JobHandler_LuaUPnP::Run device 38 Sony GC100 room 4 type urn:schemas-micasaverde-com:device:receiver:1 id parent 0/0x880698 upnp: 0 <0x2abe1000>
01 01/17/00 8:31:07.551 LuImplementation::StartLua skipping device 38 implementation valid 1 <0x2b315680>

Do you have any start-up code in your implementation file? OK, I see you do but it doesn’t seem to have been run…

I think there may be a major syntax error in your file. Check earlier in the log.

ok it seems i’m making progres, no error anymore.
It seems i get connection with the gc100.

but now i have to figure out how to send the HEX code: x02\x04\xa0\x60\x00\x01\xfb\x03

I’m basing the plugin on the pioneer plug in wich sends this kind of commands 10FN

It is set in CR but i thing i should go with RAW.

but how to send the string?
is this correct?:

function doAction(deviceType, actionName)
local code = mappingTable[deviceType][actionName];

        local CR = string.char(13)

        -- Do we have a code?
        if( code ~= "") then
        
            -- Wake up the receiver if it is in standby mode.                  
            luup.io.write(CR)

            -- Send the code to the receiver
            if( false == luup.io.write(string.char(code .. )))then
                luup.log("io.write error in action: " .. deviceType .. "-" .. actionName .. " code:" .. code, 1)
                luup.set_failure(true)
                return false
            end
        else
            luup.log("Unimplemented action: " .. deviceType .. "-" .. actionName, 1)
            luup.set_failure(true)
            return false
        end
        
        return true
    end

with his mapping table

    local mappingTable = 
       
    ["DiscretePower1"] = {
        ["Off"] = "\x02\x04\xa0\x60\x00\x00\xfc\x03",                     -- POWER OFF
        ["On"] = "0x02,0x04,0xa0,0x60,0x00,0x01,0xfb,0x03",               -- POWER ON
        },
     }

To build a hex string, use string.char(…). e.g.

 ["Off"] = string.char(0x02,0x04,0xa0,0x60,0x00,0x00,0xfc,0x03),    -- POWER OFF

Then you can send it using:

luup.io.write(code)

or if you need to add the CR to the end:

luup.io.write(code .. CR)

Ok i’m making little progress here, i know there is something send to the GC100 (since the light flashes when i send the command), but i don’t know what, any idea how to see what code is actualy sent?

I tried following

string.char(0x04,0xa0,0x60,0x00,0x00,0xfc,0x03),
string.char(0x02,0x04,0xa0,0x60,0x00,0x00,0xfc,0x03),

without the CR
luup.io.write(code))

with local CR = string.char(3) – i tried CR char 3 because is need HEX 03 (ETX)

string.char(0x04,0xa0,0x60,0x00,0x00,0xfc),
string.char(0x02,0x04,0xa0,0x60,0x00,0x00,0xfc),

luup.io.write(code…CR))

But no go
Remeber this is what needs to be received by the GC100
\x02\x04\xa0\x60\x00\x01\xfb\x03

any ideas?

Remeber this is what needs to be received by the GC100 \x02\x04\xa0\x60\x00\x01\xfb\x03

I’m not sure what you mean by this. If that is the code you want to send, why are you using different code strings? Just use this:

code = string.char(0x02,0x04,0xa0,0x60,0x00,0x01,0xfb,0x03) luup.io.write(code)