\doxysection{src/usb/osmo\+\_\+libusb.c File Reference}
\label{osmo__libusb_8c}\index{src/usb/osmo\_libusb.c@{src/usb/osmo\_libusb.c}}
{\ttfamily \#include $<$errno.\+h$>$}\newline
{\ttfamily \#include $<$unistd.\+h$>$}\newline
{\ttfamily \#include $<$stdlib.\+h$>$}\newline
{\ttfamily \#include $<$stdint.\+h$>$}\newline
{\ttfamily \#include $<$string.\+h$>$}\newline
{\ttfamily \#include $<$poll.\+h$>$}\newline
{\ttfamily \#include $<$osmocom/core/utils.\+h$>$}\newline
{\ttfamily \#include $<$osmocom/core/logging.\+h$>$}\newline
{\ttfamily \#include $<$osmocom/core/select.\+h$>$}\newline
{\ttfamily \#include $<$osmocom/core/talloc.\+h$>$}\newline
{\ttfamily \#include $<$libusb.\+h$>$}\newline
\doxysubsection*{Macros}
\begin{DoxyCompactItemize}
\item 
\#define \textbf{ DLUSB}~\textbf{ DLINP}
\end{DoxyCompactItemize}
\doxysubsection*{Functions}
\begin{DoxyCompactItemize}
\item 
static int \textbf{ osmo\+\_\+usb\+\_\+fd\+\_\+cb} (struct \textbf{ osmo\+\_\+fd} $\ast$ofd, unsigned int what)
\item 
static void \textbf{ osmo\+\_\+usb\+\_\+added\+\_\+cb} (int \textbf{ fd}, short events, void $\ast$user\+\_\+data)
\item 
static void \textbf{ osmo\+\_\+usb\+\_\+removed\+\_\+cb} (int \textbf{ fd}, void $\ast$user\+\_\+data)
\item 
char $\ast$ \textbf{ osmo\+\_\+libusb\+\_\+dev\+\_\+get\+\_\+path\+\_\+buf} (char $\ast$buf, size\+\_\+t bufsize, libusb\+\_\+device $\ast$dev)
\begin{DoxyCompactList}\small\item\em obtain the string representation of the USB device path of given device. \end{DoxyCompactList}\item 
char $\ast$ \textbf{ osmo\+\_\+libusb\+\_\+dev\+\_\+get\+\_\+path\+\_\+c} (void $\ast$ctx, libusb\+\_\+device $\ast$dev)
\begin{DoxyCompactList}\small\item\em obtain the string representation of the USB device path of given device. \end{DoxyCompactList}\item 
static int \textbf{ match\+\_\+dev\+\_\+id} (const struct libusb\+\_\+device\+\_\+descriptor $\ast$\textbf{ desc}, const struct \textbf{ dev\+\_\+id} $\ast$id)
\item 
static int \textbf{ match\+\_\+dev\+\_\+ids} (const struct libusb\+\_\+device\+\_\+descriptor $\ast$\textbf{ desc}, const struct \textbf{ dev\+\_\+id} $\ast$ids)
\item 
libusb\+\_\+device $\ast$$\ast$ \textbf{ osmo\+\_\+libusb\+\_\+find\+\_\+matching\+\_\+usb\+\_\+devs} (void $\ast$ctx, struct libusb\+\_\+context $\ast$luctx, const struct \textbf{ dev\+\_\+id} $\ast$dev\+\_\+ids)
\begin{DoxyCompactList}\small\item\em Find USB devices matching the specified list of USB Vendor\+ID/\+Product\+IDs. \end{DoxyCompactList}\item 
libusb\+\_\+device $\ast$ \textbf{ osmo\+\_\+libusb\+\_\+find\+\_\+matching\+\_\+dev\+\_\+path} (struct libusb\+\_\+context $\ast$luctx, const struct \textbf{ dev\+\_\+id} $\ast$dev\+\_\+ids, const char $\ast$path)
\begin{DoxyCompactList}\small\item\em Find a USB device of matching Vendor\+ID/\+Product\+ID at given path. \end{DoxyCompactList}\item 
libusb\+\_\+device $\ast$ \textbf{ osmo\+\_\+libusb\+\_\+find\+\_\+matching\+\_\+dev\+\_\+serial} (struct libusb\+\_\+context $\ast$luctx, const struct \textbf{ dev\+\_\+id} $\ast$dev\+\_\+ids, const char $\ast$serial)
\begin{DoxyCompactList}\small\item\em Find a USB device of matching Vendor\+ID/\+Product\+ID and given i\+Serial string. \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+libusb\+\_\+dev\+\_\+find\+\_\+matching\+\_\+interfaces} (libusb\+\_\+device $\ast$dev, int class, int sub\+\_\+class, int protocol, struct \textbf{ usb\+\_\+interface\+\_\+match} $\ast$out, unsigned int out\+\_\+len)
\begin{DoxyCompactList}\small\item\em find a matching interface among all interfaces of the given USB device. \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+libusb\+\_\+find\+\_\+matching\+\_\+interfaces} (libusb\+\_\+context $\ast$luctx, const struct \textbf{ dev\+\_\+id} $\ast$dev\+\_\+ids, int class, int sub\+\_\+class, int protocol, struct \textbf{ usb\+\_\+interface\+\_\+match} $\ast$out, unsigned int out\+\_\+len)
\begin{DoxyCompactList}\small\item\em find matching interfaces among a list devices of specified Vendor\+Id/\+Product\+ID tuples. \end{DoxyCompactList}\item 
libusb\+\_\+device\+\_\+handle $\ast$ \textbf{ osmo\+\_\+libusb\+\_\+open\+\_\+claim\+\_\+interface} (void $\ast$ctx, libusb\+\_\+context $\ast$luctx, const struct \textbf{ usb\+\_\+interface\+\_\+match} $\ast$ifm)
\begin{DoxyCompactList}\small\item\em open matching USB device and claim interface \end{DoxyCompactList}\item 
void \textbf{ osmo\+\_\+libusb\+\_\+match\+\_\+init} (struct \textbf{ osmo\+\_\+usb\+\_\+matchspec} $\ast$cfg, int if\+\_\+class, int if\+\_\+subclass, int if\+\_\+proto)
\item 
libusb\+\_\+device\+\_\+handle $\ast$ \textbf{ osmo\+\_\+libusb\+\_\+find\+\_\+open\+\_\+claim} (const struct \textbf{ osmo\+\_\+usb\+\_\+matchspec} $\ast$cfg, const struct \textbf{ dev\+\_\+id} $\ast$default\+\_\+dev\+\_\+ids)
\begin{DoxyCompactList}\small\item\em high-\/level all-\/in-\/one function for USB device, config + interface matching + opening. \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+libusb\+\_\+get\+\_\+ep\+\_\+addrs} (libusb\+\_\+device\+\_\+handle $\ast$devh, unsigned int if\+\_\+num, uint8\+\_\+t $\ast$out, uint8\+\_\+t $\ast$in, uint8\+\_\+t $\ast$irq)
\begin{DoxyCompactList}\small\item\em obtain the endpoint addresses for a given USB interface. \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+libusb\+\_\+init} (libusb\+\_\+context $\ast$$\ast$pluctx)
\item 
void \textbf{ osmo\+\_\+libusb\+\_\+exit} (libusb\+\_\+context $\ast$luctx)
\end{DoxyCompactItemize}


\doxysubsection{Macro Definition Documentation}
\mbox{\label{osmo__libusb_8c_a00ba013717621985a2ddbecbd00919dc}} 
\index{osmo\_libusb.c@{osmo\_libusb.c}!DLUSB@{DLUSB}}
\index{DLUSB@{DLUSB}!osmo\_libusb.c@{osmo\_libusb.c}}
\doxysubsubsection{DLUSB}
{\footnotesize\ttfamily \#define DLUSB~\textbf{ DLINP}}



\doxysubsection{Function Documentation}
\mbox{\label{osmo__libusb_8c_a1a28ac79d9e4f2e115ceffc431a17dc4}} 
\index{osmo\_libusb.c@{osmo\_libusb.c}!match\_dev\_id@{match\_dev\_id}}
\index{match\_dev\_id@{match\_dev\_id}!osmo\_libusb.c@{osmo\_libusb.c}}
\doxysubsubsection{match\_dev\_id()}
{\footnotesize\ttfamily static int match\+\_\+dev\+\_\+id (\begin{DoxyParamCaption}\item[{const struct libusb\+\_\+device\+\_\+descriptor $\ast$}]{desc,  }\item[{const struct \textbf{ dev\+\_\+id} $\ast$}]{id }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}



References \textbf{ dev\+\_\+id\+::product\+\_\+id}, and \textbf{ dev\+\_\+id\+::vendor\+\_\+id}.



Referenced by \textbf{ match\+\_\+dev\+\_\+ids()}.

\mbox{\label{osmo__libusb_8c_a4bd2cb6e8456b9095e9ac63febc7163e}} 
\index{osmo\_libusb.c@{osmo\_libusb.c}!match\_dev\_ids@{match\_dev\_ids}}
\index{match\_dev\_ids@{match\_dev\_ids}!osmo\_libusb.c@{osmo\_libusb.c}}
\doxysubsubsection{match\_dev\_ids()}
{\footnotesize\ttfamily static int match\+\_\+dev\+\_\+ids (\begin{DoxyParamCaption}\item[{const struct libusb\+\_\+device\+\_\+descriptor $\ast$}]{desc,  }\item[{const struct \textbf{ dev\+\_\+id} $\ast$}]{ids }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}



References \textbf{ match\+\_\+dev\+\_\+id()}, and \textbf{ dev\+\_\+id\+::vendor\+\_\+id}.



Referenced by \textbf{ osmo\+\_\+libusb\+\_\+find\+\_\+matching\+\_\+dev\+\_\+path()}, \textbf{ osmo\+\_\+libusb\+\_\+find\+\_\+matching\+\_\+dev\+\_\+serial()}, and \textbf{ osmo\+\_\+libusb\+\_\+find\+\_\+matching\+\_\+usb\+\_\+devs()}.

\mbox{\label{osmo__libusb_8c_ad5e551fd22b270a4f306bd6c86b9f765}} 
\index{osmo\_libusb.c@{osmo\_libusb.c}!osmo\_libusb\_dev\_find\_matching\_interfaces@{osmo\_libusb\_dev\_find\_matching\_interfaces}}
\index{osmo\_libusb\_dev\_find\_matching\_interfaces@{osmo\_libusb\_dev\_find\_matching\_interfaces}!osmo\_libusb.c@{osmo\_libusb.c}}
\doxysubsubsection{osmo\_libusb\_dev\_find\_matching\_interfaces()}
{\footnotesize\ttfamily int osmo\+\_\+libusb\+\_\+dev\+\_\+find\+\_\+matching\+\_\+interfaces (\begin{DoxyParamCaption}\item[{libusb\+\_\+device $\ast$}]{dev,  }\item[{int}]{class,  }\item[{int}]{sub\+\_\+class,  }\item[{int}]{protocol,  }\item[{struct \textbf{ usb\+\_\+interface\+\_\+match} $\ast$}]{out,  }\item[{unsigned int}]{out\+\_\+len }\end{DoxyParamCaption})}



find a matching interface among all interfaces of the given USB device. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em dev} & USB device in which we shall search \\
\hline
\mbox{\texttt{ in}}  & {\em class} & USB Interface Class to look for \\
\hline
\mbox{\texttt{ in}}  & {\em sub\+\_\+class} & USB Interface Subclass to look for \\
\hline
\mbox{\texttt{ in}}  & {\em protocol} & USB Interface Protocol to look for \\
\hline
\mbox{\texttt{ out}}  & {\em out} & User-\/allocated array for storing matches \\
\hline
\mbox{\texttt{ in}}  & {\em out\+\_\+len} & Length of out array \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
number of matching interfaces; negative in case of error 
\end{DoxyReturn}


References \textbf{ usb\+\_\+interface\+\_\+match\+::addr}, \textbf{ usb\+\_\+interface\+\_\+match\+::altsetting}, \textbf{ usb\+\_\+interface\+\_\+match\+::class}, \textbf{ usb\+\_\+interface\+\_\+match\+::configuration}, \textbf{ usb\+\_\+interface\+\_\+match\+::interface}, \textbf{ osmo\+\_\+libusb\+\_\+dev\+\_\+get\+\_\+path\+\_\+buf()}, \textbf{ OSMO\+\_\+\+STRLCPY\+\_\+\+ARRAY}, \textbf{ usb\+\_\+interface\+\_\+match\+::path}, \textbf{ usb\+\_\+interface\+\_\+match\+::product}, \textbf{ usb\+\_\+interface\+\_\+match\+::protocol}, \textbf{ usb\+\_\+interface\+\_\+match\+::string\+\_\+idx}, \textbf{ usb\+\_\+interface\+\_\+match\+::sub\+\_\+class}, \textbf{ usb\+\_\+interface\+\_\+match\+::usb\+\_\+dev}, \textbf{ USB\+\_\+\+MAX\+\_\+\+PATH\+\_\+\+LEN}, and \textbf{ usb\+\_\+interface\+\_\+match\+::vendor}.



Referenced by \textbf{ osmo\+\_\+libusb\+\_\+find\+\_\+matching\+\_\+interfaces()}, and \textbf{ osmo\+\_\+libusb\+\_\+find\+\_\+open\+\_\+claim()}.

\mbox{\label{osmo__libusb_8c_ab6ead842c31727b4b18fdec0bbb51859}} 
\index{osmo\_libusb.c@{osmo\_libusb.c}!osmo\_libusb\_dev\_get\_path\_buf@{osmo\_libusb\_dev\_get\_path\_buf}}
\index{osmo\_libusb\_dev\_get\_path\_buf@{osmo\_libusb\_dev\_get\_path\_buf}!osmo\_libusb.c@{osmo\_libusb.c}}
\doxysubsubsection{osmo\_libusb\_dev\_get\_path\_buf()}
{\footnotesize\ttfamily char $\ast$ osmo\+\_\+libusb\+\_\+dev\+\_\+get\+\_\+path\+\_\+buf (\begin{DoxyParamCaption}\item[{char $\ast$}]{buf,  }\item[{size\+\_\+t}]{bufsize,  }\item[{libusb\+\_\+device $\ast$}]{dev }\end{DoxyParamCaption})}



obtain the string representation of the USB device path of given device. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ out}}  & {\em buf} & Output string buffer \\
\hline
\mbox{\texttt{ in}}  & {\em bufsize} & Size of output string buffer in bytes \\
\hline
\mbox{\texttt{ in}}  & {\em dev} & USB device whose bus path we want to obtain \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
pointer to \textquotesingle{}buf\textquotesingle{} in case of success; NULL in case of error 
\end{DoxyReturn}


References \textbf{ osmo\+\_\+strbuf\+::buf}, and \textbf{ OSMO\+\_\+\+STRBUF\+\_\+\+PRINTF}.



Referenced by \textbf{ osmo\+\_\+libusb\+\_\+dev\+\_\+find\+\_\+matching\+\_\+interfaces()}, \textbf{ osmo\+\_\+libusb\+\_\+dev\+\_\+get\+\_\+path\+\_\+c()}, \textbf{ osmo\+\_\+libusb\+\_\+find\+\_\+matching\+\_\+dev\+\_\+path()}, and \textbf{ osmo\+\_\+libusb\+\_\+open\+\_\+claim\+\_\+interface()}.

\mbox{\label{osmo__libusb_8c_a512a5c350451c126b102688db544b3be}} 
\index{osmo\_libusb.c@{osmo\_libusb.c}!osmo\_libusb\_dev\_get\_path\_c@{osmo\_libusb\_dev\_get\_path\_c}}
\index{osmo\_libusb\_dev\_get\_path\_c@{osmo\_libusb\_dev\_get\_path\_c}!osmo\_libusb.c@{osmo\_libusb.c}}
\doxysubsubsection{osmo\_libusb\_dev\_get\_path\_c()}
{\footnotesize\ttfamily char $\ast$ osmo\+\_\+libusb\+\_\+dev\+\_\+get\+\_\+path\+\_\+c (\begin{DoxyParamCaption}\item[{void $\ast$}]{ctx,  }\item[{libusb\+\_\+device $\ast$}]{dev }\end{DoxyParamCaption})}



obtain the string representation of the USB device path of given device. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em talloc} & context from which to dynamically allocate output string buffer \\
\hline
\mbox{\texttt{ in}}  & {\em dev} & USB device whose bus path we want to obtain \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
pointer to \textquotesingle{}buf\textquotesingle{} in case of success; NULL in case of error 
\end{DoxyReturn}


References \textbf{ osmo\+\_\+strbuf\+::buf}, \textbf{ osmo\+\_\+libusb\+\_\+dev\+\_\+get\+\_\+path\+\_\+buf()}, and \textbf{ USB\+\_\+\+MAX\+\_\+\+PATH\+\_\+\+LEN}.

\mbox{\label{osmo__libusb_8c_a8c0e7fa643285efee2c86e198b944457}} 
\index{osmo\_libusb.c@{osmo\_libusb.c}!osmo\_libusb\_exit@{osmo\_libusb\_exit}}
\index{osmo\_libusb\_exit@{osmo\_libusb\_exit}!osmo\_libusb.c@{osmo\_libusb.c}}
\doxysubsubsection{osmo\_libusb\_exit()}
{\footnotesize\ttfamily void osmo\+\_\+libusb\+\_\+exit (\begin{DoxyParamCaption}\item[{libusb\+\_\+context $\ast$}]{luctx }\end{DoxyParamCaption})}

\mbox{\label{osmo__libusb_8c_a66d1b36c3872e438f324928b6b548a0e}} 
\index{osmo\_libusb.c@{osmo\_libusb.c}!osmo\_libusb\_find\_matching\_dev\_path@{osmo\_libusb\_find\_matching\_dev\_path}}
\index{osmo\_libusb\_find\_matching\_dev\_path@{osmo\_libusb\_find\_matching\_dev\_path}!osmo\_libusb.c@{osmo\_libusb.c}}
\doxysubsubsection{osmo\_libusb\_find\_matching\_dev\_path()}
{\footnotesize\ttfamily libusb\+\_\+device $\ast$ osmo\+\_\+libusb\+\_\+find\+\_\+matching\+\_\+dev\+\_\+path (\begin{DoxyParamCaption}\item[{struct libusb\+\_\+context $\ast$}]{luctx,  }\item[{const struct \textbf{ dev\+\_\+id} $\ast$}]{dev\+\_\+ids,  }\item[{const char $\ast$}]{path }\end{DoxyParamCaption})}



Find a USB device of matching Vendor\+ID/\+Product\+ID at given path. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em luctx} & libusb context on which to operate \\
\hline
\mbox{\texttt{ in}}  & {\em dev\+\_\+ids} & zer-\/oterminated array of Vendor\+Id/\+Product\+Id tuples \\
\hline
\mbox{\texttt{ in}}  & {\em path} & string representation of USB path \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
libusb\+\_\+device if there was exactly one match; NULL otherwise 
\end{DoxyReturn}


References \textbf{ DLUSB}, \textbf{ LOGL\+\_\+\+ERROR}, \textbf{ LOGP}, \textbf{ match\+\_\+dev\+\_\+ids()}, and \textbf{ osmo\+\_\+libusb\+\_\+dev\+\_\+get\+\_\+path\+\_\+buf()}.



Referenced by \textbf{ osmo\+\_\+libusb\+\_\+find\+\_\+open\+\_\+claim()}.

\mbox{\label{osmo__libusb_8c_aa430b3fcc238c75f0e7609bba41e3d9f}} 
\index{osmo\_libusb.c@{osmo\_libusb.c}!osmo\_libusb\_find\_matching\_dev\_serial@{osmo\_libusb\_find\_matching\_dev\_serial}}
\index{osmo\_libusb\_find\_matching\_dev\_serial@{osmo\_libusb\_find\_matching\_dev\_serial}!osmo\_libusb.c@{osmo\_libusb.c}}
\doxysubsubsection{osmo\_libusb\_find\_matching\_dev\_serial()}
{\footnotesize\ttfamily libusb\+\_\+device $\ast$ osmo\+\_\+libusb\+\_\+find\+\_\+matching\+\_\+dev\+\_\+serial (\begin{DoxyParamCaption}\item[{struct libusb\+\_\+context $\ast$}]{luctx,  }\item[{const struct \textbf{ dev\+\_\+id} $\ast$}]{dev\+\_\+ids,  }\item[{const char $\ast$}]{serial }\end{DoxyParamCaption})}



Find a USB device of matching Vendor\+ID/\+Product\+ID and given i\+Serial string. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em luctx} & libusb context on which to operate \\
\hline
\mbox{\texttt{ in}}  & {\em dev\+\_\+ids} & zer-\/oterminated array of Vendor\+Id/\+Product\+Id tuples \\
\hline
\mbox{\texttt{ in}}  & {\em serial} & string representation of serial number \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
libusb\+\_\+device if there was exactly one match; NULL otherwise 
\end{DoxyReturn}


References \textbf{ DLUSB}, \textbf{ LOGL\+\_\+\+ERROR}, \textbf{ LOGP}, and \textbf{ match\+\_\+dev\+\_\+ids()}.

\mbox{\label{osmo__libusb_8c_ac6b4f492edd7f4c2c93c3734257ddfde}} 
\index{osmo\_libusb.c@{osmo\_libusb.c}!osmo\_libusb\_find\_matching\_interfaces@{osmo\_libusb\_find\_matching\_interfaces}}
\index{osmo\_libusb\_find\_matching\_interfaces@{osmo\_libusb\_find\_matching\_interfaces}!osmo\_libusb.c@{osmo\_libusb.c}}
\doxysubsubsection{osmo\_libusb\_find\_matching\_interfaces()}
{\footnotesize\ttfamily int osmo\+\_\+libusb\+\_\+find\+\_\+matching\+\_\+interfaces (\begin{DoxyParamCaption}\item[{libusb\+\_\+context $\ast$}]{luctx,  }\item[{const struct \textbf{ dev\+\_\+id} $\ast$}]{dev\+\_\+ids,  }\item[{int}]{class,  }\item[{int}]{sub\+\_\+class,  }\item[{int}]{protocol,  }\item[{struct \textbf{ usb\+\_\+interface\+\_\+match} $\ast$}]{out,  }\item[{unsigned int}]{out\+\_\+len }\end{DoxyParamCaption})}



find matching interfaces among a list devices of specified Vendor\+Id/\+Product\+ID tuples. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em luctx} & libusb context on which to operate \\
\hline
\mbox{\texttt{ in}}  & {\em dev\+\_\+ids} & zero-\/terminated array of Vendor\+Id/\+Product\+Id tuples \\
\hline
\mbox{\texttt{ in}}  & {\em class} & USB Interface Class to look for \\
\hline
\mbox{\texttt{ in}}  & {\em sub\+\_\+class} & USB Interface Subclass to look for \\
\hline
\mbox{\texttt{ in}}  & {\em protocol} & USB Interface Protocol to look for \\
\hline
\mbox{\texttt{ out}}  & {\em out} & User-\/allocated array for storing matches \\
\hline
\mbox{\texttt{ in}}  & {\em out\+\_\+len} & Length of out array \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
number of matching interfaces; negative in case of error 
\end{DoxyReturn}


References \textbf{ osmo\+\_\+libusb\+\_\+dev\+\_\+find\+\_\+matching\+\_\+interfaces()}, and \textbf{ osmo\+\_\+libusb\+\_\+find\+\_\+matching\+\_\+usb\+\_\+devs()}.

\mbox{\label{osmo__libusb_8c_a969904dd21ee208e52cd57d888d1dc26}} 
\index{osmo\_libusb.c@{osmo\_libusb.c}!osmo\_libusb\_find\_matching\_usb\_devs@{osmo\_libusb\_find\_matching\_usb\_devs}}
\index{osmo\_libusb\_find\_matching\_usb\_devs@{osmo\_libusb\_find\_matching\_usb\_devs}!osmo\_libusb.c@{osmo\_libusb.c}}
\doxysubsubsection{osmo\_libusb\_find\_matching\_usb\_devs()}
{\footnotesize\ttfamily libusb\+\_\+device $\ast$$\ast$ osmo\+\_\+libusb\+\_\+find\+\_\+matching\+\_\+usb\+\_\+devs (\begin{DoxyParamCaption}\item[{void $\ast$}]{ctx,  }\item[{struct libusb\+\_\+context $\ast$}]{luctx,  }\item[{const struct \textbf{ dev\+\_\+id} $\ast$}]{dev\+\_\+ids }\end{DoxyParamCaption})}



Find USB devices matching the specified list of USB Vendor\+ID/\+Product\+IDs. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em ctx} & talloc context from which to allocate output data \\
\hline
\mbox{\texttt{ in}}  & {\em luctx} & libusb context on which to operate \\
\hline
\mbox{\texttt{ in}}  & {\em dev\+\_\+ids} & zero-\/terminated array of Vendor\+Id/\+Product\+Id tuples \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
array of up to 256 libusb\+\_\+device pointers; NULL in case of error 
\end{DoxyReturn}


References \textbf{ match\+\_\+dev\+\_\+ids()}.



Referenced by \textbf{ osmo\+\_\+libusb\+\_\+find\+\_\+matching\+\_\+interfaces()}, and \textbf{ osmo\+\_\+libusb\+\_\+open\+\_\+claim\+\_\+interface()}.

\mbox{\label{osmo__libusb_8c_a3a970c6d7589d64a4a02b1009ea3569d}} 
\index{osmo\_libusb.c@{osmo\_libusb.c}!osmo\_libusb\_find\_open\_claim@{osmo\_libusb\_find\_open\_claim}}
\index{osmo\_libusb\_find\_open\_claim@{osmo\_libusb\_find\_open\_claim}!osmo\_libusb.c@{osmo\_libusb.c}}
\doxysubsubsection{osmo\_libusb\_find\_open\_claim()}
{\footnotesize\ttfamily libusb\+\_\+device\+\_\+handle $\ast$ osmo\+\_\+libusb\+\_\+find\+\_\+open\+\_\+claim (\begin{DoxyParamCaption}\item[{const struct \textbf{ osmo\+\_\+usb\+\_\+matchspec} $\ast$}]{cfg,  }\item[{const struct \textbf{ dev\+\_\+id} $\ast$}]{default\+\_\+dev\+\_\+ids }\end{DoxyParamCaption})}



high-\/level all-\/in-\/one function for USB device, config + interface matching + opening. 

This function offers the highest level of API among all libosmousb helper functions. It is intended as a one-\/stop shop for everything related to grabbing an interface.

1) looks for a device matching either the VID/\+PID from \textquotesingle{}cfg\textquotesingle{} or \textquotesingle{}default\+\_\+dev\+\_\+ids\textquotesingle{}, if more than one is found, the user is expected to fill in cfg-\/$>$dev.\+path to disambiguate. 2) find any interfaces on the device that match the specification in \textquotesingle{}cfg\textquotesingle{}. The match could be done based on any of (class, subclass, proto, interface number). If there are multiple matches, the caller must disambiguate by specifying the interface number. 3) open the USB device; set the configuration (if needed); claim the interface and set the altsetting


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em cfg} & user-\/supplied match configuration (from command line or config file) \\
\hline
\mbox{\texttt{ in}}  & {\em default\+\_\+dev\+\_\+ids} & Default list of supported Vendor\+Id/\+Product\+Ids \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
libusb\+\_\+device\+\_\+handle on success, NULL on error 
\end{DoxyReturn}


