<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://wiki.linuxmce.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Tamjid</id>
	<title>LinuxMCE - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="http://wiki.linuxmce.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Tamjid"/>
	<link rel="alternate" type="text/html" href="http://wiki.linuxmce.org/index.php/Special:Contributions/Tamjid"/>
	<updated>2026-07-22T00:40:04Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.44.0</generator>
	<entry>
		<id>http://wiki.linuxmce.org/index.php?title=Implementing_Clipsal_Interface_using_Generic_Serial_Device&amp;diff=4003</id>
		<title>Implementing Clipsal Interface using Generic Serial Device</title>
		<link rel="alternate" type="text/html" href="http://wiki.linuxmce.org/index.php?title=Implementing_Clipsal_Interface_using_Generic_Serial_Device&amp;diff=4003"/>
		<updated>2007-06-20T08:01:42Z</updated>

		<summary type="html">&lt;p&gt;Tamjid: /* Explanation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Clipsal Switches are used for controlling lights, curtains and temperature controls. They can be connected to the Serial Port and can be controlled via a PC. In the following tutorial, we will add Clipsal Switches using Generic Serial Device and implement Lights and Shutter control through the Linux MCE.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Steps to Add Clipsal Interface ==&lt;br /&gt;
&lt;br /&gt;
* Create a Device Template &#039;Clipsal Interface&#039; in Device Category: &amp;quot;Interfaces - Lighting Interface #81&amp;quot;&lt;br /&gt;
* Check Implements DCE - Command Line - Generic Serial Device&lt;br /&gt;
* In the packages, add &amp;quot;Pluto Generic Serial Device&amp;quot;&lt;br /&gt;
* In Device Data, add &amp;quot;#37 COM Port on PC(string)&amp;quot;&lt;br /&gt;
* In Commands Section, create and select &amp;quot;Ruby Internal Commands&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This Clipsal Interface will act as a parent device to all the child devices (eg. Lights, Curtains) that are controlled via the serial port to which Clipsal Switch is connected. Now create a device from the device template Clipsal Interface.&lt;br /&gt;
&lt;br /&gt;
== Ruby Commands for Lighting ==&lt;br /&gt;
&lt;br /&gt;
The Clipsal Interface will have all the lighting and curtains as its child devices. The commands from child devices will be directed to Clipsal Interface and this interface will send these commands to the serial port to which clipsal switch is connected.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For the Clipsal Interface, following ruby commands will be implemented:&lt;br /&gt;
&lt;br /&gt;
* #Private Method Listing #373&lt;br /&gt;
* #Process IDLE #351&lt;br /&gt;
* #Process Incoming Data #350&lt;br /&gt;
* #Process Initialize #355&lt;br /&gt;
* #Process Receive Command For Child #384&lt;br /&gt;
* #Process Release #356&lt;br /&gt;
&lt;br /&gt;
The most important of this command is #Process Receive Command For Child #384, which is process incoming data from child devices. When we receive any command from child device such as Light or Shutter, the ruby commands in this section are invoked and we need to send relevant commands to the serial port to carry out the action on lights or shutters.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To edit the Ruby Commands for #384 Process Receive Command For Child, Edit the Clipsal Interface and click on &#039;Edit Ruby Codes&#039; besides Implements DCE on the top.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Ruby Code ==&lt;br /&gt;
&lt;br /&gt;
   group_no = device_.childdevices_[cmd.devidto_].devdata_[12]&lt;br /&gt;
   &lt;br /&gt;
   if cmd.id_ == 192&lt;br /&gt;
      serial_on = &amp;quot;\\05380079&amp;quot;+group_no+&amp;quot;\r&amp;quot;&lt;br /&gt;
      log( &amp;quot;Sending &amp;quot; + serial_on + &amp;quot; \n&amp;quot; )&lt;br /&gt;
      sendCmd(serial_on)&lt;br /&gt;
   end&lt;br /&gt;
   &lt;br /&gt;
   if cmd.id_ == 193&lt;br /&gt;
      serial_off = &amp;quot;\\05380001&amp;quot;+group_no+&amp;quot;\r&amp;quot;&lt;br /&gt;
      log( &amp;quot;Sending &amp;quot; + serial_off + &amp;quot; \n&amp;quot; )&lt;br /&gt;
      sendCmd(serial_off)&lt;br /&gt;
   end&lt;br /&gt;
   &lt;br /&gt;
   log(&amp;quot;We got cmd : &amp;quot; + cmd.id.to_s)&lt;br /&gt;
   &lt;br /&gt;
   if cmd.id_ == 184&lt;br /&gt;
      dim_level = cmd.params_[76]&lt;br /&gt;
      serial_dim = &amp;quot;\\05380002&amp;quot;+group_no+&amp;quot;&amp;quot;+dim_level+&amp;quot;\r&amp;quot;&lt;br /&gt;
      log( &amp;quot;Sending &amp;quot; + serial_dim + &amp;quot; \n&amp;quot;)&lt;br /&gt;
      sendCmd(serial_dim)&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
== Explanation ==&lt;br /&gt;
&lt;br /&gt;
In the ruby code, what is happening is when we receive a command from any of the child devices (such as lights, curtains), we also get its port number. Then, using that port number we make a binary string to be sent to the serial port. That binary string is sent to the serial port defined in the Clipsal Interface Device Data.&lt;br /&gt;
&lt;br /&gt;
eg. Command # 192 is the command to switch light ON. The binary string to switch a light ON to be sent to the serial port is:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
\05380079 + Port Number + \r&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
So, we receive the port number from child device (group_no), concatenate it in the binary string and send it to the serial port defined in the Clipsal Interface.&lt;/div&gt;</summary>
		<author><name>Tamjid</name></author>
	</entry>
	<entry>
		<id>http://wiki.linuxmce.org/index.php?title=Implementing_Clipsal_Interface_using_Generic_Serial_Device&amp;diff=4002</id>
		<title>Implementing Clipsal Interface using Generic Serial Device</title>
		<link rel="alternate" type="text/html" href="http://wiki.linuxmce.org/index.php?title=Implementing_Clipsal_Interface_using_Generic_Serial_Device&amp;diff=4002"/>
		<updated>2007-06-20T08:01:00Z</updated>

		<summary type="html">&lt;p&gt;Tamjid: /* Ruby Code */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Clipsal Switches are used for controlling lights, curtains and temperature controls. They can be connected to the Serial Port and can be controlled via a PC. In the following tutorial, we will add Clipsal Switches using Generic Serial Device and implement Lights and Shutter control through the Linux MCE.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Steps to Add Clipsal Interface ==&lt;br /&gt;
