\hypertarget{classeu_1_1javaexperience_1_1electronic_1_1uartbus_1_1UartbusTools}{}\section{eu.\+javaexperience.\+electronic.\+uartbus.\+Uartbus\+Tools Class Reference}
\label{classeu_1_1javaexperience_1_1electronic_1_1uartbus_1_1UartbusTools}\index{eu.\+javaexperience.\+electronic.\+uartbus.\+Uartbus\+Tools@{eu.\+javaexperience.\+electronic.\+uartbus.\+Uartbus\+Tools}}


Collaboration diagram for eu.\+javaexperience.\+electronic.\+uartbus.\+Uartbus\+Tools\+:\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=259pt]{classeu_1_1javaexperience_1_1electronic_1_1uartbus_1_1UartbusTools__coll__graph}
\end{center}
\end{figure}
\subsection*{Classes}
\begin{DoxyCompactItemize}
\item 
enum {\bfseries Packet\+Formatting\+Mode}
\end{DoxyCompactItemize}
\subsection*{Static Public Member Functions}
\begin{DoxyCompactItemize}
\item 
\mbox{\Hypertarget{classeu_1_1javaexperience_1_1electronic_1_1uartbus_1_1UartbusTools_abc3da655a5ef25cd7aa1ebb00904d2d1}\label{classeu_1_1javaexperience_1_1electronic_1_1uartbus_1_1UartbusTools_abc3da655a5ef25cd7aa1ebb00904d2d1}} 
static byte {\bfseries crc8} (byte\mbox{[}$\,$\mbox{]} data)
\item 
\mbox{\Hypertarget{classeu_1_1javaexperience_1_1electronic_1_1uartbus_1_1UartbusTools_ac75f6edc9be23da7500ac377c65a869e}\label{classeu_1_1javaexperience_1_1electronic_1_1uartbus_1_1UartbusTools_ac75f6edc9be23da7500ac377c65a869e}} 
static byte {\bfseries crc8} (byte\mbox{[}$\,$\mbox{]} data, int length)
\item 
\mbox{\Hypertarget{classeu_1_1javaexperience_1_1electronic_1_1uartbus_1_1UartbusTools_ab290308d5626271fbf07d97b5c7cd191}\label{classeu_1_1javaexperience_1_1electronic_1_1uartbus_1_1UartbusTools_ab290308d5626271fbf07d97b5c7cd191}} 
static byte \mbox{[}$\,$\mbox{]} {\bfseries parse\+Colon\+Data} (String data)
\item 
\mbox{\Hypertarget{classeu_1_1javaexperience_1_1electronic_1_1uartbus_1_1UartbusTools_a2f2952d9d8e0bb843d34aa1b25cc0a33}\label{classeu_1_1javaexperience_1_1electronic_1_1uartbus_1_1UartbusTools_a2f2952d9d8e0bb843d34aa1b25cc0a33}} 
static String {\bfseries format\+Colon\+Data} (byte\mbox{[}$\,$\mbox{]} e)
\item 
\mbox{\Hypertarget{classeu_1_1javaexperience_1_1electronic_1_1uartbus_1_1UartbusTools_a176d224900d534ed01be99f85b0a131c}\label{classeu_1_1javaexperience_1_1electronic_1_1uartbus_1_1UartbusTools_a176d224900d534ed01be99f85b0a131c}} 
static String {\bfseries format\+Colon\+Data\+With\+Validation} (byte\mbox{[}$\,$\mbox{]} e)
\item 
\mbox{\Hypertarget{classeu_1_1javaexperience_1_1electronic_1_1uartbus_1_1UartbusTools_a3c84a4f357eae3eeb52a33a8345da673}\label{classeu_1_1javaexperience_1_1electronic_1_1uartbus_1_1UartbusTools_a3c84a4f357eae3eeb52a33a8345da673}} 
static String {\bfseries format\+Packet\+With\+Mode} (Packet\+Formatting\+Mode mode, byte\mbox{[}$\,$\mbox{]} data)
\item 
\mbox{\Hypertarget{classeu_1_1javaexperience_1_1electronic_1_1uartbus_1_1UartbusTools_a9a405a67e29c3167508b1888cf7f9f3e}\label{classeu_1_1javaexperience_1_1electronic_1_1uartbus_1_1UartbusTools_a9a405a67e29c3167508b1888cf7f9f3e}} 
static int {\bfseries pack\+Value} (boolean signed, int value, byte\mbox{[}$\,$\mbox{]} dst, int start\+Index)
\item 
\mbox{\Hypertarget{classeu_1_1javaexperience_1_1electronic_1_1uartbus_1_1UartbusTools_a75e1ff52c08acdca60262bed78f41a4b}\label{classeu_1_1javaexperience_1_1electronic_1_1uartbus_1_1UartbusTools_a75e1ff52c08acdca60262bed78f41a4b}} 
static int {\bfseries pack\+Value} (boolean signed, long value, byte\mbox{[}$\,$\mbox{]} dst, int start\+Index)
\item 
\mbox{\Hypertarget{classeu_1_1javaexperience_1_1electronic_1_1uartbus_1_1UartbusTools_a88dfc8874ffd80cf3e60142aec05f8b2}\label{classeu_1_1javaexperience_1_1electronic_1_1uartbus_1_1UartbusTools_a88dfc8874ffd80cf3e60142aec05f8b2}} 
static int {\bfseries pack\+Value} (boolean signed, Big\+Integer value, byte\mbox{[}$\,$\mbox{]} dst, int start\+Index)
\item 
\mbox{\Hypertarget{classeu_1_1javaexperience_1_1electronic_1_1uartbus_1_1UartbusTools_a5a69b0629764a39c3beaa2dfc05a51f7}\label{classeu_1_1javaexperience_1_1electronic_1_1uartbus_1_1UartbusTools_a5a69b0629764a39c3beaa2dfc05a51f7}} 
static int {\bfseries calc\+Pack\+Req\+Bytes} (boolean signed, Big\+Integer value)
\item 
\mbox{\Hypertarget{classeu_1_1javaexperience_1_1electronic_1_1uartbus_1_1UartbusTools_a21d6fe59bc24fad6dad8bdb451ea3567}\label{classeu_1_1javaexperience_1_1electronic_1_1uartbus_1_1UartbusTools_a21d6fe59bc24fad6dad8bdb451ea3567}} 
static int {\bfseries calc\+Pack\+Req\+Bytes} (boolean signed, byte\mbox{[}$\,$\mbox{]} value)
\item 
static int \hyperlink{classeu_1_1javaexperience_1_1electronic_1_1uartbus_1_1UartbusTools_aa46096e2942d2ab725db99de03acca6c}{pack\+Value} (Boolean negative, byte\mbox{[}$\,$\mbox{]} value, byte\mbox{[}$\,$\mbox{]} dst, int start\+Index)
\item 
\mbox{\Hypertarget{classeu_1_1javaexperience_1_1electronic_1_1uartbus_1_1UartbusTools_acaf0fd79546015302466c0df8cb27c1a}\label{classeu_1_1javaexperience_1_1electronic_1_1uartbus_1_1UartbusTools_acaf0fd79546015302466c0df8cb27c1a}} 
static byte \mbox{[}$\,$\mbox{]} {\bfseries pack\+Int} (boolean signed, int value)
\item 
\mbox{\Hypertarget{classeu_1_1javaexperience_1_1electronic_1_1uartbus_1_1UartbusTools_a22d51e3904f7c368f4765b21c0e4bf8a}\label{classeu_1_1javaexperience_1_1electronic_1_1uartbus_1_1UartbusTools_a22d51e3904f7c368f4765b21c0e4bf8a}} 
static Big\+Integer {\bfseries unpack\+Value} (boolean signed, byte\mbox{[}$\,$\mbox{]} data, int start\+Index)
\item 
\mbox{\Hypertarget{classeu_1_1javaexperience_1_1electronic_1_1uartbus_1_1UartbusTools_a812c623d50b804a6efd0c35997cf7f80}\label{classeu_1_1javaexperience_1_1electronic_1_1uartbus_1_1UartbusTools_a812c623d50b804a6efd0c35997cf7f80}} 
static Big\+Integer {\bfseries unpack\+Value} (boolean signed, byte\mbox{[}$\,$\mbox{]} data, int start\+Index, int\mbox{[}$\,$\mbox{]} used\+Bytes)
\item 
\mbox{\Hypertarget{classeu_1_1javaexperience_1_1electronic_1_1uartbus_1_1UartbusTools_a67d15dcd4a0ab34339e107a2dd858f89}\label{classeu_1_1javaexperience_1_1electronic_1_1uartbus_1_1UartbusTools_a67d15dcd4a0ab34339e107a2dd858f89}} 
static byte \mbox{[}$\,$\mbox{]} {\bfseries get\+Valid\+Packet} (byte\mbox{[}$\,$\mbox{]} e)
\item 
\mbox{\Hypertarget{classeu_1_1javaexperience_1_1electronic_1_1uartbus_1_1UartbusTools_a8f54f23c7f0ae113bda1b38f8fbebf74}\label{classeu_1_1javaexperience_1_1electronic_1_1uartbus_1_1UartbusTools_a8f54f23c7f0ae113bda1b38f8fbebf74}} 
static boolean {\bfseries is\+Packet\+Crc8\+Valid} (byte\mbox{[}$\,$\mbox{]} data)
\item 
\mbox{\Hypertarget{classeu_1_1javaexperience_1_1electronic_1_1uartbus_1_1UartbusTools_ae651d86bce00f18c16eb4006c12489a9}\label{classeu_1_1javaexperience_1_1electronic_1_1uartbus_1_1UartbusTools_ae651d86bce00f18c16eb4006c12489a9}} 
static void {\bfseries print\+Packet\+Stdout} (byte\mbox{[}$\,$\mbox{]} data)
\item 
\mbox{\Hypertarget{classeu_1_1javaexperience_1_1electronic_1_1uartbus_1_1UartbusTools_ab2c5812dc35e31a48b23764effa08c09}\label{classeu_1_1javaexperience_1_1electronic_1_1uartbus_1_1UartbusTools_ab2c5812dc35e31a48b23764effa08c09}} 
static void {\bfseries init\+Connection} (\hyperlink{interfaceeu_1_1javaexperience_1_1electronic_1_1uartbus_1_1rpc_1_1UartbusConnection}{Uartbus\+Connection} conn)
\end{DoxyCompactItemize}
\subsection*{Static Protected Attributes}
\begin{DoxyCompactItemize}
\item 
\mbox{\Hypertarget{classeu_1_1javaexperience_1_1electronic_1_1uartbus_1_1UartbusTools_a53de653339b2d7d24495f3412a9090e0}\label{classeu_1_1javaexperience_1_1electronic_1_1uartbus_1_1UartbusTools_a53de653339b2d7d24495f3412a9090e0}} 
static final Logger {\bfseries L\+OG} = Java\+Experience\+Logging\+Facility.\+get\+Logger(new Loggable(\char`\"{}Uartbus\+Tools\char`\"{}))
\end{DoxyCompactItemize}


\subsection{Detailed Description}


Definition at line 16 of file Uartbus\+Tools.\+java.



\subsection{Member Function Documentation}
\mbox{\Hypertarget{classeu_1_1javaexperience_1_1electronic_1_1uartbus_1_1UartbusTools_aa46096e2942d2ab725db99de03acca6c}\label{classeu_1_1javaexperience_1_1electronic_1_1uartbus_1_1UartbusTools_aa46096e2942d2ab725db99de03acca6c}} 
\index{eu\+::javaexperience\+::electronic\+::uartbus\+::\+Uartbus\+Tools@{eu\+::javaexperience\+::electronic\+::uartbus\+::\+Uartbus\+Tools}!pack\+Value@{pack\+Value}}
\index{pack\+Value@{pack\+Value}!eu\+::javaexperience\+::electronic\+::uartbus\+::\+Uartbus\+Tools@{eu\+::javaexperience\+::electronic\+::uartbus\+::\+Uartbus\+Tools}}
\subsubsection{\texorpdfstring{pack\+Value()}{packValue()}}
{\footnotesize\ttfamily static int eu.\+javaexperience.\+electronic.\+uartbus.\+Uartbus\+Tools.\+pack\+Value (\begin{DoxyParamCaption}\item[{Boolean}]{negative,  }\item[{byte \mbox{[}$\,$\mbox{]}}]{value,  }\item[{byte \mbox{[}$\,$\mbox{]}}]{dst,  }\item[{int}]{start\+Index }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}, {\ttfamily [static]}}

packed byte scheme\+: X\+N-\/-\/-\/---$\vert$\+X-\/-\/-\/-\/---$\vert$\+X-\/-\/-\/-\/---

first byte\+: X extended address (0 = no, 1 = yes) N negated value (0 = no, 1 = yes)

n\textquotesingle{}th byte\+: X value continued in the next byte + 7 bit number value

negative\+: null\+: unsigned value false\+: signed positive true\+: signed negative 

Definition at line 218 of file Uartbus\+Tools.\+java.


\begin{DoxyCode}
219     \{
220         \textcolor{keywordflow}{if}(0 == value.length)
221         \{
222             \textcolor{keywordflow}{if}(Boolean.TRUE == negative)
223             \{
224                 dst[startIndex] = 0x40;
225             \}
226             \textcolor{keywordflow}{else}
227             \{
228                 dst[startIndex] = 0;
229             \}
230             \textcolor{keywordflow}{return} 1;
231         \}
232         
233         \textcolor{keywordtype}{int} sReq = calcPackReqBytes(null != negative, value);
234         
235         \textcolor{keywordtype}{int} off = 0;
236         \textcolor{keywordtype}{int} index = value.length-1;
237         
238         \textcolor{keywordflow}{for}(\textcolor{keywordtype}{int} i = sReq-1;i >=0;--i,--index)
239         \{
240             \textcolor{keywordtype}{int} val = 0;
241             \textcolor{keywordflow}{if}(0 == off)\textcolor{comment}{//value from the same byte}
242             \{
243                 val = value[index];\textcolor{comment}{//bit offset}
244             \}
245             \textcolor{keywordflow}{else}\textcolor{comment}{//different bytes}
246             \{
247                 val = (0xff & value[index+1]) >> (8-off);
248                 \textcolor{keywordflow}{if}(index >= 0)
249                 \{
250                     val |= (0xff & value[index]) << off;
251                 \}
252             \}
253             
254             val &= 0x7f;
255             
256             \textcolor{keywordflow}{if}(++off == 8)
257             \{
258                 off = 0;
259                 index += 1;
260             \}
261             
262             \textcolor{keywordflow}{if}(i != sReq-1)
263             \{
264                 val |= 0x80;
265             \}
266             
267             \textcolor{keywordflow}{if}(Boolean.TRUE == negative && i == 0)
268             \{
269                 val |= 0x40;
270             \}
271             
272             dst[startIndex+i] = (byte) val;
273         \}
274         
275         \textcolor{keywordflow}{return} sReq;
276     \}
\end{DoxyCode}


The documentation for this class was generated from the following file\+:\begin{DoxyCompactItemize}
\item 
/home/javaexperience/git-\/repositories/javaexperience/uartbus/source/java/uartbus/src/main/java/eu/javaexperience/electronic/uartbus/Uartbus\+Tools.\+java\end{DoxyCompactItemize}
