Onkyo Reciver RS232 plugin

Do you have questions about writing plugins or scripts in Python? Meet the coders here.
prostetnic
Posts: 28
Joined: Fri Apr 18, 2008 6:52 pm
Location: Sweden

Onkyo Reciver RS232 plugin

Post by prostetnic » Thu Sep 18, 2008 3:46 pm

Hi,

I have modified the Denon RS232 Plugin to work with my Onkyo TX-SR804E Reciver. Its not finished yet and I cant get any communication from the reciver to be turned into events yet.
Can anyone who understands Python take a look at the code and tell me if I'm doing anything wrong.

If I don't get it to work Ill probably just leave it as is and live with it.

Hopefully it will be helpful as is for all you Onkyo owners out there :)

Edit.
I use XP SP3 and have tried several versions of EG including the most recent build. I have also tried from both my laptop and desktop and with different cables.
Attachments
Onkyo_RS_232_RCVR_061207.zip
Onkyo RS 232 Protocol (was very hard to find)
(87.42 KiB) Downloaded 305 times
__init__.py
The EG plugin
(12.28 KiB) Downloaded 326 times

Bartman
Plugin Developer
Posts: 881
Joined: Sun Feb 12, 2006 9:03 am

Re: Onkyo Reciver RS232 plugin

Post by Bartman » Tue Sep 23, 2008 5:01 pm

ah great.
I'm thinking of buying an 805. Do you know if there are any differences between the models concerning the serial communication?

prostetnic
Posts: 28
Joined: Fri Apr 18, 2008 6:52 pm
Location: Sweden

Re: Onkyo Reciver RS232 plugin

Post by prostetnic » Tue Sep 23, 2008 8:40 pm

No there shouldn't be any big difference.
There might be some of the commands that don't work but probably not any key ones.
All the differences should be documented in the protocol I attached in my first post.

Bartman
Plugin Developer
Posts: 881
Joined: Sun Feb 12, 2006 9:03 am

Re: Onkyo Reciver RS232 plugin

Post by Bartman » Fri Oct 03, 2008 10:56 am

I ordered the 805 today.
Do you mind if I add the plugin to the SVN-repository so it appears in the next beta?
You can also have SVN-Access of your own.

prostetnic
Posts: 28
Joined: Fri Apr 18, 2008 6:52 pm
Location: Sweden

Re: Onkyo Reciver RS232 plugin

Post by prostetnic » Fri Oct 03, 2008 11:20 am

Bartman wrote:I ordered the 805 today.
:D I'm sure your going to be happy with it.
Bartman wrote: Do you mind if I add the plugin to the SVN-repository so it appears in the next beta?
You can also have SVN-Access of your own.
No I don't mind at all rather the opposite.
But as I said I haven't been able to get the event generation to work with my reciver so ether the code is wrong or my reciver don't work properly. I will be happy to update the plugin if you can give me feedback on if event generation works with your 805.

prostetnic
Posts: 28
Joined: Fri Apr 18, 2008 6:52 pm
Location: Sweden

Re: Onkyo Reciver RS232 plugin

Post by prostetnic » Tue Oct 07, 2008 8:20 pm

It seems like that the set master volume action doesn't work. Not sure why because the set sleep time command works alright and it works in the same way.

Bartman
Plugin Developer
Posts: 881
Joined: Sun Feb 12, 2006 9:03 am

Re: Onkyo Reciver RS232 plugin

Post by Bartman » Wed Oct 08, 2008 9:20 pm

I got my receiver yesterday and still confused by all the possible settings :)
Anyway I commited your plugin to the svn and I'm still testing it.
Mastervalue does not work for me too. I also get an error when disabling the plugin.

Edit:
The master value had a typo. I also added some toggle actions and commited the version to the repository. Maybe I can add event triggering. Does the original plugin have such a feature?

User avatar
Bitmonster
Site Admin
Posts: 2239
Joined: Mon Feb 06, 2006 10:28 pm

Re: Onkyo Reciver RS232 plugin

Post by Bitmonster » Wed Oct 08, 2008 9:55 pm

Most of these serial plugins are based on the Denon plugin code and it is a bit faulty. Actually all serial plugins should be rewritten to use the new eg.SerialThread code. It has a very convenient handling of asynchronous receive. But sadly we don't have a suitable demo of its use. The Barco plugin for example uses it, but it is also a very complicated plugin because it uses a rather odd protocol. And I personally have no other device that uses the serial port.
Please post software-related questions in the forum - PMs will only be answered, if really private, thanks!