&lt;br /&gt;
* Create a Device Template &#039;Clipsal Interface&#039; in Device Category: &amp;quot;Interfaces - Lighting Interface #81&amp;quot;&lt;br /&gt;
* Check Implements DCE - Command Line - Generic Serial Device&lt;br /&gt;
* In the packages, add &amp;quot;Pluto Generic Serial Device&amp;quot;&lt;br /&gt;
* In Device Data, add &amp;quot;#37 COM Port on PC(string)&amp;quot;&lt;br /&gt;
* In Commands Section, create and select &amp;quot;Ruby Internal Commands&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This Clipsal Interface will act as a parent device to all the child devices (eg. Lights, Curtains) that are controlled via the serial port to which Clipsal Switch is connected. Now create a device from the device template Clipsal Interface.&lt;br /&gt;
&lt;br /&gt;
== Ruby Commands for Lighting ==&lt;br /&gt;
&lt;br /&gt;
The Clipsal Interface will have all the lighting and curtains as its child devices. The commands from child devices will be directed to Clipsal Interface and this interface will send these commands to the serial port to which clipsal switch is connected.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For the Clipsal Interface, following ruby commands will be implemented:&lt;br /&gt;
&lt;br /&gt;
* #Private Method Listing #373&lt;br /&gt;
* #Process IDLE #351&lt;br /&gt;
* #Process Incoming Data #350&lt;br /&gt;
* #Process Initialize #355&lt;br /&gt;
* #Process Receive Command For Child #384&lt;br /&gt;
* #Process Release #356&lt;br /&gt;
&lt;br /&gt;
The most important of this command is #Process Receive Command For Child #384, which is process incoming data from child devices. When we receive any command from child device such as Light or Shutter, the ruby commands in this section are invoked and we need to send relevant commands to the serial port to carry out the action on lights or shutters.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To edit the Ruby Commands for #384 Process Receive Command For Child, Edit the Clipsal Interface and click on &#039;Edit Ruby Codes&#039; besides Implements DCE on the top.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Ruby Code ==&lt;br /&gt;
&lt;br /&gt;
   group_no = device_.childdevices_[cmd.devidto_].devdata_[12]&lt;br /&gt;
   &lt;br /&gt;
   if cmd.id_ == 192&lt;br /&gt;
      serial_on = &amp;quot;\\05380079&amp;quot;+group_no+&amp;quot;\r&amp;quot;&lt;br /&gt;
      log( &amp;quot;Sending &amp;quot; + serial_on + &amp;quot; \n&amp;quot; )&lt;br /&gt;
      sendCmd(serial_on)&lt;br /&gt;
   end&lt;br /&gt;
   &lt;br /&gt;
   if cmd.id_ == 193&lt;br /&gt;
      serial_off = &amp;quot;\\05380001&amp;quot;+group_no+&amp;quot;\r&amp;quot;&lt;br /&gt;
      log( &amp;quot;Sending &amp;quot; + serial_off + &amp;quot; \n&amp;quot; )&lt;br /&gt;
      sendCmd(serial_off)&lt;br /&gt;
   end&lt;br /&gt;
   &lt;br /&gt;
   log(&amp;quot;We got cmd : &amp;quot; + cmd.id.to_s)&lt;br /&gt;
   &lt;br /&gt;
   if cmd.id_ == 184&lt;br /&gt;
      dim_level = cmd.params_[76]&lt;br /&gt;
      serial_dim = &amp;quot;\\05380002&amp;quot;+group_no+&amp;quot;&amp;quot;+dim_level+&amp;quot;\r&amp;quot;&lt;br /&gt;
      log( &amp;quot;Sending &amp;quot; + serial_dim + &amp;quot; \n&amp;quot;)&lt;br /&gt;
      sendCmd(serial_dim)&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
== Explanation ==&lt;br /&gt;
&lt;br /&gt;
In the ruby code, what is happening is when we receive a command from any of the child devices (such as lights, curtains), we also get its port number. Then, using that port number we make a binary string to be sent to the serial port. That binary string is sent to the serial port defined in the Clipsal Interface Device Data.&lt;br /&gt;
&lt;br /&gt;
eg. Command # 192 is the command to switch light ON. The binary string to switch a light ON to be sent to the serial port is:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
\05380079 + Port Number + \r&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
So, we receive the port number from child device (group_no), concatenate it in the binary string and send it to the serial port defined in the Clipsal Interface.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This page is under authoring. More details coming soon.&lt;/div&gt;</summary>
		<author><name>Tamjid</name></author>
	</entry>
	<entry>
		<id>http://wiki.linuxmce.org/index.php?title=Implementing_Clipsal_Interface_using_Generic_Serial_Device&amp;diff=4001</id>
		<title>Implementing Clipsal Interface using Generic Serial Device</title>
		<link rel="alternate" type="text/html" href="http://wiki.linuxmce.org/index.php?title=Implementing_Clipsal_Interface_using_Generic_Serial_Device&amp;diff=4001"/>
		<updated>2007-06-20T07:58:12Z</updated>

		<summary type="html">&lt;p&gt;Tamjid: /* Steps to Add Clipsal Interface */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Clipsal Switches are used for controlling lights, curtains and temperature controls. They can be connected to the Serial Port and can be controlled via a PC. In the following tutorial, we will add Clipsal Switches using Generic Serial Device and implement Lights and Shutter control through the Linux MCE.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Steps to Add Clipsal Interface ==&lt;br /&gt;
&lt;br /&gt;
* Create a Device Template &#039;Clipsal Interface&#039; in Device Category: &amp;quot;Interfaces - Lighting Interface #81&amp;quot;&lt;br /&gt;
* Check Implements DCE - Command Line - Generic Serial Device&lt;br /&gt;
* In the packages, add &amp;quot;Pluto Generic Serial Device&amp;quot;&lt;br /&gt;
* In Device Data, add &amp;quot;#37 COM Port on PC(string)&amp;quot;&lt;br /&gt;
* In Commands Section, create and select &amp;quot;Ruby Internal Commands&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This Clipsal Interface will act as a parent device to all the child devices (eg. Lights, Curtains) that are controlled via the serial port to which Clipsal Switch is connected. Now create a device from the device template Clipsal Interface.&lt;br /&gt;
&lt;br /&gt;
== Ruby Commands for Lighting ==&lt;br /&gt;
&lt;br /&gt;
The Clipsal Interface will have all the lighting and curtains as its child devices. The commands from child devices will be directed to Clipsal Interface and this interface will send these commands to the serial port to which clipsal switch is connected.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For the Clipsal Interface, following ruby commands will be implemented:&lt;br /&gt;
&lt;br /&gt;
* #Private Method Listing #373&lt;br /&gt;
* #Process IDLE #351&lt;br /&gt;
* #Process Incoming Data #350&lt;br /&gt;
* #Process Initialize #355&lt;br /&gt;
* #Process Receive Command For Child #384&lt;br /&gt;
* #Process Release #356&lt;br /&gt;
&lt;br /&gt;
The most important of this command is #Process Receive Command For Child #384, which is process incoming data from child devices. When we receive any command from child device such as Light or Shutter, the ruby commands in this section are invoked and we need to send relevant commands to the serial port to carry out the action on lights or shutters.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To edit the Ruby Commands for #384 Process Receive Command For Child, Edit the Clipsal Interface and click on &#039;Edit Ruby Codes&#039; besides Implements DCE on the top.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Ruby Code ==&lt;br /&gt;
&lt;br /&gt;
group_no = device_.childdevices_[cmd.devidto_].devdata_[12]&lt;br /&gt;
&lt;br /&gt;
if cmd.id_ == 192&lt;br /&gt;
serial_on = &amp;quot;\\05380079&amp;quot;+group_no+&amp;quot;\r&amp;quot;&lt;br /&gt;
log( &amp;quot;Sending &amp;quot; + serial_on + &amp;quot; \n&amp;quot; )&lt;br /&gt;
sendCmd(serial_on)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
if cmd.id_ == 193&lt;br /&gt;
serial_off = &amp;quot;\\05380001&amp;quot;+group_no+&amp;quot;\r&amp;quot;&lt;br /&gt;
log( &amp;quot;Sending &amp;quot; + serial_off + &amp;quot; \n&amp;quot; )&lt;br /&gt;
sendCmd(serial_off)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
log(&amp;quot;We got cmd : &amp;quot; + cmd.id.to_s)&lt;br /&gt;
&lt;br /&gt;
if cmd.id_ == 184&lt;br /&gt;
dim_level = cmd.params_[76]&lt;br /&gt;
serial_dim = &amp;quot;\\05380002&amp;quot;+group_no+&amp;quot;&amp;quot;+dim_level+&amp;quot;\r&amp;quot;&lt;br /&gt;
log( &amp;quot;Sending &amp;quot; + serial_dim + &amp;quot; \n&amp;quot;)&lt;br /&gt;
sendCmd(serial_dim)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Explanation ==&lt;br /&gt;
&lt;br /&gt;
In the ruby code, what is happening is when we receive a command from any of the child devices (such as lights, curtains), we also get its port number. Then, using that port number we make a binary string to be sent to the serial port. That binary string is sent to the serial port defined in the Clipsal Interface Device Data.&lt;br /&gt;
&lt;br /&gt;
eg. Command # 192 is the command to switch light ON. The binary string to switch a light ON to be sent to the serial port is:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
\05380079 + Port Number + \r&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
So, we receive the port number from child device (group_no), concatenate it in the binary string and send it to the serial port defined in the Clipsal Interface.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This page is under authoring. More details coming soon.&lt;/div&gt;</summary>
		<author><name>Tamjid</name></author>
	</entry>
	<entry>
		<id>http://wiki.linuxmce.org/index.php?title=Here_is_a_detailed_example_of_how_to_add_Clipsal_Interface_using_Generic_Serial_Device.&amp;diff=4000</id>
		<title>Here is a detailed example of how to add Clipsal Interface using Generic Serial Device.</title>
		<link rel="alternate" type="text/html" href="http://wiki.linuxmce.org/index.php?title=Here_is_a_detailed_example_of_how_to_add_Clipsal_Interface_using_Generic_Serial_Device.&amp;diff=4000"/>
		<updated>2007-06-17T12:49:46Z</updated>

		<summary type="html">&lt;p&gt;Tamjid: Here is a detailed example of how to add Clipsal Interface using Generic Serial Device. moved to Implementing Clipsal Interface using Generic Serial Device&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#redirect [[Implementing Clipsal Interface using Generic Serial Device]]&lt;/div&gt;</summary>
		<author><name>Tamjid</name></author>
	</entry>
	<entry>
		<id>http://wiki.linuxmce.org/index.php?title=Implementing_Clipsal_Interface_using_Generic_Serial_Device&amp;diff=3999</id>
		<title>Implementing Clipsal Interface using Generic Serial Device</title>
		<link rel="alternate" type="text/html" href="http://wiki.linuxmce.org/index.php?title=Implementing_Clipsal_Interface_using_Generic_Serial_Device&amp;diff=3999"/>
		<updated>2007-06-17T12:49:46Z</updated>

		<summary type="html">&lt;p&gt;Tamjid: Here is a detailed example of how to add Clipsal Interface using Generic Serial Device. moved to Implementing Clipsal Interface using Generic Serial Device&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Clipsal Switches are used for controlling lights, curtains and temperature controls. They can be connected to the Serial Port and can be controlled via a PC. In the following tutorial, we will add Clipsal Switches using Generic Serial Device and implement Lights and Shutter control through the Linux MCE.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Steps to Add Clipsal Interface ==&lt;br /&gt;