References \textbf{ osmo\+\_\+usb\+\_\+matchspec\+::class}, \textbf{ osmo\+\_\+usb\+\_\+matchspec\+::dev}, \textbf{ DLUSB}, \textbf{ osmo\+\_\+usb\+\_\+matchspec\+::intf}, \textbf{ LOGL\+\_\+\+ERROR}, \textbf{ LOGL\+\_\+\+NOTICE}, \textbf{ LOGP}, \textbf{ osmo\+\_\+usb\+\_\+matchspec\+::num}, \textbf{ osmo\+\_\+libusb\+\_\+dev\+\_\+find\+\_\+matching\+\_\+interfaces()}, \textbf{ osmo\+\_\+libusb\+\_\+find\+\_\+matching\+\_\+dev\+\_\+path()}, \textbf{ osmo\+\_\+libusb\+\_\+open\+\_\+claim\+\_\+interface()}, \textbf{ osmo\+\_\+usb\+\_\+matchspec\+::path}, \textbf{ osmo\+\_\+usb\+\_\+matchspec\+::product\+\_\+id}, \textbf{ osmo\+\_\+usb\+\_\+matchspec\+::proto}, \textbf{ osmo\+\_\+usb\+\_\+matchspec\+::subclass}, and \textbf{ osmo\+\_\+usb\+\_\+matchspec\+::vendor\+\_\+id}.

