It's been 15 years since I wrote any code, and never before in Python, so I am sure there are some things that could be improved. Never-the-less, the plug-in does what it is supposed to do... It controls most of the receiver functions (that can be controlled by RS232), and generates events for most of the reports that the RX-V100 produces.
I must give credit to Oliver Wagner, upon who'se Denon Serial plug-in code this plug-in is based.
Yamaha Serial Plug-in
Hint: You can convert a hex-string to an integer simply with the built-in "int()" function in Python:
So, "newdbValue = int(volstring, 16) * step - 99.5" should do the trick.int( [x[, radix]])
Convert a string or number to a plain integer. If the argument is a string, it must contain a possibly signed decimal number representable as a Python integer, possibly embedded in whitespace. The radix parameter gives the base for the conversion and may be any integer in the range [2, 36], or zero. If radix is zero, the proper radix is guessed based on the contents of string; the interpretation is the same as for integer literals. If radix is specified and x is not a string, TypeError is raised. Otherwise, the argument may be a plain or long integer or a floating point number. Conversion of floating point numbers to integers truncates (towards zero). If the argument is outside the integer range a long object will be returned instead. If no arguments are given, returns 0.
I also had some trouble with variable scope, but this object oriented stuff is pretty new to me. I wanted to define global constants for STX, ETX DC1, DC2 and DC3. Apparently they're already part of the curses libraries, but I couldn't figure out how to use them. Since I really only wanted them for code readability, I settled for the "\x02" version of STX (I guess I could have used chr(02) as well).
I am working on decoding the "power on" event string, so I'll fix the hex--> int conversion at the same time.
Global scope is easy: just define them at the main level, as you did for "cmdList".
STX = "\x02"
Then you can use this constants everywhere in your module, as long as this name is not defined again at the local name space, like:
self.plugin.serial.write(cmd + STX)
if STX in cmd:
and so on
http://docs.python.org/tut/node11.html# ... 0000000000
I am having some problems with EventGhost with my serial control. I have a Yamaha RXV-2400 and a Panasonic commercial plasma. I have not been able to control either device regardless of the commands I send. I do have both working within Meedio; here are the codes I use in Meedio for reference.
Yamaha Power On &H02 30 37 41 31 44 03
Yamaha Volume UP &H02 30 37 41 31 41 03
Panasonic Power On &H02 50 4F 4E 03
Panasonic Power Off &H02 50 4F 46 03
If I put this information in EventGhost, I get no response from my equipment. I did try the Yamaha plugin, which does work, but I would like to add additional commands that aren’t there. I opened the plugin files from the installation directory to try and figure out what needs to be entered in the serial plugin, but no variation of characters from that screen worked either. I need to understand how EventGhost wants its data. In the Panasonic manual it shows the commands as follows:
Power On STX PON ETX
Power Off STX POF ETX
If you look at my Meedio commands, it makes sense. What do I put in EventGhost to control these devices?
Once I get my devices controlled, the next issue will be toggling. If I want to push Power on my remote to turn both devices On, then push the same button, to turn both devices Off. Is there a toggle plugin, or setting?
Thanks in advance for any help.
&H02 30 37 41 31 44 03
must be written:
STX and ETX are names of control codes. You have to look them up in an ascii chart. http://www.asciitable.com/
For toggling look in the Example.xml (Other Examples folder).
The protocoll is documented and can be downloaded at http://www.yamaha-service.de/downloadyo ... dprod=1417
Probably I only need to switch between DSP programs.