&lt;br /&gt;
* Create a Device Template &#039;Clipsal Interface&#039; in Device Category: &amp;quot;Interfaces - Lighting Interface #81&amp;quot;&lt;br /&gt;
* In the packages, add &amp;quot;Pluto Generic Serial Device&amp;quot;&lt;br /&gt;
* In Device Data, add &amp;quot;#37 COM Port on PC(string)&amp;quot;&lt;br /&gt;
* In Commands Section, create and select &amp;quot;Ruby Internal Commands&amp;quot;&lt;br /&gt;
&lt;br /&gt;
This Clipsal Interface will act as a parent device to all the child devices (eg. Lights, Curtains) that are controlled via the serial port to which Clipsal Switch is connected.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This page is under authoring. More details coming soon.&lt;/div&gt;</summary>
		<author><name>Tamjid</name></author>
	</entry>
	<entry>
		<id>http://wiki.linuxmce.org/index.php?title=Implementing_Clipsal_Interface_using_Generic_Serial_Device&amp;diff=3998</id>
		<title>Implementing Clipsal Interface using Generic Serial Device</title>
		<link rel="alternate" type="text/html" href="http://wiki.linuxmce.org/index.php?title=Implementing_Clipsal_Interface_using_Generic_Serial_Device&amp;diff=3998"/>
		<updated>2007-06-17T12:49:12Z</updated>

		<summary type="html">&lt;p&gt;Tamjid: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Clipsal Switches are used for controlling lights, curtains and temperature controls. They can be connected to the Serial Port and can be controlled via a PC. In the following tutorial, we will add Clipsal Switches using Generic Serial Device and implement Lights and Shutter control through the Linux MCE.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Steps to Add Clipsal Interface ==&lt;br /&gt;
&lt;br /&gt;
* Create a Device Template &#039;Clipsal Interface&#039; in Device Category: &amp;quot;Interfaces - Lighting Interface #81&amp;quot;&lt;br /&gt;
* In the packages, add &amp;quot;Pluto Generic Serial Device&amp;quot;&lt;br /&gt;
* In Device Data, add &amp;quot;#37 COM Port on PC(string)&amp;quot;&lt;br /&gt;
* In Commands Section, create and select &amp;quot;Ruby Internal Commands&amp;quot;&lt;br /&gt;
&lt;br /&gt;
This Clipsal Interface will act as a parent device to all the child devices (eg. Lights, Curtains) that are controlled via the serial port to which Clipsal Switch is connected.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This page is under authoring. More details coming soon.&lt;/div&gt;</summary>
		<author><name>Tamjid</name></author>
	</entry>
	<entry>
		<id>http://wiki.linuxmce.org/index.php?title=Generic_Serial_Device&amp;diff=3997</id>
		<title>Generic Serial Device</title>
		<link rel="alternate" type="text/html" href="http://wiki.linuxmce.org/index.php?title=Generic_Serial_Device&amp;diff=3997"/>
		<updated>2007-06-17T12:38:33Z</updated>

		<summary type="html">&lt;p&gt;Tamjid: /* Short example */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:GSD]]&lt;br /&gt;
