mini-led-cube/doc/doxygen/html/opendevice_8h_source.html
2011-12-25 13:48:15 +01:00

159 lines
14 KiB
HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://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"/>
<title>CTHN.de - LEDCube - commandline client: opendevice.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body onload='searchBox.OnSelectItem(0);'>
<!-- Generated by Doxygen 1.7.4 -->
<script type="text/javascript"><!--
var searchBox = new SearchBox("searchBox", "search",false,'Search');
--></script>
<div id="top">
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 56px;">
<td style="padding-left: 0.5em;">
<div id="projectname">CTHN.de - LEDCube - commandline client</div>
</td>
</tr>
</tbody>
</table>
</div>
<div id="navrow1" class="tabs">
<ul class="tablist">
<li><a href="index.html"><span>Main&#160;Page</span></a></li>
<li class="current"><a href="files.html"><span>Files</span></a></li>
<li id="searchli">
<div id="MSearchBox" class="MSearchBoxInactive">
<span class="left">
<img id="MSearchSelect" src="search/mag_sel.png"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
alt=""/>
<input type="text" id="MSearchField" value="Search" accesskey="S"
onfocus="searchBox.OnSearchFieldFocus(true)"
onblur="searchBox.OnSearchFieldFocus(false)"
onkeyup="searchBox.OnSearchFieldChange(event)"/>
</span><span class="right">
<a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
</span>
</div>
</li>
</ul>
</div>
<div id="navrow2" class="tabs2">
<ul class="tablist">
<li><a href="files.html"><span>File&#160;List</span></a></li>
<li><a href="globals.html"><span>File&#160;Members</span></a></li>
</ul>
</div>
<div class="header">
<div class="headertitle">
<div class="title">opendevice.h</div> </div>
</div>
<div class="contents">
<a href="opendevice_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/* Name: opendevice.h</span>
<a name="l00002"></a>00002 <span class="comment"> * Project: V-USB host-side library</span>
<a name="l00003"></a>00003 <span class="comment"> * Author: Christian Starkjohann</span>
<a name="l00004"></a>00004 <span class="comment"> * Creation Date: 2008-04-10</span>
<a name="l00005"></a>00005 <span class="comment"> * Tabsize: 4</span>
<a name="l00006"></a>00006 <span class="comment"> * Copyright: (c) 2008 by OBJECTIVE DEVELOPMENT Software GmbH</span>
<a name="l00007"></a>00007 <span class="comment"> * License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt)</span>
<a name="l00008"></a>00008 <span class="comment"> * This Revision: $Id: opendevice.h 755 2009-08-03 17:01:21Z cs $</span>
<a name="l00009"></a>00009 <span class="comment"> */</span>
<a name="l00010"></a>00010
<a name="l00011"></a>00011 <span class="comment">/*</span>
<a name="l00012"></a>00012 <span class="comment">General Description:</span>
<a name="l00013"></a>00013 <span class="comment">This module offers additional functionality for host side drivers based on</span>
<a name="l00014"></a>00014 <span class="comment">libusb or libusb-win32. It includes a function to find and open a device</span>
<a name="l00015"></a>00015 <span class="comment">based on numeric IDs and textual description. It also includes a function to</span>
<a name="l00016"></a>00016 <span class="comment">obtain textual descriptions from a device.</span>
<a name="l00017"></a>00017 <span class="comment"></span>
<a name="l00018"></a>00018 <span class="comment">To use this functionality, simply copy opendevice.c and opendevice.h into your</span>
<a name="l00019"></a>00019 <span class="comment">project and add them to your Makefile. You may modify and redistribute these</span>
<a name="l00020"></a>00020 <span class="comment">files according to the GNU General Public License (GPL) version 2 or 3.</span>
<a name="l00021"></a>00021 <span class="comment">*/</span>
<a name="l00022"></a>00022
<a name="l00023"></a>00023 <span class="preprocessor">#ifndef __OPENDEVICE_H_INCLUDED__</span>
<a name="l00024"></a>00024 <span class="preprocessor"></span><span class="preprocessor">#define __OPENDEVICE_H_INCLUDED__</span>
<a name="l00025"></a>00025 <span class="preprocessor"></span>
<a name="l00026"></a>00026 <span class="preprocessor">#include &lt;usb.h&gt;</span> <span class="comment">/* this is libusb, see http://libusb.sourceforge.net/ */</span>
<a name="l00027"></a>00027 <span class="preprocessor">#include &lt;stdio.h&gt;</span>
<a name="l00028"></a>00028
<a name="l00029"></a>00029 <span class="keywordtype">int</span> <a class="code" href="opendevice_8c.html#a75b5f0b18368de18125662f87524b5b0">usbGetStringAscii</a>(usb_dev_handle *dev, <span class="keywordtype">int</span> index, <span class="keywordtype">char</span> *buf, <span class="keywordtype">int</span> buflen);
<a name="l00030"></a>00030 <span class="comment">/* This function gets a string descriptor from the device. &#39;index&#39; is the</span>
<a name="l00031"></a>00031 <span class="comment"> * string descriptor index. The string is returned in ISO Latin 1 encoding in</span>
<a name="l00032"></a>00032 <span class="comment"> * &#39;buf&#39; and it is terminated with a 0-character. The buffer size must be</span>
<a name="l00033"></a>00033 <span class="comment"> * passed in &#39;buflen&#39; to prevent buffer overflows. A libusb device handle</span>
<a name="l00034"></a>00034 <span class="comment"> * must be given in &#39;dev&#39;.</span>
<a name="l00035"></a>00035 <span class="comment"> * Returns: The length of the string (excluding the terminating 0) or</span>
<a name="l00036"></a>00036 <span class="comment"> * a negative number in case of an error. If there was an error, use</span>
<a name="l00037"></a>00037 <span class="comment"> * usb_strerror() to obtain the error message.</span>
<a name="l00038"></a>00038 <span class="comment"> */</span>
<a name="l00039"></a>00039
<a name="l00040"></a>00040 <span class="keywordtype">int</span> <a class="code" href="opendevice_8c.html#acea645564f1dfcd741ff20038d811ac5">usbOpenDevice</a>(usb_dev_handle **device, <span class="keywordtype">int</span> vendorID, <span class="keywordtype">char</span> *vendorNamePattern, <span class="keywordtype">int</span> productID, <span class="keywordtype">char</span> *productNamePattern, <span class="keywordtype">char</span> *serialNamePattern, FILE *printMatchingDevicesFp, FILE *warningsFp);
<a name="l00041"></a>00041 <span class="comment">/* This function iterates over all devices on all USB busses and searches for</span>
<a name="l00042"></a>00042 <span class="comment"> * a device. Matching is done first by means of Vendor- and Product-ID (passed</span>
<a name="l00043"></a>00043 <span class="comment"> * in &#39;vendorID&#39; and &#39;productID&#39;. An ID of 0 matches any numeric ID (wildcard).</span>
<a name="l00044"></a>00044 <span class="comment"> * When a device matches by its IDs, matching by names is performed. Name</span>
<a name="l00045"></a>00045 <span class="comment"> * matching can be done on textual vendor name (&#39;vendorNamePattern&#39;), product</span>
<a name="l00046"></a>00046 <span class="comment"> * name (&#39;productNamePattern&#39;) and serial number (&#39;serialNamePattern&#39;). A</span>
<a name="l00047"></a>00047 <span class="comment"> * device matches only if all non-null pattern match. If you don&#39;t care about</span>
<a name="l00048"></a>00048 <span class="comment"> * a string, pass NULL for the pattern. Patterns are Unix shell style pattern:</span>
<a name="l00049"></a>00049 <span class="comment"> * &#39;*&#39; stands for 0 or more characters, &#39;?&#39; for one single character, a list</span>
<a name="l00050"></a>00050 <span class="comment"> * of characters in square brackets for a single character from the list</span>
<a name="l00051"></a>00051 <span class="comment"> * (dashes are allowed to specify a range) and if the lis of characters begins</span>
<a name="l00052"></a>00052 <span class="comment"> * with a caret (&#39;^&#39;), it matches one character which is NOT in the list.</span>
<a name="l00053"></a>00053 <span class="comment"> * Other parameters to the function: If &#39;warningsFp&#39; is not NULL, warning</span>
<a name="l00054"></a>00054 <span class="comment"> * messages are printed to this file descriptor with fprintf(). If</span>
<a name="l00055"></a>00055 <span class="comment"> * &#39;printMatchingDevicesFp&#39; is not NULL, no device is opened but matching</span>
<a name="l00056"></a>00056 <span class="comment"> * devices are printed to the given file descriptor with fprintf().</span>
<a name="l00057"></a>00057 <span class="comment"> * If a device is opened, the resulting USB handle is stored in &#39;*device&#39;. A</span>
<a name="l00058"></a>00058 <span class="comment"> * pointer to a &quot;usb_dev_handle *&quot; type variable must be passed here.</span>
<a name="l00059"></a>00059 <span class="comment"> * Returns: 0 on success, an error code (see defines below) on failure.</span>
<a name="l00060"></a>00060 <span class="comment"> */</span>
<a name="l00061"></a>00061
<a name="l00062"></a>00062 <span class="comment">/* usbOpenDevice() error codes: */</span>
<a name="l00063"></a><a class="code" href="opendevice_8h.html#a6d38a8c9d2927333c15aee5d4e118e6c">00063</a> <span class="preprocessor">#define USBOPEN_SUCCESS 0 </span><span class="comment">/* no error */</span>
<a name="l00064"></a><a class="code" href="opendevice_8h.html#a7740d6b3c1581a07523be3b3d5039c95">00064</a> <span class="preprocessor">#define USBOPEN_ERR_ACCESS 1 </span><span class="comment">/* not enough permissions to open device */</span>
<a name="l00065"></a><a class="code" href="opendevice_8h.html#a0d2858ff0ca8d95aaf31876e1535a4db">00065</a> <span class="preprocessor">#define USBOPEN_ERR_IO 2 </span><span class="comment">/* I/O error */</span>
<a name="l00066"></a><a class="code" href="opendevice_8h.html#aeffd7f45947b1e146f8dfc1c6d94704e">00066</a> <span class="preprocessor">#define USBOPEN_ERR_NOTFOUND 3 </span><span class="comment">/* device not found */</span>
<a name="l00067"></a>00067
<a name="l00068"></a>00068
<a name="l00069"></a>00069 <span class="comment">/* Obdev&#39;s free USB IDs, see USB-IDs-for-free.txt for details */</span>
<a name="l00070"></a>00070
<a name="l00071"></a><a class="code" href="opendevice_8h.html#aa2e64eba4eebb9adac118798df28e8f8">00071</a> <span class="preprocessor">#define USB_VID_OBDEV_SHARED 5824 </span><span class="comment">/* obdev&#39;s shared vendor ID */</span>
<a name="l00072"></a><a class="code" href="opendevice_8h.html#a23f57d0a9608bd47ace38f99c3c55c94">00072</a> <span class="preprocessor">#define USB_PID_OBDEV_SHARED_CUSTOM 1500 </span><span class="comment">/* shared PID for custom class devices */</span>
<a name="l00073"></a><a class="code" href="opendevice_8h.html#ae19368147b8342f413dd7b6344a5a93e">00073</a> <span class="preprocessor">#define USB_PID_OBDEV_SHARED_HID 1503 </span><span class="comment">/* shared PID for HIDs except mice &amp; keyboards */</span>
<a name="l00074"></a><a class="code" href="opendevice_8h.html#a146854cde323774f09e364b6cb05197c">00074</a> <span class="preprocessor">#define USB_PID_OBDEV_SHARED_CDCACM 1505 </span><span class="comment">/* shared PID for CDC Modem devices */</span>
<a name="l00075"></a><a class="code" href="opendevice_8h.html#ae93838e6a6f4fb4abc912165b4d9ee34">00075</a> <span class="preprocessor">#define USB_PID_OBDEV_SHARED_MIDI 1508 </span><span class="comment">/* shared PID for MIDI class devices */</span>
<a name="l00076"></a>00076
<a name="l00077"></a>00077 <span class="preprocessor">#endif </span><span class="comment">/* __OPENDEVICE_H_INCLUDED__ */</span>
</pre></div></div>
</div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Defines</a></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>
<hr class="footer"/><address class="footer"><small>Generated on Sun Dec 25 2011 13:37:31 for CTHN.de - LEDCube - commandline client by&#160;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.4 </small></address>
</body>
</html>