\mbox{\label{osmo__libusb_8c_a467420e58a70f4f99d19e668e3a542ca}} 
\index{osmo\_libusb.c@{osmo\_libusb.c}!osmo\_libusb\_get\_ep\_addrs@{osmo\_libusb\_get\_ep\_addrs}}
\index{osmo\_libusb\_get\_ep\_addrs@{osmo\_libusb\_get\_ep\_addrs}!osmo\_libusb.c@{osmo\_libusb.c}}
\doxysubsubsection{osmo\_libusb\_get\_ep\_addrs()}
{\footnotesize\ttfamily int osmo\+\_\+libusb\+\_\+get\+\_\+ep\+\_\+addrs (\begin{DoxyParamCaption}\item[{libusb\+\_\+device\+\_\+handle $\ast$}]{devh,  }\item[{unsigned int}]{if\+\_\+num,  }\item[{uint8\+\_\+t $\ast$}]{out,  }\item[{uint8\+\_\+t $\ast$}]{in,  }\item[{uint8\+\_\+t $\ast$}]{irq }\end{DoxyParamCaption})}



obtain the endpoint addresses for a given USB interface. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em devh} & USB device handle on which to operate \\
\hline
\mbox{\texttt{ in}}  & {\em if\+\_\+num} & USB Interface number on which to operate \\
\hline
\mbox{\texttt{ out}}  & {\em out} & user-\/provided storage for OUT endpoint number \\
\hline
\mbox{\texttt{ out}}  & {\em in} & user-\/provided storage for IN endpoint number \\
\hline
\mbox{\texttt{ out}}  & {\em irq} & user-\/provided storage for IRQ endpoint number \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 in case of success; negative in case of error 
\end{DoxyReturn}
\mbox{\label{osmo__libusb_8c_a79bdc810cd2141c14b974b6cd0529a84}} 
\index{osmo\_libusb.c@{osmo\_libusb.c}!osmo\_libusb\_init@{osmo\_libusb\_init}}
\index{osmo\_libusb\_init@{osmo\_libusb\_init}!osmo\_libusb.c@{osmo\_libusb.c}}
\doxysubsubsection{osmo\_libusb\_init()}
{\footnotesize\ttfamily int osmo\+\_\+libusb\+\_\+init (\begin{DoxyParamCaption}\item[{libusb\+\_\+context $\ast$$\ast$}]{pluctx }\end{DoxyParamCaption})}