Bartman
Plugin Developer
Posts: 881
Joined: Sun Feb 12, 2006 9:03 am

Re: Onkyo Reciver RS232 plugin

Post by Bartman » Wed Oct 08, 2008 10:01 pm

If all the protocolls are that similiar wouldn't it be possible to write just one plugin and create a configuration file for a device?

User avatar
Bitmonster
Site Admin
Posts: 2239
Joined: Mon Feb 06, 2006 10:28 pm

Re: Onkyo Reciver RS232 plugin

Post by Bitmonster » Wed Oct 08, 2008 10:05 pm

They aren't so similar in details like checksum handling and the control flow, so it wouldn't be possible to write something as easy as all the SendMessage plugins for example, that only differ in some constants.
Please post software-related questions in the forum - PMs will only be answered, if really private, thanks!

Bartman
Plugin Developer
Posts: 881
Joined: Sun Feb 12, 2006 9:03 am

Re: Onkyo Reciver RS232 plugin

Post by Bartman » Wed Oct 08, 2008 10:20 pm

Code: Select all

        
        self.serialThread = eg.SerialThread()
        self.serialThread.SetReadEventCallback(self.OnReceive)
        self.serialThread.Open(port, baudrate)
        self.serialThread.SetRts()
        self.serialThread.Start()
Write an OnReceive callback and write with self.serialThread()? Am I missing anything? Sounds pretty easy?

User avatar
Bitmonster
Site Admin
Posts: 2239
Joined: Mon Feb 06, 2006 10:28 pm

Re: Onkyo Reciver RS232 plugin

Post by Bitmonster » Wed Oct 08, 2008 10:28 pm

Yes, this is basically it. It has some more features if you want to temporarily switch to synchronous handling. For example the callback might wait for some event from the device, but if you have to do some action, a kind of challenge/response pattern might be needed in the action. Then you can use SuspendReadEvents() before you synchronously want to read the port and ResumeReadEvents() afterwards to re-enable the callback.

And the Read() method can (and should) then also be used with a timeout value.
Please post software-related questions in the forum - PMs will only be answered, if really private, thanks!

User avatar
Bitmonster
Site Admin
Posts: 2239
Joined: Mon Feb 06, 2006 10:28 pm

Re: Onkyo Reciver RS232 plugin

Post by Bitmonster » Wed Oct 08, 2008 10:40 pm

Oh, and it would be fine, if the cmdList could be refactored for use with PluginClass.AddActionsFromList()

The Denon plugin was the first plugin not written by me, so OWagner hadn't the possibilities plugin coders now have.
Please post software-related questions in the forum - PMs will only be answered, if really private, thanks!

prostetnic
Posts: 28
Joined: Fri Apr 18, 2008 6:52 pm
Location: Sweden

Re: Onkyo Reciver RS232 plugin

Post by prostetnic » Wed Oct 08, 2008 10:42 pm

Bartman wrote:I got my receiver yesterday and still confused by all the possible settings :)
Anyway I commited your plugin to the svn and I'm still testing it.
Mastervalue does not work for me too. I also get an error when disabling the plugin.
The pure audio setting is pretty good. You can test it by comparing it to stereo mode with max volume but without any media playing. Just listen to the noise levels.
Bartman wrote:Edit:
The master value had a typo. I also added some toggle actions and commited the version to the repository. Maybe I can add event triggering. Does the original plugin have such a feature?
I really do hate being dyslectic it makes programing a living hell ;)
I did try to get triggering to work but since couldn't get it right so I abandoned the plugin for a while since I'm busy with other projects. So I posted my half finished plugin in hope of someone helping me out with the triggering :D

I will revisit the code this weekend if I have any spare time and to get it to work unless you guys bet me to it :)

Thanks for your help and interest :D

User avatar
Bitmonster
Site Admin
Posts: 2239
Joined: Mon Feb 06, 2006 10:28 pm

Re: Onkyo Reciver RS232 plugin

Post by Bitmonster » Wed Oct 08, 2008 10:47 pm

Two other notes:
1. In your actions you actually should always use SuspendReadEvents() and ResumeReadEvents() to inform the thread you want to do something on the port. Even if you only want to write something.
2. Inside the callback registered with SetReadEventCallback you don't need to do it, as the port is then exclusively in use of the callback. So you can use .Write() and .Read() there without problems, but should leave the callback as soon as possible to give actions the ability to execute.
Please post software-related questions in the forum - PMs will only be answered, if really private, thanks!

Post Reply