libx52/group__x52dcomm.html

184 lines
8.7 KiB
HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.17"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>libx52: Daemon communication</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 56px;">
<td id="projectalign" style="padding-left: 0.5em;">
<div id="projectname">libx52
&#160;<span id="projectnumber">0.2.3</span>
</div>
<div id="projectbrief">Saitek X52/X52Pro drivers for Linux/Unix</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.17 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
initMenu('',true,false,'search.php','Search');
$(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
</div><!-- top -->
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0"
name="MSearchResults" id="MSearchResults">
</iframe>
</div>
<div class="header">
<div class="summary">
<a href="#func-members">Functions</a> </div>
<div class="headertitle">
<div class="title">Daemon communication</div> </div>
</div><!--header-->
<div class="contents">
<p>These functions are used to communicate with the X52 daemon.
<a href="#details">More...</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:ga59b382427afc417499311336747fb191"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__x52dcomm.html#ga59b382427afc417499311336747fb191">x52d_dial_command</a> (const char *sock_path)</td></tr>
<tr class="memdesc:ga59b382427afc417499311336747fb191"><td class="mdescLeft">&#160;</td><td class="mdescRight">Open a connection to the daemon. <a href="group__x52dcomm.html#ga59b382427afc417499311336747fb191">More...</a><br /></td></tr>
<tr class="separator:ga59b382427afc417499311336747fb191"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gad72175611919fcafc0a0533b7a01f167"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__x52dcomm.html#gad72175611919fcafc0a0533b7a01f167">x52d_send_command</a> (int sock_fd, char *buffer, size_t buflen)</td></tr>
<tr class="memdesc:gad72175611919fcafc0a0533b7a01f167"><td class="mdescLeft">&#160;</td><td class="mdescRight">Send a command to the daemon and retrieve the response. <a href="group__x52dcomm.html#gad72175611919fcafc0a0533b7a01f167">More...</a><br /></td></tr>
<tr class="separator:gad72175611919fcafc0a0533b7a01f167"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<p>These functions are used to communicate with the X52 daemon. </p>
<h2 class="groupheader">Function Documentation</h2>
<a id="ga59b382427afc417499311336747fb191"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga59b382427afc417499311336747fb191">&#9670;&nbsp;</a></span>x52d_dial_command()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int x52d_dial_command </td>
<td>(</td>
<td class="paramtype">const char *&#160;</td>
<td class="paramname"><em>sock_path</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Open a connection to the daemon. </p>
<p>This method opens a socket connection to the daemon command socket. This socket allows the client to issue commands and retrieve data. The <code>sock_path</code> parameter may be NULL, in which case, it will use the default socket path.</p>
<p>The client will need to use the returned descriptor to communicate with the daemon using <a class="el" href="group__x52dcomm.html#gad72175611919fcafc0a0533b7a01f167">x52d_send_command</a>. Once finished, the client may use the <code>close(2)</code> method to close the file descriptor.</p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramdir">[in]</td><td class="paramname">sock_path</td><td>Path to the daemon command socket.</td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>Non-negative socket file descriptor on success. </dd>
<dd>
-1 on failure, and set <code>errno</code> accordingly.</dd></dl>
<dl class="exception"><dt>Exceptions</dt><dd>
<table class="exception">
<tr><td class="paramname">E2BIG</td><td>returned if the passed socket path is too big </td></tr>
</table>
</dd>
</dl>
</div>
</div>
<a id="gad72175611919fcafc0a0533b7a01f167"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gad72175611919fcafc0a0533b7a01f167">&#9670;&nbsp;</a></span>x52d_send_command()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int x52d_send_command </td>
<td>(</td>
<td class="paramtype">int&#160;</td>
<td class="paramname"><em>sock_fd</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">char *&#160;</td>
<td class="paramname"><em>buffer</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">size_t&#160;</td>
<td class="paramname"><em>buflen</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Send a command to the daemon and retrieve the response. </p>
<p>The client sends the command and parameters as a single NULL terminated string, and retrieves the response in the same manner. Depending on the result, the return status is either a positive integer or -1, and <code>errno</code> is set accordingly.</p>
<p><code>buffer</code> should contain sufficient space to accomodate the returned response string.</p>
<p>This is a blocking function and will not return until either a response is received from the server, or an exception condition occurs.</p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramdir">[in]</td><td class="paramname">sock_fd</td><td>Socket descriptor returned from <a class="el" href="group__x52dcomm.html#ga59b382427afc417499311336747fb191">x52d_dial_command</a></td></tr>
<tr><td class="paramdir">[in,out]</td><td class="paramname">buffer</td><td>Pointer to the string containing the command and parameters. This is also used to save the returned response.</td></tr>
<tr><td class="paramdir">[in]</td><td class="paramname">buflen</td><td>Length of the buffer to hold the returned response.</td></tr>
</table>
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>number of bytes returned from the server </dd>
<dd>
-1 on an error condition, and <code>errno</code> is set accordingly. </dd></dl>
</div>
</div>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.17
</small></address>
</body>
</html>