\doxysection{Utility functions to deal with serial ports}
\label{group__serial}\index{Utility functions to deal with serial ports@{Utility functions to deal with serial ports}}


Osmocom serial port helpers.  


\doxysubsection*{Files}
\begin{DoxyCompactItemize}
\item 
file \textbf{ serial.\+h}
\begin{DoxyCompactList}\small\item\em Osmocom serial port helpers. \end{DoxyCompactList}\item 
file \textbf{ serial.\+c}
\begin{DoxyCompactList}\small\item\em Utility functions to deal with serial ports. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsection*{Macros}
\begin{DoxyCompactItemize}
\item 
\#define \textbf{ dbg\+\_\+perror}(\textbf{ x})~do \{ \} while (0)
\end{DoxyCompactItemize}
\doxysubsection*{Functions}
\begin{DoxyCompactItemize}
\item 
int \textbf{ osmo\+\_\+serial\+\_\+init} (const char $\ast$dev, speed\+\_\+t baudrate)
\begin{DoxyCompactList}\small\item\em Open serial device and does base init. \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+serial\+\_\+set\+\_\+baudrate} (int fd, speed\+\_\+t baudrate)
\begin{DoxyCompactList}\small\item\em Change current baudrate. \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+serial\+\_\+set\+\_\+custom\+\_\+baudrate} (int fd, int baudrate)
\begin{DoxyCompactList}\small\item\em Change current baudrate to a custom one using OS specific method. \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+serial\+\_\+clear\+\_\+custom\+\_\+baudrate} (int fd)
\begin{DoxyCompactList}\small\item\em Clear any custom baudrate. \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+serial\+\_\+speed\+\_\+t} (unsigned int baudrate, speed\+\_\+t $\ast$speed)
\begin{DoxyCompactList}\small\item\em Convert unsigned integer value to speed\+\_\+t. \end{DoxyCompactList}\item 
static int \textbf{ \+\_\+osmo\+\_\+serial\+\_\+set\+\_\+baudrate} (int fd, speed\+\_\+t baudrate)
\end{DoxyCompactItemize}


\doxysubsection{Detailed Description}
Osmocom serial port helpers. 



\doxysubsection{Macro Definition Documentation}
\mbox{\label{group__serial_ga7c79736a4054bb325bc9228b286401f7}} 
\index{Utility functions to deal with serial ports@{Utility functions to deal with serial ports}!dbg\_perror@{dbg\_perror}}
\index{dbg\_perror@{dbg\_perror}!Utility functions to deal with serial ports@{Utility functions to deal with serial ports}}
\doxysubsubsection{dbg\_perror}
{\footnotesize\ttfamily \#define dbg\+\_\+perror(\begin{DoxyParamCaption}\item[{}]{\textbf{ x} }\end{DoxyParamCaption})~do \{ \} while (0)}



\doxysubsection{Function Documentation}
\mbox{\label{group__serial_gad354988168b080f5a2a8f6b0e3aa4c2e}} 
\index{Utility functions to deal with serial ports@{Utility functions to deal with serial ports}!\_osmo\_serial\_set\_baudrate@{\_osmo\_serial\_set\_baudrate}}
\index{\_osmo\_serial\_set\_baudrate@{\_osmo\_serial\_set\_baudrate}!Utility functions to deal with serial ports@{Utility functions to deal with serial ports}}
\doxysubsubsection{\_osmo\_serial\_set\_baudrate()}
{\footnotesize\ttfamily static int \+\_\+osmo\+\_\+serial\+\_\+set\+\_\+baudrate (\begin{DoxyParamCaption}\item[{int}]{fd,  }\item[{speed\+\_\+t}]{baudrate }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}



References \textbf{ dbg\+\_\+perror}.



Referenced by \textbf{ osmo\+\_\+serial\+\_\+set\+\_\+baudrate()}, and \textbf{ osmo\+\_\+serial\+\_\+set\+\_\+custom\+\_\+baudrate()}.

\mbox{\label{group__serial_gaf674bb14346e7bbd6f0555464fb66a53}} 
\index{Utility functions to deal with serial ports@{Utility functions to deal with serial ports}!osmo\_serial\_clear\_custom\_baudrate@{osmo\_serial\_clear\_custom\_baudrate}}
\index{osmo\_serial\_clear\_custom\_baudrate@{osmo\_serial\_clear\_custom\_baudrate}!Utility functions to deal with serial ports@{Utility functions to deal with serial ports}}
\doxysubsubsection{osmo\_serial\_clear\_custom\_baudrate()}
{\footnotesize\ttfamily int osmo\+\_\+serial\+\_\+clear\+\_\+custom\+\_\+baudrate (\begin{DoxyParamCaption}\item[{int}]{fd }\end{DoxyParamCaption})}



Clear any custom baudrate. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em fd} & File descriptor of the open device \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 for success or negative errno.
\end{DoxyReturn}
This function might not work on all OS or with all type of serial adapters 

References \textbf{ dbg\+\_\+perror}.



Referenced by \textbf{ osmo\+\_\+serial\+\_\+set\+\_\+baudrate()}.

\mbox{\label{group__serial_ga1f1af4f9541cea98915c807938d576af}} 
\index{Utility functions to deal with serial ports@{Utility functions to deal with serial ports}!osmo\_serial\_init@{osmo\_serial\_init}}
\index{osmo\_serial\_init@{osmo\_serial\_init}!Utility functions to deal with serial ports@{Utility functions to deal with serial ports}}
\doxysubsubsection{osmo\_serial\_init()}
{\footnotesize\ttfamily int osmo\+\_\+serial\+\_\+init (\begin{DoxyParamCaption}\item[{const char $\ast$}]{dev,  }\item[{speed\+\_\+t}]{baudrate }\end{DoxyParamCaption})}



Open serial device and does base init. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em dev} & Path to the device node to open \\
\hline
\mbox{\texttt{ in}}  & {\em baudrate} & Baudrate constant (speed\+\_\+t\+: B9600, B...) \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
$>$=0 file descriptor in case of success or negative errno. 
\end{DoxyReturn}