[[Category:LinuxMCE_Devices]]&lt;br /&gt;
Generic_Serial_Device (also knowk as &#039;&#039;&#039;GSD&#039;&#039;&#039;) is a LinuxMCE device that allows end-user to do simple programming for RS232, serial USB or network connected devices.&lt;br /&gt;
:Note : The information is not quite complete because I&#039;m not the original author.&lt;br /&gt;
&lt;br /&gt;
== Short description ==&lt;br /&gt;
It&#039;s a standard DCE device, it only can execute commands and send events .&lt;br /&gt;
The main idea is instead of programming a device in C++, compile, link with proper libraries you can edit (in a webpage) few lines of code in ruby which will be executed when device receives that command. It exports several objects into ruby so you&#039;ll have access to devicedata, device hierarchy, established connection and so on.&lt;br /&gt;
&lt;br /&gt;
The ruby code for each device template is stored somewhere in &#039;&#039;InfraredGroup_Command&#039;&#039; table. To edit the code go to Wizard&amp;gt; Devices &amp;gt; Generic_Serial_Devices on [[LinuxMCE-admin]] website. You have to add a device from a device template in order to see anything in that page.&lt;br /&gt;
&lt;br /&gt;
Select the device, and click &amp;quot;RubyCodes&amp;quot; button to be able to edit code that will be executed. &lt;br /&gt;
You should be able to see commands that are specified in device template (like ON/OFF/WhateverElse) and a group of &#039;&#039;Internal Commands&#039;&#039; which are used to perform certain actions are to add helper functions.&lt;br /&gt;
&lt;br /&gt;
If the command you are trying to add doesn&#039;t show on first page, go to &#039;&#039;Add/Remove commands&#039;&#039; and add more commands for your device.&lt;br /&gt;
&lt;br /&gt;
=== Ruby source code ===&lt;br /&gt;
&lt;br /&gt;
There are 2 forms of ruby code you can write :&lt;br /&gt;
* standard ruby code (check [http://www.ruby-lang.org/en/] and [http://poignantguide.net/ruby/] for syntax, references and programming guides)&lt;br /&gt;
* short form for &#039;&#039;&#039;conn_.Send&#039;&#039;&#039;&lt;br /&gt;
 &amp;lt;$&amp;quot;PWON\r&amp;quot;$&amp;gt;&lt;br /&gt;
:which simply will send the string &#039;&#039;&amp;quot;PWON\r&amp;quot;&#039;&#039; to device.&lt;br /&gt;
&lt;br /&gt;
You&#039;ll have to quick reload router to get new code. Restarting GSD only will keep old code because the code is supplied by [[Infrared_Plugin]] which caches pluto_main and won&#039;t update it&#039;s cache without full restart of [[DCERouter]]. With this code it creates a ruby source which will be interpreted by embedded ruby.&lt;br /&gt;
&lt;br /&gt;
It will create methods called &amp;quot;cmd_CmdIDx&amp;quot; for each command(x) defined in web interface except &#039;&#039;Private_Method_Listing&#039;&#039; which will be inserted in the body of the class directly without wrapping.&lt;br /&gt;
&lt;br /&gt;
The source usually looks like (&#039;&#039;DevID&#039;&#039; is iPK_Device of specific device, &#039;&#039;CmdIDx&#039;&#039; is iPK_Command ) :&lt;br /&gt;
&lt;br /&gt;
 require &#039;Ruby_Generic_Serial_Device&#039;&lt;br /&gt;
 class Command &amp;lt; Ruby_Generic_Serial_Device::RubyCommandWrapper&lt;br /&gt;
 end&lt;br /&gt;
 class Device_DevID &amp;lt; Ruby_Generic_Serial_Device::RubySerialWrapper&lt;br /&gt;
 def cmd_CmdID1(paramlist)&lt;br /&gt;
     @returnParamArray.clear&lt;br /&gt;
     ### WEB CODE for CmdID1 GOES HERE ###&lt;br /&gt;
     return @returnParamArray&lt;br /&gt;
 end&lt;br /&gt;
 def cmd_CmdID2(paramlist)&lt;br /&gt;
     @returnParamArray.clear&lt;br /&gt;
     ### WEB CODE for CmdID2 GOES HERE ###&lt;br /&gt;
     return @returnParamArray&lt;br /&gt;
 end&lt;br /&gt;
 ...&lt;br /&gt;
 def cmd_ReceiveCommandForChild(cmd)&lt;br /&gt;
     ### Process_Receive Command_For_Child GOES HERE ###&lt;br /&gt;
 end&lt;br /&gt;
 ...&lt;br /&gt;
 ### Private_Method_Listing GOES HERE ###&lt;br /&gt;
 ...&lt;br /&gt;
 def initialize()&lt;br /&gt;
     super&lt;br /&gt;
     @returnParamArray=Array.new&lt;br /&gt;
 end&lt;br /&gt;
 ### Generated Setters/Getters goes here (may be empty, but usually looks like below) ###&lt;br /&gt;
 def data_set(value)&lt;br /&gt;
     @returnParamArray[19]=value&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
There might be more then one class definition in that source. This may happen when child device is itself a GSD device.&lt;br /&gt;
&lt;br /&gt;
=== Command details ===&lt;br /&gt;
When the command from DCE arrives it is routed to specific device and &#039;&#039;cmd_XXX&#039;&#039; is run. The commands are run one by one, meaning that you cannot run 2 commands simultaneously. This limitation is implied by embedded ruby interpretor which fails if run from multiple threads.&lt;br /&gt;
DCE commands may have return parameters (well known GetVideoFrame), as ruby can return only 1 parameter the &#039;&#039;@returnParamArray&#039;&#039; was added. You can see that in each method we insert &#039;&#039;&#039;@returnParamArray.clear&#039;&#039;&#039; then the real code and then &#039;&#039;&#039;return @returnParamArray&#039;&#039;&#039;. Also some setters are generated (like the one from above) for code readability.&lt;br /&gt;
&lt;br /&gt;
Beside usual DCE command you&#039;ll see some &#039;&#039;Internal Commands&#039;&#039;. Here goes a small list and what they do:&lt;br /&gt;
* &#039;&#039;&#039;Private Method Listing&#039;&#039;&#039; - used to insert all kind of helpers&lt;br /&gt;
* &#039;&#039;&#039;Process IDLE&#039;&#039;&#039; - method executed once in a while (may be used to keep connection alive, scan for new devices on serial bus)&lt;br /&gt;
* &#039;&#039;&#039;Process Incoming Data&#039;&#039;&#039; - called when some data is available &lt;br /&gt;
* &#039;&#039;&#039;Process Receive Command For Child&#039;&#039;&#039; - called if the device has children and those are pretty dummy (like Lights under CM11), so practically the parent will do the job. As a parameter you have &#039;&#039;cmd&#039;&#039; which is a wrapper for DCEMessage, so you&#039;ll have access to deviceId, senderId, commandID and so on.&lt;br /&gt;
* &#039;&#039;&#039;Process Initialize&#039;&#039;&#039; - called when device is starting (to perform handshake with device or some other initialisation required by protocol)&lt;br /&gt;
* &#039;&#039;&#039;Process Release&#039;&#039;&#039; - to close gracefully connection with device (say &amp;quot;good bye&amp;quot; or something)&lt;br /&gt;
&lt;br /&gt;
== Implementation notes ==&lt;br /&gt;
There are several classes that actually need to be touched. Most of the other classes are just for wrapping DCE objects (like Device, Message, Connection and so on) and exporting them into ruby.&lt;br /&gt;
&lt;br /&gt;
Most important classes :&lt;br /&gt;
* &#039;&#039;&#039;RubyDCEDeviceNode&#039;&#039;&#039; is actually the Device, responsable with initialisation and partially a message handler.&lt;br /&gt;
* &#039;&#039;&#039;RubyDCEEmbededClass&#039;&#039;&#039; is bridge between DeviceNode and ruby, it has &#039;&#039;CallCmdHandler&#039;&#039; which does the real call to ruby and sends back result.&lt;br /&gt;
* &#039;&#039;&#039;RubyIOManager&#039;&#039;&#039; is the one responsible for instantiating RubyDCEDeviceNodes, code retrieval, command handler and serializing ruby calls.&lt;br /&gt;
* &#039;&#039;&#039;RubyDCECodeSupplier&#039;&#039;&#039; gives you the ruby code&lt;br /&gt;
* &#039;&#039;&#039;RubyCommandWrapper&#039;&#039;&#039; a wrapper for Message&lt;br /&gt;
* &#039;&#039;&#039;GSDMessageProcessing&#039;&#039;&#039; is [[Message_Translation|message translator]] which will try to run command if it&#039;s implemented without translation.&lt;br /&gt;
* &#039;&#039;&#039;RubySerialIOConnectionWrapper&#039;&#039;&#039; helps to wrap Serial and TCP/IP based connection under same interface, see down the hierarchy the connection you need.&lt;br /&gt;
&lt;br /&gt;
There are also some files needed for building a library for ruby with SWIG, let them alone, it should work.&lt;br /&gt;
&lt;br /&gt;
The compilation will give you &#039;&#039;&#039;Generic_Serial_Device&#039;&#039;&#039; and &#039;&#039;&#039;Ruby_Generic_Serial_Device.so&#039;&#039;&#039;, first file is the binary itself, second file is the bridge library and it will be included by ruby (the request for it is in the first line of the generated source)&lt;br /&gt;
&lt;br /&gt;
== Known issues ==&lt;br /&gt;
&lt;br /&gt;
* Only &#039;&#039;&#039;ONE&#039;&#039;&#039; command can be executed at a time. This is a limitation of embedded ruby, which should be run from one thread only.&lt;br /&gt;
* If command expected an answer, it would wait about 20 seconds for the ruby command to complete, and if the command haven&#039;t completed yet, it would send an empty response.&lt;br /&gt;
* Most of the data are pretty cryptic (like &#039;&#039;device_.devdata_[114]&#039;&#039;), you have to look that that number represents (device data id, command id, command parameter id, event id, event parameter id, some other id)&lt;br /&gt;
&lt;br /&gt;
== Short example ==&lt;br /&gt;
For more details about exported classes and available methods check [[GSD_Ruby_Interface]]&lt;br /&gt;
&lt;br /&gt;
Here is a short example from &#039;&#039;Panasonic IP Camera&#039;&#039;:&lt;br /&gt;
   0:require &#039;Ruby_Generic_Serial_Device&#039;&lt;br /&gt;
   1:class Command &amp;lt; Ruby_Generic_Serial_Device::RubyCommandWrapper&lt;br /&gt;
   2:end&lt;br /&gt;
   3:class Device_47 &amp;lt; Ruby_Generic_Serial_Device::RubySerialWrapper&lt;br /&gt;
   4:#### 84 ####################################################################&lt;br /&gt;
   5:def cmd_84(data, format, disable_aspect_lock, streamid, width, height)&lt;br /&gt;
   6:@returnParamArray.clear&lt;br /&gt;
   7:conn_.Reconnect()&lt;br /&gt;
   8:auth_s=device_.devdata_[114]+&amp;quot;:&amp;quot;+device_.devdata_[115]&lt;br /&gt;
   9:auth_a=Array.new;&lt;br /&gt;
  10:auth_s.each{|c| auth_a.push(c)}&lt;br /&gt;
  11:&lt;br /&gt;
  12:fix_path=device_.devdata_[2];&lt;br /&gt;
  13:fix_path=&#039;/&#039;+fix_path if(fix_path[0]!=&#039;/&#039;[0]);&lt;br /&gt;
  14:&lt;br /&gt;
  15:s = &amp;quot;GET &amp;quot;+fix_path+&amp;quot; HTTP/1.0\r\n&amp;quot;&lt;br /&gt;
  16:s+= &amp;quot;Accept: */*\r\n&amp;quot;&lt;br /&gt;
  17:s+= &amp;quot;Authorization: Basic &amp;quot;+auth_a.pack(&amp;quot;m&amp;quot;).chop+&amp;quot;\r\n&amp;quot;&lt;br /&gt;
  18:s+= &amp;quot;\r\n&amp;quot;&lt;br /&gt;
  19:&lt;br /&gt;
  20:conn_.Send(s)&lt;br /&gt;
  21:recv=&amp;quot;&amp;quot;&lt;br /&gt;
  22:while(true)&lt;br /&gt;
  23:  buff=conn_.Recv(16384, 5000)&lt;br /&gt;
  24:  if(buff.length() == 0)&lt;br /&gt;
  25:     break&lt;br /&gt;
  26:   end&lt;br /&gt;
  27:   recv = recv +  buff&lt;br /&gt;
  28:end&lt;br /&gt;
  29:if (recv=~ /^HTTP[^\r\n]+200\sOK.+?\r\n\r\n(.+)$/m)&lt;br /&gt;
  30:  data_set($1)&lt;br /&gt;
  31:  format_set(&#039;jpg&#039;)&lt;br /&gt;
  32:end&lt;br /&gt;
  33:return @returnParamArray&lt;br /&gt;
  34:end&lt;br /&gt;
 ...&lt;br /&gt;
 194:#### START SETTERS ####################################################################&lt;br /&gt;
 195:def initialize()&lt;br /&gt;
 196:super&lt;br /&gt;
 197:@returnParamArray=Array.new&lt;br /&gt;
 198:end&lt;br /&gt;
 199:def data_set(value)&lt;br /&gt;
 200:@returnParamArray[19]=value&lt;br /&gt;
 201:end&lt;br /&gt;
 202:def format_set(value)&lt;br /&gt;
 203:@returnParamArray[20]=value&lt;br /&gt;
 204:end&lt;br /&gt;
 205:####  END  SETTERS ####################################################################&lt;br /&gt;
 206:end&lt;br /&gt;
You can see how command 84 (GetVideoFrame) is implemented:&lt;br /&gt;
* it has 6 parameters &#039;&#039;cmd_84(data, format, disable_aspect_lock, streamid, width, height)&#039;&#039;, parameters &#039;&#039;data&#039;&#039; and &#039;&#039;format&#039;&#039; are also output parameters&lt;br /&gt;
* to set output parameters methods like &#039;&#039;data_set&#039;&#039; and &#039;&#039;format_set&#039;&#039; are automatically generated&lt;br /&gt;
* &#039;&#039;device_.devdata_[114]&#039;&#039;, &#039;&#039;device_.devdata_[115]&#039;&#039; are the username and password to login into camera &lt;br /&gt;
* then it creates HTTP header with basic authorization&lt;br /&gt;
* &#039;&#039;device_.devdata_[2]&#039;&#039; is the path to the snapshot (it is configurable because it can change between models)&lt;br /&gt;
* it sends the request and waits for the answer&lt;br /&gt;
* reads the answer, regexp parse it and gets JPEG content&lt;br /&gt;
* sets output parameters&lt;br /&gt;
* returns @returnParamArray (the return statement is added automatically)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Example - Adding Clipsal Interface ==&lt;br /&gt;
&lt;br /&gt;
We can control lights, curtains and climate controls using Clipsal Interface that connects through Serial Port.&lt;br /&gt;
&lt;br /&gt;
[[Here is a detailed example of how to add Clipsal Interface using Generic Serial Device.|Adding Clipsal Interface using Generic Serial Device]]&lt;/div&gt;</summary>
		<author><name>Tamjid</name></author>
	</entry>
	<entry>
		<id>http://wiki.linuxmce.org/index.php?title=DCE_Binary_Communication_Protocol&amp;diff=3964</id>
		<title>DCE Binary Communication Protocol</title>
		<link rel="alternate" type="text/html" href="http://wiki.linuxmce.org/index.php?title=DCE_Binary_Communication_Protocol&amp;diff=3964"/>
		<updated>2007-06-04T15:02:32Z</updated>

		<summary type="html">&lt;p&gt;Tamjid: /* How to create a command connection */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
A device can create a command connection and one or more event connections to the router.&lt;br /&gt;
&lt;br /&gt;
* The command connection is used as an incoming connection and device will use it to receive message from the router (commands).&lt;br /&gt;
* An event connection is used by the device as an outgoing connection to notify the router about events or the deliver commands to other devices.&lt;br /&gt;
&lt;br /&gt;
The DCERouter process is listening on 3450 port.&lt;br /&gt;
&lt;br /&gt;
== How to create an event connection ==&lt;br /&gt;
&lt;br /&gt;
Here is how the handshake is made for an event connection:&lt;br /&gt;
&lt;br /&gt;
&amp;gt;&amp;gt; Device sends: &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;EVENT &amp;lt;my_device_id&amp;gt; &#039;\n&#039;&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;&amp;lt; To router will respond with : &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;OK &amp;lt;my_device_id&amp;gt; IP=&amp;lt;device_ip_address&amp;gt; &#039;\n&#039;&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;gt;&amp;gt; To send a message, the device will send :&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;MESSAGE &amp;lt;size_of_binary_message&amp;gt; &#039;\n&#039;&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
and then&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;&amp;lt;serialized_binary_message&amp;gt;&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== How to create a command connection ==&lt;br /&gt;
&lt;br /&gt;
Here is how the handshake is made for a command connection:&lt;br /&gt;
&lt;br /&gt;
&amp;gt;&amp;gt; Device sends: &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;COMMAND &amp;lt;my_device_id&amp;gt; &#039;\n&#039;&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;&amp;lt; To router will respond with : &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;OK &amp;lt;my_device_id&amp;gt; IP=&amp;lt;device_ip_address&amp;gt; &#039;\n&#039;&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;gt;&amp;gt; The device will wait for messages from dcerouter; the router will send :&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;MESSAGE &amp;lt;size_of_binary_message&amp;gt; &#039;\n&#039;&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
and then&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;&amp;lt;serialized_binary_message&amp;gt;&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== How to serialize data == &lt;br /&gt;
&lt;br /&gt;
DCE uses SerializeClass to serialize/deserialize data.&lt;br /&gt;
&lt;br /&gt;
The sources can be found here : src/SerializeClass/Serialize.h/cpp.&lt;br /&gt;
&lt;br /&gt;
The deserialize the data, the deserializing module must know the way the data was serialized like this:&lt;br /&gt;
&lt;br /&gt;
- 4 bytes, unsigned long&lt;br /&gt;
&lt;br /&gt;
- 1 byte, unsigned char&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Primitives:&lt;br /&gt;
&lt;br /&gt;
- 8 bytes, unsigned int64&lt;br /&gt;
&lt;br /&gt;
- 8 bytes, int64&lt;br /&gt;
&lt;br /&gt;
- 4 bytes, unsigned long&lt;br /&gt;
&lt;br /&gt;
- 4 bytes, unsigned short&lt;br /&gt;
&lt;br /&gt;
- 1 byte, unsigned char&lt;br /&gt;
&lt;br /&gt;
- 1 byte, char&lt;br /&gt;
&lt;br /&gt;
- 1 byte, long&lt;br /&gt;
&lt;br /&gt;
- 4 bytes, float&lt;br /&gt;
&lt;br /&gt;
- 8 bytes, double&lt;br /&gt;
&lt;br /&gt;
- 2 bytes, short&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Complex types:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1. string&lt;br /&gt;
&lt;br /&gt;
- STR_LENGTH bytes, the array with chars&lt;br /&gt;
&lt;br /&gt;
- 1 byte, &#039;/0&#039; (value 0x00)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. block of data&lt;br /&gt;
&lt;br /&gt;
- BLOCK_LENGTH bytes, the array with bytes&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. vector of strings&lt;br /&gt;
&lt;br /&gt;
- VECT_LENGTH bytes, the number of strings from vector&lt;br /&gt;
&lt;br /&gt;
- string 0&lt;br /&gt;
&lt;br /&gt;
- string 1&lt;br /&gt;
&lt;br /&gt;
...&lt;br /&gt;
&lt;br /&gt;
- string VECT_LENGTH - 1&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Other complex types serialized (see SerializeClass.cpp for details) :&lt;br /&gt;
&lt;br /&gt;
- map&amp;lt;int,string&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- map&amp;lt;u_int64_t,string&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- map&amp;lt;int,int&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- map&amp;lt;string,string&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- vector&amp;lt;int&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- vector&amp;lt; pair&amp;lt;int,int&amp;gt; &amp;gt;&lt;br /&gt;
&lt;br /&gt;
- map&amp;lt;string, pair&amp;lt;int,int&amp;gt; &amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
SerializeClass also allowed you to serialize/deserialize custom objects. Examples:&lt;br /&gt;
&lt;br /&gt;
- PlutoColor&lt;br /&gt;
&lt;br /&gt;
- PlutoPoint&lt;br /&gt;
&lt;br /&gt;
- PlutoSize&lt;br /&gt;
&lt;br /&gt;
- PlutoRectangle&lt;br /&gt;
&lt;br /&gt;
- PlutoDataBlock&lt;br /&gt;
&lt;br /&gt;
== How to serialize a message ==&lt;br /&gt;
&lt;br /&gt;
The class used by DCE is Message class from src/DCE/Message.h/cpp unit.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This is how the raw data looks like into a binary message:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
- long, value must be 1234 (magic number)&lt;br /&gt;
&lt;br /&gt;
- long, &amp;lt;device_from_id&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- long, &amp;lt;device_to_id&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- long, &amp;lt;device_group_to_id&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- long, &amp;lt;message_id&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- long, &amp;lt;message_priority&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- long, &amp;lt;message_type&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- long, &amp;lt;device_category_to&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- long, &amp;lt;device_template_to&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- unsigned char, &amp;lt;include_children&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- long, &amp;lt;message_broadcast_level&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- long, &amp;lt;message_retry&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- unsigned char, &amp;lt;relative_to_sender&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- long, &amp;lt;expected_response&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- string, &amp;lt;device_list_to&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- unsigned long, &amp;lt;number_of_string_parameters&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* foreach &amp;lt;string_parameter&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*  - long, &amp;lt;string_parameter_id&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*  - string, &amp;lt;string_parameter_value&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* end_foreach&lt;br /&gt;
&lt;br /&gt;
- unsigned long, &amp;lt;number_of_data_parameters&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* foreach &amp;lt;data_parameter&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*  - long, &amp;lt;data_parameter_id&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*  - unsigned long, &amp;lt;data_parameter_length&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*  - array of bytes, &amp;lt;data_parameter_value&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* end_foreach&lt;br /&gt;
&lt;br /&gt;
- unsigned long, &amp;lt;number_of_extra_messages&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* foreach &amp;lt;extra_message&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*  - unsigned long, &amp;lt;serialized_extra_message_length&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*  - array of bytes, &amp;lt;serialized_extra_message_value&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* end_foreach&lt;br /&gt;
&lt;br /&gt;
- unsigned long, must be 6789&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Enums:&lt;br /&gt;
&lt;br /&gt;
- enum eBroadcastLevel { BL_None=0, BL_DirectSiblings=1, BL_SameComputer=2, BL_SameRoom=3, BL_SameHouse=4, BL_AllHouses=5 };&lt;br /&gt;
&lt;br /&gt;
- enum eRetry { MR_None=0, MR_Retry=1, MR_Persist=2 };&lt;br /&gt;
&lt;br /&gt;
- enum eExpectedResponse { ER_None=0, ER_ReplyMessage, ER_ReplyString, ER_DeliveryConfirmation };&lt;br /&gt;
&lt;br /&gt;
- message types:     enum { MESSAGETYPE_COMMAND=1, MESSAGETYPE_EVENT=2, MESSAGETYPE_DATAPARM_CHANGE=3, MESSAGETYPE_REPLY=4, &lt;br /&gt;
		MESSAGETYPE_DATAPARM_REQUEST=5, MESSAGETYPE_LOG=6, MESSAGETYPE_SYSCOMMAND=7, &lt;br /&gt;
		MESSAGETYPE_REGISTER_INTERCEPTOR=8, MESSAGETYPE_MESSAGE_INTERCEPTED=9, MESSAGETYPE_EXEC_COMMAND_GROUP=10,&lt;br /&gt;
		MESSAGETYPE_START_PING=11, MESSAGETYPE_STOP_PING=12, MESSAGETYPE_PURGE_INTERCEPTORS=13,&lt;br /&gt;
		MESSAGETYPE_PENDING_TASKS=14 };&lt;br /&gt;
&lt;br /&gt;
- message priority :     enum { PRIORITY_LOW=0, PRIORITY_NORMAL=1, PRIORITY_HIGH=2, PRIORITY_URGENT=3 };&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Here is the pseudocode to send the &amp;quot;on&amp;quot; command to a light switch.&lt;br /&gt;
&lt;br /&gt;
We&#039;ll assume that the your device has #id 250 and the light switch has device #id 100&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
 &lt;br /&gt;
MyDevice.Connect(router_ip, 3450 /*port*/)&lt;br /&gt;
&lt;br /&gt;
MyDevice.SendData(&amp;quot;EVENT 250\n&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
MyDevice.ReceiveData()  //until you&#039;ll get a &#039;\n&#039; ; you should receive: &amp;quot;OK 250 IP=&amp;lt;device_ip_address&amp;gt; &#039;\n&#039;;&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
//next: creating a message&lt;br /&gt;
&lt;br /&gt;
//let&#039;s say MyData is an array of bytes&lt;br /&gt;
&lt;br /&gt;
SerializeLong(MyData, 1234) //magic number&lt;br /&gt;
&lt;br /&gt;
SerializeLong(MyData, 250) //my id&lt;br /&gt;
&lt;br /&gt;
SerializeLong(MyData, 100) //the light switch&lt;br /&gt;
&lt;br /&gt;
SerializeLong(MyData, 0) //not used now&lt;br /&gt;
&lt;br /&gt;
SerializeLong(MyData, 192) //message id of command &#039;on&#039;&lt;br /&gt;
&lt;br /&gt;
SerializeLong(MyData, 1) //normal priority&lt;br /&gt;
&lt;br /&gt;
SerializeLong(MyData, 1) //message type : command&lt;br /&gt;
&lt;br /&gt;
SerializeLong(MyData, 0) //not used now&lt;br /&gt;
&lt;br /&gt;
SerializeLong(MyData, 0) //not used now&lt;br /&gt;
&lt;br /&gt;
SerializeUnsignedChar(MyData, 0) //not including children&lt;br /&gt;
&lt;br /&gt;
SerializeLong(MyData, 0) //broadcast level : none&lt;br /&gt;
&lt;br /&gt;
SerializeLong(MyData, 0) //don&#039;t retry&lt;br /&gt;
&lt;br /&gt;
SerializeUnsignedChar(MyData, 0) //relative to sender false&lt;br /&gt;
&lt;br /&gt;
SerializeLong(MyData, 3) //delivery confirmation&lt;br /&gt;
&lt;br /&gt;
SerializeString(MyData, &amp;quot;&amp;quot;) //device list to empty&lt;br /&gt;
&lt;br /&gt;
SerializeUnsignedLong(MyData, 2) //2 parameters&lt;br /&gt;
&lt;br /&gt;
SerializeLong(MyData, 98) //parameter type #98&lt;br /&gt;
&lt;br /&gt;
SerializeString(MyData, &amp;quot;&amp;quot;) //empty value&lt;br /&gt;
&lt;br /&gt;
SerializeLong(MyData, 97) //parameter type #97&lt;br /&gt;
&lt;br /&gt;
SerializeString(MyData, &amp;quot;&amp;quot;) //empty value&lt;br /&gt;
&lt;br /&gt;
SerializeUnsignedLong(MyData, 0) //no binary parameters&lt;br /&gt;
&lt;br /&gt;
SerializeUnsignedLong(MyData, 0) //no extra messages&lt;br /&gt;
&lt;br /&gt;
SerializeUnsignedLong(6789) //magic number&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
MyDevice.SendData(&amp;quot;MESSAGE &amp;quot; + MyData.length() + &#039;\n&#039;)&lt;br /&gt;
&lt;br /&gt;
MyDevice.SendData(MyData)&lt;br /&gt;
&lt;br /&gt;
MyDevice.ReceiveData()  //until you&#039;ll get a &#039;\n&#039; ; you should receive: &amp;quot;OK&amp;quot; an error message&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
MyDevice.CloseConnection();&lt;br /&gt;
 &lt;br /&gt;
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////&lt;br /&gt;
&lt;br /&gt;
== How to serialize data-grids ==&lt;br /&gt;
&lt;br /&gt;
(in work)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Complex objects:&lt;br /&gt;
&lt;br /&gt;
1) DataGridCellSerializableData &lt;br /&gt;
&lt;br /&gt;
- unsigned long, &amp;lt;sizeof(DataGridCellSerializableData)&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- unsigned long, &amp;lt;graphic_length&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- unsigned long, &amp;lt;message_length&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- unsigned long, &amp;lt;text_length&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- unsigned long, &amp;lt;value_length&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- unsigned long, &amp;lt;image_path_length&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- unsigned long, &amp;lt;number_of_attributes_length&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- unsigned long, &amp;lt;attributes_length&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- int, &amp;lt;alternate_color&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- unsigned long, &amp;lt;graphic_format&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- unsigned char, &amp;lt;selectable&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- int, &amp;lt;style_detail&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- int, &amp;lt;col_span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- int, &amp;lt;row_span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- unsigned char, &amp;lt;dont_fire_grid_event&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Enums:&lt;br /&gt;
&lt;br /&gt;
- enum eGraphicFormat { GR_UNKNOWN=0, GR_JPG=1, GR_GIF=2, GR_TIF=3, GR_PNG=4, GR_MNG=5, GR_BMP=6, GR_OCG=7, GR_PFG=8 };&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2) DataGridCell &lt;br /&gt;
&lt;br /&gt;
- DataGridCellSerializableData, &amp;lt;datagrid_cell_serializable_data&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- array of chars, &amp;lt;text&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
- array of chars, &amp;lt;value&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- array of bytes, &amp;lt;graphic_data&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- array of bytes, &amp;lt;message_data&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- array of chars, &amp;lt;image_path&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* foreach &amp;lt;cell_attribute&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*  - array of chars ended with &#039;\0&#039; , &amp;lt;cell_attribute_name&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*  - array of chars ended with &#039;\0&#039;, &amp;lt;cell_attribute_value&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* end_foreach&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3) DataGridTableSerializableData&lt;br /&gt;
&lt;br /&gt;
- int, &amp;lt;total_number_of_columns&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- int, &amp;lt;total_number_of_rows&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- unsigned char, &amp;lt;keep_row_header&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- unsigned char, &amp;lt;keep_column_header&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- int, &amp;lt;column_count&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- int, &amp;lt;row_count&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- int, &amp;lt;starting_column&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- int, &amp;lt;starting_row&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- int, &amp;lt;cell_count&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
4) DataGridTableCellIndex&lt;br /&gt;
&lt;br /&gt;
- unsigned int, &amp;lt;column_row_type&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- unsigned int, &amp;lt;size&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
5) DataGridTable&lt;br /&gt;
&lt;br /&gt;
- unsigned long, &amp;lt;sizeof(DataGridTableSerializableData)&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- array of DataGridTableCellIndex, &amp;lt;col * row * sizeof(DataGridTableCellIndex)&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- array of DataGridCell, &amp;lt;col * row * serialized DataGridCell&amp;gt;&lt;br /&gt;
&lt;br /&gt;
/*********************************************************************************/&lt;br /&gt;
&lt;br /&gt;
Additional step: lzo compression/decompression&lt;br /&gt;
&lt;br /&gt;
Note: can be disabled if compiled with DISABLE_LZO_DATAGRID &lt;br /&gt;
&lt;br /&gt;
/*********************************************************************************/&lt;/div&gt;</summary>
		<author><name>Tamjid</name></author>
	</entry>
	<entry>
		<id>http://wiki.linuxmce.org/index.php?title=Control_LinuxMCE_using_an_Infrared_remote&amp;diff=3962</id>
		<title>Control LinuxMCE using an Infrared remote</title>
		<link rel="alternate" type="text/html" href="http://wiki.linuxmce.org/index.php?title=Control_LinuxMCE_using_an_Infrared_remote&amp;diff=3962"/>
		<updated>2007-05-30T12:31:17Z</updated>

		<summary type="html">&lt;p&gt;Tamjid: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;p&amp;gt;&amp;lt;h1&amp;gt;How to set it up&amp;lt;/h1&amp;gt;&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;In LinuxMCE Admin choose Wizard, Devices, Media Directors.  Choose the type of Infrared Receiver you have from the pull-down.  The list of choices are LIRC drivers, so you can also refer to http://lirc.org/ for details.  Most use the &amp;quot;default&amp;quot; driver.  Then add all the &amp;quot;Infrared remote controls you will use&amp;quot;.  You can have as many as you want and they will all work.  LinuxMCE Admin will then add 1 Infrared Receiver device, and 1 device for each remote control you added.  After adding any new devices chose Wizard, Restart and click Quick Reload Router so LinuxMCE starts using that device.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;&amp;lt;h1&amp;gt;How to use it&amp;lt;/h1&amp;gt;&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;When the media director starts you will see a graphical user interface with a menu of buttons.  This is the &amp;quot;Orbiter&amp;quot;.  It&#039;s the same user interface as on the web-pads and PDA&#039;s.  The Orbiter that the media director displays on your TV we call the On-screen Orbiter, to distinguish from the other roving Orbiters like the PDA&#039;s and mobile phones.  What the buttons on the infrared remote control do depends largely on what you see on the On-Screen Orbiter.  LinuxMCE is intelligent enough to know that sometimes you push buttons to control the media director&#039;s Orbiter, and sometimes you push buttons to control whatever media device you&#039;re using.  LinuxMCE will handle all the translation for you.  In other words you can use one universal remote control to LinuxMCE and other A/V Equipment.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;Here&#039;s an example.  Let&#039;s say you have a media director, which is also controlling your satellite TV box as well as a regular DVD player.  The media director is controlling both of them via Infrared.  You have a universal remote control which you added to LinuxMCE as described above.  The On-screen Orbiter is visible on the TV.  As you hit the up/down/left/right/enter buttons on the remote you will see that you can select the menu options on the Orbiter.  You select the button to watch &amp;quot;Satellite TV&amp;quot;, and the TV appears.  Now when you hit up/down/left/right/enter LinuxMCE knows you obviously want to control the satellite tv box.  So, when you press those buttons LinuxMCE translates the infrared codes into ones that your satellite tv box understands, and you will see the same arrows on the same remote control are now controlling the satellite TV.  You hit &#039;Power Off&#039;, and the satellite box shuts off, and the Orbiter&#039;s menu is again visible.  Now the arrows are again controlling the Orbiter.  You choose the button to watch a DVD in your DVD Player.  Now the same arrows are controlling the DVD player.  And when you hit &#039;pause&#039; the DVD player will pause, even though you&#039;re holding the LinuxMCE remote--not the DVD remote.  LinuxMCE is translating everything for you so you don&#039;t have to juggle remote controls.  Again you hit &#039;power&#039; and the DVD turns off.  Hit &#039;power&#039; again and the orbiter shuts the TV off.  Hit &#039;power&#039; a third time and the media director itself turns off.  This is even better than a universal remote control since you don&#039;t need to tell it what device you want to control--LinuxMCE figures it out on its own.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;Although you can use all sorts of remote controls, and all have different buttons, they will all control LinuxMCE in a consistent manner.  The media-specific buttons, like rewind/fastforward, play/pause, etc., will always control whatever media device you are currently listening to no matter what screen is visible on the on-screen Orbiter.  Navigation buttons, like up/down/left/right/enter and the 10-key number pad, will control the currently active media device if the On-screen Orbiter is showing the remote control for that device.  Otherwise it controls the On-screen Orbiter.  When the main menu is visible on the Orbiter you can select scenarios with the up/down/left/right/enter buttons, or the 10-key pad.  To use the 10-key pad, hit the type of scenario you want: the categories are always numbered as follows: 1=Lighting, 2=Media, 3=Climate, 4=Telecom, 5=Security, 6=Misc  Then when the list of those scenarios appears, hit the scenario you want, such as 2 for the 2nd scenario.  Thus 22 on the remote will start TV (2=Media, TV is always the 2nd option).&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;You can use different remote controls that have completely different layouts, but they will still control LinuxMCE in a consistent manner.  For example you can use a Bang &amp;amp; Olufsen remote which only has a single set of up/down/left/right buttons, and LinuxMCE knows that when there is a menu on screen those buttons should move the highlighter around on the screen, and when there is not a menu on screen, those buttons are used for rewind fast-forward and skip up/down.  The logic is all handled automatically so for the user it is a very intuitive experience, allowing all sorts of different devices to be controlled with all sorts of different remote controls without having to do any setup.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Programmer&#039;s Guide ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;Be sure to read the How To Use It section above first.&lt;br /&gt;
&lt;br /&gt;
As you can see, LinuxMCE provides a highly intelligent interpretation of infrared remote buttons, that automatically change their function based on what the user is doing, what type of remote control layout exists, and where the infrared codes are going.  If you have ever worked with infrared remote controls, such as LIRC, you know that there is no standard, and all the remote controls have different buttons with different names.  Therefore we had to create a database structure that allows for interpreting the different button names into commands which can change depending upon the context and the layout of the remote.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;The DCE Devices (i.e. the LinuxMCE binary that is run to handle i/r reception) are all of the category Peripherals, Infrared Receivers.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In LinuxMCE Admin choose Advanced &amp;gt; Device Templates, and you can see the categories and devices in them.  There is a separate folder for the LIRC drivers.  In addition to a device for the i/r receiver, there is also a device for the i/r remote.  The remote controls are of the type Peripherals &amp;gt; Remote Controls.  Since the definition of the infrared codes for a remote control is stored within the remote control device, and that definition varies depending upon the type of receiver, you will see there is a separate subcategory for each type of receiver.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For example there is a folder &amp;quot;LIRC Remote Controls&amp;quot; that has all of the remote controls and definition files for the LIRC project.  We also created our own DCE devices for other infrared receivers, such as IRTrans and Tira.  Although these are supported within the lirc project, we found that we had better control and greater accuracy when we used the native SDKs for these receivers.  So, for example, if you have an IRTrans receiver, and an XPMC remote, you have two possibilities.  First you could add the LIRC receiver device, and the XPMC remote device that is within the LIRC remote category.  In this case the remote control will be using an LIRC config file.  Secondly you could add LinuxMCE&#039;s native IRTrans receiver device, and then pick the XMPC remote device that is within the IRTrans remotes category, which stores the button codes in a different format, that is in IRTrans&#039; native format.  When you are adding your infrared receiver and remote control using the LinuxMCE Admin Wizard/Devices/Media Directors page, the wizard automatically ensures that when you add a remote control it is the correct category.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;For each remote control there is a device data &amp;quot;#59 Configuration&amp;quot; which has the remote controls configuration file, which defined all the infrared codes at each button will send and gives each code, or button, a name.  So the XPMC remote within the LIRC category has a device data #59 that is the LIRC config file.  The XPMC remote within the IRTrans category has a device data #59 that is the  same buttons/codes, but in IRTrans format.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;When the framework starts an IR receiver device, iIn general this device will first scan for all sister devices within the category remote control, and write out a configuration file.  So, for example, when LIRC_DCE runs it finds all LIRC remote controls on that machine, grabs the device data &amp;quot;#59 Configuration&amp;quot; for every one of them and writes that out to a lirc.conf file, and then starts LIRC.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;All the logic is in a base class called IRReceiverBase.  All of LinuxMCE&#039;s infrared receiver devices use this same base class.  So the actual code that is specific to each type of receiver is very small, usually around 20 lines.  It only needs to write out the configuration file at start up, and then call the member function ReceivedCode within IRReceiverBase when a button is pushed.  This function takes the name of the button as a parameter, and converts this into a message.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;Since all of the receivers use a common base class to handle the logic, that also means that all of the translation between buttons and actions is also in a shared database.  It does not matter whether you are using LIRC or some other infrared receiver, the translation is the same.  There is no unified standard for what the buttons are called.  The button &amp;quot;SkipFwd&amp;quot; may be called &amp;quot;Fwd&amp;quot;, &amp;quot;Skip+&amp;quot;, &amp;quot;Jump-&amp;gt;&amp;quot;, etc.  The table RemoteMapping in the main mysql database, pluto_main, has a field Mapping which lists all the button aliases, followed by the command to be executed when any of those buttons is pushed.  For example: chup;skipfwd;ChanUp;SkipNext;|0 -106 1 65 5 +1&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;Whenever any infrared receiver reports any of those button presses, the message &amp;quot;0 -106 1 65 5 +1&amp;quot; gets fired.  The format of the message is the same as if you typed it with the MessageSend utility: ie from device, to device message type, message id, followed by parameters.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;So if the user presses a button called ChanUp, a message will be sent to device -106 (media plugin) of type 1 (command) id 65 (Jump Position In Playlist) with parameter 5 (Value To Assign) set to &amp;quot;+1&amp;quot;.  This table is shared amongst all LinuxMCE users, and is updated every time your system upgrades versions.  If you make your own manual changes to this table then the next time your core upgrades it will not upgrade the rows in that table that you modified, because SQL CVS does not, by default, overwrite your local changes with global ones.  Therefore, if you have a new remote control with some new buttons that we have not yet mapped, it is recommended that you e-mail us or post us a message in the forum, with the button name and the message and then we can add it to our master database and then your system can remain in sync with other users enhancements.  If you want to do some mapping that is just for you, you can change the table and know your changes will not be overwritten.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;You&#039;ll note that the RemoteMapping table has 2 optional fields: ScreenType and RemoteLayout.  When the IRReceiverBase base class is deciding what message to send in response to button press, it first looks for a more specific entry where the screen type matches the type of screen currently visible on the orbiter, and the remote layout matches the layout.  The on-screen orbiters regularly send messages to the infrared receiver telling them what type of screen is currently visible, using the following codes: M=Main Menu, m=other menu, R=LinuxMCE Remote, r=Non-LinuxMCE remote, F=File Listing.  This allows for buttons to behave differently depending upon what type of screen is visible.  For example when the main menu is visible, the arrows on a remote control should send a message to the on-screen orbiter to move the highlight pointer around on the screen.  However when the user is controlling an external piece of AV equipment, like a DVD player, the arrows should pass through to the DVD player so the user can control its own on-screen menu.  Also the type of functionality can vary depending upon the layout of the remote.  For example, Bang &amp;amp; Olufsen remotes are quite simple, there is only a single up/down/left/right buttons which are used both to navigate on-screen menus as well as to handle rewind fast-forward and skip.  Other remotes have dedicated arrows and media navigation buttons.  So one remote layout can be created for Bang &amp;amp; Olufsen-style remote, where the arrows control the menu when there is a menu on screen, and adjust the media when there is not.  The remote layout is a device data &amp;quot;#110 Remote Layout&amp;quot; stored with the remote control&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;When IRReceiverBase looks for a mapping it first looks for records that match the current screen type and remote layout, and then revert to standard records (ie ScreenType and RemoteLayout are null) only if there are no matching results.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;See also [[Add support for new remote controls]]&amp;lt;/p&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tamjid</name></author>
	</entry>
</feed>