References \textbf{ DLUSB}, \textbf{ LOGL\+\_\+\+ERROR}, \textbf{ LOGP}, \textbf{ osmo\+\_\+usb\+\_\+added\+\_\+cb()}, and \textbf{ osmo\+\_\+usb\+\_\+removed\+\_\+cb()}.

\mbox{\label{osmo__libusb_8c_a4f2cb47d98039ef05e9a72a267fee0d0}} 
\index{osmo\_libusb.c@{osmo\_libusb.c}!osmo\_libusb\_match\_init@{osmo\_libusb\_match\_init}}
\index{osmo\_libusb\_match\_init@{osmo\_libusb\_match\_init}!osmo\_libusb.c@{osmo\_libusb.c}}
\doxysubsubsection{osmo\_libusb\_match\_init()}
{\footnotesize\ttfamily void osmo\+\_\+libusb\+\_\+match\+\_\+init (\begin{DoxyParamCaption}\item[{struct \textbf{ osmo\+\_\+usb\+\_\+matchspec} $\ast$}]{cfg,  }\item[{int}]{if\+\_\+class,  }\item[{int}]{if\+\_\+subclass,  }\item[{int}]{if\+\_\+proto }\end{DoxyParamCaption})}



References \textbf{ osmo\+\_\+usb\+\_\+matchspec\+::altsetting}, \textbf{ osmo\+\_\+usb\+\_\+matchspec\+::class}, \textbf{ osmo\+\_\+usb\+\_\+matchspec\+::config\+\_\+id}, \textbf{ osmo\+\_\+usb\+\_\+matchspec\+::dev}, \textbf{ osmo\+\_\+usb\+\_\+matchspec\+::intf}, \textbf{ osmo\+\_\+usb\+\_\+matchspec\+::num}, \textbf{ osmo\+\_\+usb\+\_\+matchspec\+::path}, \textbf{ osmo\+\_\+usb\+\_\+matchspec\+::product\+\_\+id}, \textbf{ osmo\+\_\+usb\+\_\+matchspec\+::proto}, \textbf{ osmo\+\_\+usb\+\_\+matchspec\+::subclass}, and \textbf{ osmo\+\_\+usb\+\_\+matchspec\+::vendor\+\_\+id}.