References \textbf{ dbg\+\_\+perror}, and \textbf{ flags}.

\mbox{\label{group__serial_gac12e9df0274d063a3a188f16c9f86378}} 
\index{Utility functions to deal with serial ports@{Utility functions to deal with serial ports}!osmo\_serial\_set\_baudrate@{osmo\_serial\_set\_baudrate}}
\index{osmo\_serial\_set\_baudrate@{osmo\_serial\_set\_baudrate}!Utility functions to deal with serial ports@{Utility functions to deal with serial ports}}
\doxysubsubsection{osmo\_serial\_set\_baudrate()}
{\footnotesize\ttfamily int osmo\+\_\+serial\+\_\+set\+\_\+baudrate (\begin{DoxyParamCaption}\item[{int}]{fd,  }\item[{speed\+\_\+t}]{baudrate }\end{DoxyParamCaption})}



Change current baudrate. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em fd} & File descriptor of the open device \\
\hline
\mbox{\texttt{ in}}  & {\em baudrate} & Baudrate constant (speed\+\_\+t\+: B9600, B...) \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 for success or negative errno. 
\end{DoxyReturn}


References \textbf{ \+\_\+osmo\+\_\+serial\+\_\+set\+\_\+baudrate()}, and \textbf{ osmo\+\_\+serial\+\_\+clear\+\_\+custom\+\_\+baudrate()}.

\mbox{\label{group__serial_ga53bf675db7d6c886d683bcfa3621193c}} 
\index{Utility functions to deal with serial ports@{Utility functions to deal with serial ports}!osmo\_serial\_set\_custom\_baudrate@{osmo\_serial\_set\_custom\_baudrate}}
\index{osmo\_serial\_set\_custom\_baudrate@{osmo\_serial\_set\_custom\_baudrate}!Utility functions to deal with serial ports@{Utility functions to deal with serial ports}}
\doxysubsubsection{osmo\_serial\_set\_custom\_baudrate()}
{\footnotesize\ttfamily int osmo\+\_\+serial\+\_\+set\+\_\+custom\+\_\+baudrate (\begin{DoxyParamCaption}\item[{int}]{fd,  }\item[{int}]{baudrate }\end{DoxyParamCaption})}



Change current baudrate to a custom one using OS specific method. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em fd} & File descriptor of the open device \\
\hline
\mbox{\texttt{ in}}  & {\em baudrate} & Baudrate as integer \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 for success or negative errno.
\end{DoxyReturn}
This function might not work on all OS or with all type of serial adapters 

References \textbf{ \+\_\+osmo\+\_\+serial\+\_\+set\+\_\+baudrate()}, and \textbf{ dbg\+\_\+perror}.

\mbox{\label{group__serial_ga79c9ea27d7852c2652122e5bbdb47511}} 
\index{Utility functions to deal with serial ports@{Utility functions to deal with serial ports}!osmo\_serial\_speed\_t@{osmo\_serial\_speed\_t}}
\index{osmo\_serial\_speed\_t@{osmo\_serial\_speed\_t}!Utility functions to deal with serial ports@{Utility functions to deal with serial ports}}
\doxysubsubsection{osmo\_serial\_speed\_t()}
{\footnotesize\ttfamily int osmo\+\_\+serial\+\_\+speed\+\_\+t (\begin{DoxyParamCaption}\item[{unsigned int}]{baudrate,  }\item[{speed\+\_\+t $\ast$}]{speed }\end{DoxyParamCaption})}



Convert unsigned integer value to speed\+\_\+t. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em baudrate} & integer value containing the desired standard baudrate \\
\hline
\mbox{\texttt{ out}}  & {\em speed} & the standrd baudrate requested in speed\+\_\+t format \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 for success or negative errno. 
\end{DoxyReturn}
