Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 7e5d6f76ee
Fetching contributors…

Cannot retrieve contributors at this time

322 lines (197 sloc) 14.5 kb
<!DOCTYPE html>
<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
<title>Class: KNX_Transceiver</title>
<link type="text/css" media="screen" href="./rdoc.css" rel="stylesheet">
<script type="text/javascript">
var rdoc_rel_prefix = "./";
</script>
<script type="text/javascript" charset="utf-8" src="./js/jquery.js"></script>
<script type="text/javascript" charset="utf-8" src="./js/navigation.js"></script>
<script type="text/javascript" charset="utf-8" src="./js/search_index.js"></script>
<script type="text/javascript" charset="utf-8" src="./js/search.js"></script>
<script type="text/javascript" charset="utf-8" src="./js/searcher.js"></script>
<script type="text/javascript" charset="utf-8" src="./js/darkfish.js"></script>
<body id="top" class="class">
<nav id="metadata">
<nav id="home-section" class="section">
<h3 class="section-header">
<a href="./index.html">Home</a>
<a href="./table_of_contents.html#classes">Classes</a>
<a href="./table_of_contents.html#methods">Methods</a>
</h3>
</nav>
<nav id="search-section" class="section project-section" class="initially-hidden">
<form action="#" method="get" accept-charset="utf-8">
<h3 class="section-header">
<input type="text" name="search" placeholder="Search" id="search-field"
title="Type to search, Up and Down to navigate, Enter to load">
</h3>
</form>
<ul id="search-results" class="initially-hidden"></ul>
</nav>
<div id="file-metadata">
<nav id="file-list-section" class="section">
<h3 class="section-header">Defined In</h3>
<ul>
<li>knx/knx_transceiver.rb
</ul>
</nav>
</div>
<div id="class-metadata">
<nav id="parent-class-section" class="section">
<h3 class="section-header">Parent</h3>
<p class="link"><a href="Transceiver.html">Transceiver</a>
</nav>
<!-- Method Quickref -->
<nav id="method-list-section" class="section">
<h3 class="section-header">Methods</h3>
<ul class="link-list">
<li><a href="#method-c-new">::new</a>
<li><a href="#method-i-run">#run</a>
<li><a href="#method-i-send_apdu_raw">#send_apdu_raw</a>
</ul>
</nav>
</div>
<div id="project-metadata">
<nav id="classindex-section" class="section project-section">
<h3 class="section-header">Class and Module Index</h3>
<ul class="link-list">
<li><a href="./Ansible.html">Ansible</a>
<li><a href="./Ansible/ZWave_Transceiver.html">Ansible::ZWave_Transceiver</a>
<li><a href="./OpenZWave.html">OpenZWave</a>
<li><a href="./OpenZWave/ValueID.html">OpenZWave::ValueID</a>
<li><a href="./AnsibleValue.html">AnsibleValue</a>
<li><a href="./KNX_L_DATA_Frame.html">KNX_L_DATA_Frame</a>
<li><a href="./KNX_TP_ControlField.html">KNX_TP_ControlField</a>
<li><a href="./KNX_Transceiver.html">KNX_Transceiver</a>
<li><a href="./OZW_EventID_id.html">OZW_EventID_id</a>
<li><a href="./OZW_EventID_id1.html">OZW_EventID_id1</a>
<li><a href="./Object.html">Object</a>
<li><a href="./OrbiterProxy.html">OrbiterProxy</a>
<li><a href="./Test.html">Test</a>
<li><a href="./Transceiver.html">Transceiver</a>
</ul>
</nav>
</div>
</nav>
<div id="documentation">
<h1 class="class">class KNX_Transceiver</h1>
<div id="description" class="description">
</div><!-- description -->
<section id="5Buntitled-5D" class="documentation-section">
<!-- Attributes -->
<section id="attribute-method-details" class="method-section section">
<h3 class="section-header">Attributes</h3>
<div id="attribute-i-stomp" class="method-detail">
<div class="method-heading attribute-method-heading">
<span class="method-name">stomp</span><span
class="attribute-access-type">[R]</span>
</div>
<div class="method-description">
</div>
</div>
</section><!-- attribute-method-details -->
<!-- Methods -->
<section id="public-class-5Buntitled-5D-method-details" class="method-section section">
<h3 class="section-header">Public Class Methods</h3>
<div id="method-c-new" class="method-detail ">
<div class="method-heading">
<span class="method-name">new</span><span
class="method-args">(connURL)</span>
<span class="method-click-advice">click to toggle source</span>
</div>
<div class="method-description">
<div class="method-source-code" id="new-source">
<pre><span class="ruby-comment"># File knx/knx_transceiver.rb, line 28</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">connURL</span>)
<span class="ruby-identifier">puts</span>(<span class="ruby-node">&quot;KNX: init connection to #{connURL}&quot;</span>)
<span class="ruby-ivar">@monitor_conn</span> = <span class="ruby-constant">EIBConnection</span>.<span class="ruby-identifier">new</span>()
<span class="ruby-ivar">@monitor_conn</span>.<span class="ruby-constant">EIBSocketURL</span>(<span class="ruby-identifier">connURL</span>)
<span class="ruby-ivar">@send_conn</span> = <span class="ruby-constant">EIBConnection</span>.<span class="ruby-identifier">new</span>()
<span class="ruby-ivar">@send_conn</span>.<span class="ruby-constant">EIBSocketURL</span>(<span class="ruby-identifier">connURL</span>)
<span class="ruby-ivar">@knxbuf</span> = <span class="ruby-constant">EIBBuffer</span>.<span class="ruby-identifier">new</span>()
<span class="ruby-keyword">super</span>(<span class="ruby-identifier">connURL</span>)
<span class="ruby-keyword">end</span></pre>
</div><!-- new-source -->
</div>
</div><!-- new-method -->
</section><!-- public-class-method-details -->
<section id="public-instance-5Buntitled-5D-method-details" class="method-section section">
<h3 class="section-header">Public Instance Methods</h3>
<div id="method-i-run" class="method-detail ">
<div class="method-heading">
<span class="method-name">run</span><span
class="method-args">()</span>
<span class="method-click-advice">click to toggle source</span>
</div>
<div class="method-description">
<div class="method-source-code" id="run-source">
<pre><span class="ruby-comment"># File knx/knx_transceiver.rb, line 38</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">run</span>()
<span class="ruby-identifier">puts</span>(<span class="ruby-string">&quot;KNX Transceiver thread is running!&quot;</span>)
<span class="ruby-keyword">begin</span>
<span class="ruby-comment">#### part 1: connect to STOMP broker</span>
<span class="ruby-ivar">@stomp</span> = <span class="ruby-constant">OnStomp</span>.<span class="ruby-identifier">connect</span> <span class="ruby-string">&quot;stomp://localhost&quot;</span>
<span class="ruby-comment">#### part 2: subscribe to command channel, listen for messages and pass them to KNX</span>
<span class="ruby-ivar">@stomp</span>.<span class="ruby-identifier">subscribe</span> <span class="ruby-constant">KNX_COMMAND_TOPIC</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">msg</span><span class="ruby-operator">|</span>
<span class="ruby-identifier">dest</span> = <span class="ruby-identifier">msg</span>.<span class="ruby-identifier">headers</span>[<span class="ruby-string">'dest_addr'</span>].<span class="ruby-identifier">to_i</span>
<span class="ruby-comment">#TODO: check address limits</span>
<span class="ruby-identifier">apdu</span> = <span class="ruby-constant">Marshal</span>.<span class="ruby-identifier">load</span>(<span class="ruby-constant">CGI</span>.<span class="ruby-identifier">unescape</span>(<span class="ruby-identifier">msg</span>.<span class="ruby-identifier">body</span>))
<span class="ruby-identifier">send_apdu_raw</span>(<span class="ruby-identifier">dest</span>, <span class="ruby-identifier">apdu</span>)
<span class="ruby-keyword">end</span>
<span class="ruby-comment">##### part 3: monitor KNX bus, post all activity to /knx/monitor</span>
<span class="ruby-identifier">vbm</span> = <span class="ruby-ivar">@monitor_conn</span>.<span class="ruby-constant">EIBOpenVBusmonitor</span>()
<span class="ruby-identifier">loop</span> <span class="ruby-keyword">do</span>
<span class="ruby-identifier">len</span> = <span class="ruby-ivar">@monitor_conn</span>.<span class="ruby-constant">EIBGetBusmonitorPacket</span>(<span class="ruby-ivar">@knxbuf</span>)
<span class="ruby-ivar">@monitor_conn</span>.<span class="ruby-constant">EIBGetGroup_Src</span>(<span class="ruby-ivar">@buf</span>, <span class="ruby-identifier">src</span>, <span class="ruby-identifier">dest</span>)
<span class="ruby-identifier">frame</span> = <span class="ruby-constant">KNX_L_DATA_Frame</span>.<span class="ruby-identifier">new</span>(<span class="ruby-ivar">@knxbuf</span>.<span class="ruby-identifier">buffer</span>.<span class="ruby-identifier">pack</span>(<span class="ruby-string">'c*'</span>))
<span class="ruby-identifier">headers</span> = {}
<span class="ruby-identifier">frame</span>.<span class="ruby-identifier">fields</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">fld</span><span class="ruby-operator">|</span>
<span class="ruby-identifier">headers</span>[<span class="ruby-identifier">fld</span>.<span class="ruby-identifier">name</span>] = <span class="ruby-constant">CGI</span>.<span class="ruby-identifier">escape</span>(<span class="ruby-identifier">fld</span>.<span class="ruby-identifier">inspect_in_object</span>(<span class="ruby-identifier">frame</span>, <span class="ruby-value">:default</span>))
}
<span class="ruby-identifier">message</span> = <span class="ruby-node">&quot;KNX transceiver: #{APCICODES[headers.apci]} packet from #{addr2str(frame.src_addr)} to #{addr2str(frame.dst_addr, frame.daf)}, priority:#{PRIOCLASSES[headers.prio]}&quot;</span>)
<span class="ruby-ivar">@stomp</span>.<span class="ruby-identifier">send</span>(<span class="ruby-constant">KNX_MONITOR_TOPIC</span>, <span class="ruby-identifier">message</span>, <span class="ruby-identifier">headers</span>)
<span class="ruby-keyword">end</span>
<span class="ruby-keyword">rescue</span> <span class="ruby-constant">NormalExit</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
<span class="ruby-identifier">puts</span>(<span class="ruby-string">&quot;KNX transceiver terminating gracefully...&quot;</span>)
<span class="ruby-keyword">rescue</span> <span class="ruby-constant">Exception</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
<span class="ruby-identifier">puts</span>(<span class="ruby-node">&quot;Exception in KNX server thread: #{e}&quot;</span>)
<span class="ruby-identifier">puts</span>(<span class="ruby-string">&quot;backtrace:\n &quot;</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">backtrace</span>.<span class="ruby-identifier">join</span>(<span class="ruby-string">&quot;\n &quot;</span>))
<span class="ruby-keyword">ensure</span>
<span class="ruby-ivar">@conn</span>.<span class="ruby-constant">EIBClose</span>()
<span class="ruby-ivar">@stomp</span>.<span class="ruby-identifier">disconnect</span>
<span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
</div><!-- run-source -->
</div>
</div><!-- run-method -->
<div id="method-i-send_apdu_raw" class="method-detail ">
<div class="method-heading">
<span class="method-name">send_apdu_raw</span><span
class="method-args">(dest, apdu)</span>
<span class="method-click-advice">click to toggle source</span>
</div>
<div class="method-description">
<div class="method-source-code" id="send_apdu_raw-source">
<pre><span class="ruby-comment"># File knx/knx_transceiver.rb, line 74</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">send_apdu_raw</span>(<span class="ruby-identifier">dest</span>, <span class="ruby-identifier">apdu</span>)
<span class="ruby-identifier">puts</span>(<span class="ruby-node">&quot;KNX transceiver: sending to group address #{dest}, #{apdu.inspect}&quot;</span>)
<span class="ruby-keyword">if</span> (<span class="ruby-ivar">@send_conn</span>.<span class="ruby-constant">EIBOpenT_Group</span>(<span class="ruby-identifier">dest</span>, <span class="ruby-value">1</span>) <span class="ruby-operator">==</span> <span class="ruby-value">-1</span>) <span class="ruby-keyword">then</span>
<span class="ruby-identifier">raise</span>(<span class="ruby-string">&quot;KNX client: error setting socket mode&quot;</span>)
<span class="ruby-keyword">end</span>
<span class="ruby-ivar">@send_conn</span>.<span class="ruby-constant">EIBSendAPDU</span>(<span class="ruby-identifier">apdu</span>)
<span class="ruby-ivar">@send_conn</span>.<span class="ruby-constant">EIBReset</span>()
<span class="ruby-keyword">end</span></pre>
</div><!-- send_apdu_raw-source -->
</div>
</div><!-- send_apdu_raw-method -->
</section><!-- public-instance-method-details -->
</section><!-- 5Buntitled-5D -->
</div><!-- documentation -->
<footer id="validator-badges">
<p><a href="http://validator.w3.org/check/referer">[Validate]</a>
<p>Generated by <a href="https://github.com/rdoc/rdoc">RDoc</a> 3.11.
<p>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish Rdoc Generator</a> 3.
</footer>
Jump to Line
Something went wrong with that request. Please try again.