\mbox{\label{osmo__libusb_8c_a144b6c3d06ba2f828d38a797efdd8020}} 
\index{osmo\_libusb.c@{osmo\_libusb.c}!osmo\_libusb\_open\_claim\_interface@{osmo\_libusb\_open\_claim\_interface}}
\index{osmo\_libusb\_open\_claim\_interface@{osmo\_libusb\_open\_claim\_interface}!osmo\_libusb.c@{osmo\_libusb.c}}
\doxysubsubsection{osmo\_libusb\_open\_claim\_interface()}
{\footnotesize\ttfamily libusb\+\_\+device\+\_\+handle $\ast$ osmo\+\_\+libusb\+\_\+open\+\_\+claim\+\_\+interface (\begin{DoxyParamCaption}\item[{void $\ast$}]{ctx,  }\item[{libusb\+\_\+context $\ast$}]{luctx,  }\item[{const struct \textbf{ usb\+\_\+interface\+\_\+match} $\ast$}]{ifm }\end{DoxyParamCaption})}



open matching USB device and claim interface 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em ctx} & talloc context to use for related allocations \\
\hline
\mbox{\texttt{ in}}  & {\em luctx} & libusb context on which to operate \\
\hline
\mbox{\texttt{ in}}  & {\em ifm} & interface match describing interface to claim \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
libusb device chandle on success; NULL on error 
\end{DoxyReturn}


