Control A/V equipment with RS232/USB/Ethernet
From LinuxMCE wiki
|Version||Status||Date Updated||Updated By|
How to set it up
Normally LinuxMCE can control RS32 and Ethernet devices much better than infrared because the communication is more accurate. Also most devices controlled by those means are bi-directional, meaning that the device can tell LinuxMCE when the user does something manually. This allows LinuxMCE to monitor the devices and see if the user manually turn it on or off and try to anticipate what the user wants to do and automatically follow through. So whenever possible we encourage users to get A/V equipment with RS232 or Ethernet interfaces.
We have a device called "Generic Serial Device" to make it easy to add support for these devices. Add the device to the system just like normal, as explained Control a TV or cable/satellite box. Click the "Advanced" button on the A/VB equipment page to view the device settings, and click the view button next to the device template. Checked the box "Implements DCE", and put this in the command line: Generic_Serial_Device
Now on the A/V equipment page click the "IR/GSD codes" button. Add the commands you want to support just like you would for infrared equipment as explained Control regular A/V equipment. The only difference is that instead you'll be entering the data to send the device to execute the command, or Ruby snippets. Ruby as a simple programming language, yet pretty powerful and flexible. Some simple devices do not have a structured command protocol, you simply send them the string of data to execute a command. For example, click Advanced, Device Templates, Manufacturer: Denon, Category: A/V - Amps/receivers, Model: AVC-A1SRA (RS232), and click "Edit". Under "Infrared Groups", click the "Edit Commands" next to "Denon AVR/AVC protocol #1300". This is a simple protocol--no programming was required. To turn the device off you send it PWSTANDBY follwed by a carriage return. You'll see the syntax is: <$"PWSTANDBY\r"$> where <$"XXX"$> sends XXX to the device, and \r sends a carriage return. You'll see a little snippet of Ruby code for the "On" command. Since we wanted to always unmute the receiver when we turn it on, so it starts in a known state, we need to send PWON followed by MUOFF, but with a 2 second delay in between. While some technical skills are required to setup a serial device, you'll see this is much easier than requiring device drives to be written in C++ or other some other programming language.
Some devices are not so simple and they require a more complicated command protocol including checksums and so on.. For this you'll need to use Ruby. Refer to other similar GSD devices to see how it is done, or contact LinuxMCE to get assistance from one of our programmers.
How to use it
Just add a media scenario for the device, as explained Control a TV or cable/satellite box
The Ruby snippets used by GSD are stored in the InfraredGroup_Command table in the pluto_main, just like Infrared Codes. Also, if you leave "Share my codes" box checked, the GSD codes will be shared too. The logic for determining what GSD codes each device uses is in Infrared_Plugin. The command is Get Infrared Codes--exactly the same like retrieving infrared codes. The GSD (see src/Generic_Serial_Device) is a C++ DCE device that includes an embedded Ruby engine. Whenever it receives a command it forwards it to the Ruby processor. The intent is to have a very light way that non-programmers can add support for the thousands of generic serial devices out there.