References \textbf{ usb\+\_\+interface\+\_\+match\+::addr}, \textbf{ usb\+\_\+interface\+\_\+match\+::altsetting}, \textbf{ config}, \textbf{ usb\+\_\+interface\+\_\+match\+::configuration}, \textbf{ usb\+\_\+interface\+\_\+match\+::interface}, \textbf{ osmo\+\_\+libusb\+\_\+dev\+\_\+get\+\_\+path\+\_\+buf()}, \textbf{ osmo\+\_\+libusb\+\_\+find\+\_\+matching\+\_\+usb\+\_\+devs()}, \textbf{ usb\+\_\+interface\+\_\+match\+::path}, \textbf{ usb\+\_\+interface\+\_\+match\+::product}, \textbf{ USB\+\_\+\+MAX\+\_\+\+PATH\+\_\+\+LEN}, and \textbf{ usb\+\_\+interface\+\_\+match\+::vendor}.



Referenced by \textbf{ osmo\+\_\+libusb\+\_\+find\+\_\+open\+\_\+claim()}.

\mbox{\label{osmo__libusb_8c_a115ba19ed387a79d8e8579b34b44d754}} 
\index{osmo\_libusb.c@{osmo\_libusb.c}!osmo\_usb\_added\_cb@{osmo\_usb\_added\_cb}}
\index{osmo\_usb\_added\_cb@{osmo\_usb\_added\_cb}!osmo\_libusb.c@{osmo\_libusb.c}}
\doxysubsubsection{osmo\_usb\_added\_cb()}
{\footnotesize\ttfamily static void osmo\+\_\+usb\+\_\+added\+\_\+cb (\begin{DoxyParamCaption}\item[{int}]{fd,  }\item[{short}]{events,  }\item[{void $\ast$}]{user\+\_\+data }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}



References \textbf{ DLUSB}, \textbf{ fd}, \textbf{ LOGL\+\_\+\+ERROR}, \textbf{ LOGP}, \textbf{ OSMO\+\_\+\+FD\+\_\+\+READ}, \textbf{ osmo\+\_\+fd\+\_\+register()}, \textbf{ osmo\+\_\+fd\+\_\+setup()}, \textbf{ OSMO\+\_\+\+FD\+\_\+\+WRITE}, \textbf{ osmo\+\_\+usb\+\_\+fd\+\_\+cb()}, \textbf{ OTC\+\_\+\+GLOBAL}, and \textbf{ osmo\+\_\+fd\+::when}.



Referenced by \textbf{ osmo\+\_\+libusb\+\_\+init()}.

\mbox{\label{osmo__libusb_8c_ab9f7757f421dc8ee31a544d155acd400}} 
\index{osmo\_libusb.c@{osmo\_libusb.c}!osmo\_usb\_fd\_cb@{osmo\_usb\_fd\_cb}}
\index{osmo\_usb\_fd\_cb@{osmo\_usb\_fd\_cb}!osmo\_libusb.c@{osmo\_libusb.c}}
\doxysubsubsection{osmo\_usb\_fd\_cb()}
{\footnotesize\ttfamily static int osmo\+\_\+usb\+\_\+fd\+\_\+cb (\begin{DoxyParamCaption}\item[{struct \textbf{ osmo\+\_\+fd} $\ast$}]{ofd,  }\item[{unsigned int}]{what }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}



References \textbf{ osmo\+\_\+fd\+::data}.



Referenced by \textbf{ osmo\+\_\+usb\+\_\+added\+\_\+cb()}.

\mbox{\label{osmo__libusb_8c_aaa3d4e56f197ad8672466b9eed12b279}} 
\index{osmo\_libusb.c@{osmo\_libusb.c}!osmo\_usb\_removed\_cb@{osmo\_usb\_removed\_cb}}
\index{osmo\_usb\_removed\_cb@{osmo\_usb\_removed\_cb}!osmo\_libusb.c@{osmo\_libusb.c}}
\doxysubsubsection{osmo\_usb\_removed\_cb()}
{\footnotesize\ttfamily static void osmo\+\_\+usb\+\_\+removed\+\_\+cb (\begin{DoxyParamCaption}\item[{int}]{fd,  }\item[{void $\ast$}]{user\+\_\+data }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}



References \textbf{ fd}, \textbf{ osmo\+\_\+fd\+\_\+get\+\_\+by\+\_\+fd()}, and \textbf{ osmo\+\_\+fd\+\_\+unregister()}.



Referenced by \textbf{ osmo\+\_\+libusb\+\_\+init()}.

