📄 avrgsm__zip_8h.html
字号:
<p>References <a class="el" href="AVRGSM__zip_8c-source.html#l00026">hex_lookup</a>, <a class="el" href="AVRGSM__zip_8c-source.html#l00027">mask</a>, <a class="el" href="AVRGSM__zip_8h-source.html#l00026">MESSAGE_LENGTH</a>, and <a class="el" href="AVRGSM__zip_8c-source.html#l00028">power</a>.<p>Referenced by <a class="el" href="AVRGSM__api_8c-source.html#l00160">API_sendmsg()</a>.<p><pre class="fragment"><div>00041 {00042 00044 <span class="keywordtype">int</span> i,ii,iii;00045 <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> encode_c, now_c, next_c;00046 00047 <span class="comment">//Initialization</span>00048 *discarded = 0;00049 00050 <span class="keywordflow">for</span>( i = ii = iii = 0; ( in[i] != <span class="charliteral">'\0'</span> ) && ( i < <a class="code" href="AVRGSM__zip_8h.html#a1">MESSAGE_LENGTH</a> ); ) <span class="comment">//Run through whole string</span>00051 {00052 now_c = in[ i++ ]; <span class="comment">//This char</span>00053 next_c = in[ i ]; <span class="comment">//Next potentially '\0'</span>00054 00055 <span class="comment">//Last char?</span>00056 <span class="keywordflow">if</span>( next_c == <span class="charliteral">'\0'</span> )00057 {00058 next_c = 0;00059 }00060 00061 encode_c = ( now_c >> ii )+ ( <a class="code" href="AVRGSM__zip_8c.html#a1">mask</a>[ ii ] & next_c )*<a class="code" href="AVRGSM__zip_8c.html#a2">power</a>[ ii ];00062 ret[ iii++ ] = <a class="code" href="AVRGSM__zip_8c.html#a0">hex_lookup</a>[ ( encode_c >> 4 ) & 0x0F ]; <span class="comment">//Insert first hex part</span>00063 ret[ iii++ ] = <a class="code" href="AVRGSM__zip_8c.html#a0">hex_lookup</a>[ ( encode_c & 0x0F ) ]; <span class="comment">//Insert last hex part</span>00064 00065 <span class="keywordflow">if</span>( ii == 6 ) <span class="comment">//We have read a chunk of 7 chars, the next one will be discarded</span>00066 {00067 ii = 0;00068 i++;00069 (*discarded)++;00070 }00071 00072 <span class="keywordflow">else</span>00073 {00074 ii++;00075 }00076 }00077 00078 ret[iii] = <span class="charliteral">'\0'</span>;00079 00080 <span class="keywordflow">return</span> i;00081 }</div></pre> </td> </tr></table><a class="anchor" name="a4" doxytag="AVRGSM_zip.h::ZIP_decompress" ></a><p><table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> <tr> <td class="mdRow"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> int ZIP_decompress </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top">unsigned char * </td> <td class="mdname" nowrap> <em>compressed</em>, </td> </tr> <tr> <td class="md" nowrap align="right"></td> <td></td> <td class="md" nowrap>unsigned char * </td> <td class="mdname" nowrap> <em>decompressed</em></td> </tr> <tr> <td></td> <td class="md">) </td> <td class="md" colspan="2"></td> </tr> </table> </td> </tr></table><table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td><p>ZIP_decompress will decode a message in PDU format into a readable string. <p><dl compact><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td></td><td valign=top><em>*compressed</em> </td><td>PDU encoded text </td></tr> <tr><td></td><td valign=top><em>*decompressed</em> </td><td>Pointer to return array</td></tr> </table></dl><dl compact><dt><b>Return values:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td></td><td valign=top><em>iii</em> </td><td>Number of decoded chars</td></tr> </table></dl><p>Local variables <p>Definition at line <a class="el" href="AVRGSM__zip_8c-source.html#l00091">91</a> of file <a class="el" href="AVRGSM__zip_8c-source.html">AVRGSM_zip.c</a>.<p>References <a class="el" href="AVRGSM__zip_8c-source.html#l00027">mask</a>, and <a class="el" href="AVRGSM__zip_8c-source.html#l00164">ZIP_htoi()</a>.<p>Referenced by <a class="el" href="AVRGSM__api_8c-source.html#l00232">API_readmsg()</a>.<p><pre class="fragment"><div>00092 {00093 00095 <span class="keywordtype">int</span> i,ii,iii; <span class="comment">//String index</span>00096 <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> rest_c, ans_c ,dec_c , this_c, next_c; <span class="comment">//Read and temorary variables</span>00097 00098 <span class="keywordflow">for</span>( i = ii = iii = rest_c = 0; (this_c = compressed[i++]) != <span class="charliteral">'\0'</span>; ) <span class="comment">//Run through complete string</span>00099 {00100 <span class="comment">//Read:</span>00101 next_c = compressed[i++]; <span class="comment">//Read from in buffer in AVR_SMS_com.c</span>00102 00103 <span class="comment">//Convert:</span>00104 dec_c = 16 * <a class="code" href="AVRGSM__zip_8h.html#a6">ZIP_htoi</a>( this_c ) + <a class="code" href="AVRGSM__zip_8h.html#a6">ZIP_htoi</a>( next_c ); <span class="comment">//Decimal value of the two chars</span>00105 ans_c = dec_c & <a class="code" href="AVRGSM__zip_8c.html#a1">mask</a>[6 - ii]; <span class="comment">//Mask out the correct bits</span>00106 ans_c <<= ii; <span class="comment">//Left shift proper correct of times</span>00107 decompressed[iii++] = ans_c + rest_c; <span class="comment">//Store</span>00108 00109 rest_c = (dec_c & ~<a class="code" href="AVRGSM__zip_8c.html#a1">mask</a>[6 - ii]) >> ( 7 - ii ); <span class="comment">//Saving up for next time</span>00110 00111 <span class="keywordflow">if</span>( ii == 6) <span class="comment">//Do carry</span>00112 {00113 ii = 0;00114 decompressed[ iii++ ] = rest_c;00115 rest_c = 0;00116 }00117 00118 <span class="keywordflow">else</span>00119 {00120 ii++;00121 }00122 00123 }00124 00125 decompressed[ iii ] = <span class="charliteral">'\0'</span>; <span class="comment">//Terminate string in a proper manner</span>00126 <span class="keywordflow">return</span> iii; <span class="comment">//Return length</span>00127 }</div></pre><p>Here is the call graph for this function:<p><center><img src="AVRGSM__zip_8h_a4_cgraph.png" border="0" usemap="#AVRGSM__zip_8h_a4_cgraph_map" alt=""></center><map name="AVRGSM__zip_8h_a4_cgraph_map"><area href="AVRGSM__zip_8h.html#a6" shape="rect" coords="177,7,249,33" alt=""></map> </td> </tr></table><a class="anchor" name="a6" doxytag="AVRGSM_zip.h::ZIP_htoi" ></a><p><table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> <tr> <td class="mdRow"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> int ZIP_htoi </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top">unsigned char </td> <td class="mdname1" valign="top" nowrap> <em>hex</em> </td> <td class="md" valign="top"> ) </td> <td class="md" nowrap></td> </tr> </table> </td> </tr></table><table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td><p>Convert hex to int. <p>This function will take a hex in char format and return int value<p><dl compact><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td></td><td valign=top><em>hex</em> </td><td>Hex value to convert</td></tr> </table></dl><dl compact><dt><b>Return values:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td></td><td valign=top><em>int</em> </td><td>Integer representation of hex-value </td></tr> </table></dl><p>Definition at line <a class="el" href="AVRGSM__zip_8c-source.html#l00164">164</a> of file <a class="el" href="AVRGSM__zip_8c-source.html">AVRGSM_zip.c</a>.<p>Referenced by <a class="el" href="AVRGSM__tools_8c-source.html#l00080">TOOLS__decodeCMGR()</a>, and <a class="el" href="AVRGSM__zip_8c-source.html#l00091">ZIP_decompress()</a>.<p><pre class="fragment"><div>00165 {00166 00167 <span class="keywordflow">if</span>( ( hex >= <span class="charliteral">'A'</span> ) && ( hex <= <span class="charliteral">'F'</span> ) ) <span class="comment">//Test if hex is A-->F?</span>00168 {00169 <span class="keywordflow">return</span> hex - <span class="charliteral">'A'</span> + 10;00170 }00171 <span class="keywordflow">else</span> <span class="comment">//Must have something else then:0-->9</span>00172 {00173 <span class="keywordflow">return</span> hex - <span class="charliteral">'0'</span>;00174 }00175 }</div></pre> </td> </tr></table><a class="anchor" name="a7" doxytag="AVRGSM_zip.h::ZIP_itoh" ></a><p><table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> <tr> <td class="mdRow"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"> void ZIP_itoh </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top">int </td> <td class="mdname" nowrap> <em>n</em>, </td> </tr> <tr> <td class="md" nowrap align="right"></td> <td></td> <td class="md" nowrap>unsigned char * </td> <td class="mdname" nowrap> <em>ret</em></td> </tr> <tr> <td></td> <td class="md">) </td> <td class="md" colspan="2"></td> </tr> </table> </td> </tr></table><table cellspacing=5 cellpadding=0 border=0> <tr> <td> </td> <td><p>Converting int [0->255] to hex value. <p><dl compact><dt><b>Note:</b></dt><dd>Will return hex value as string.</dd></dl><dl compact><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td></td><td valign=top><em>n</em> </td><td>Integer value to be decoded. </td></tr> <tr><td></td><td valign=top><em>ret</em> </td><td>Return array. </td></tr> </table></dl><p>Definition at line <a class="el" href="AVRGSM__zip_8c-source.html#l00187">187</a> of file <a class="el" href="AVRGSM__zip_8c-source.html">AVRGSM_zip.c</a>.<p>References <a class="el" href="AVRGSM__zip_8c-source.html#l00026">hex_lookup</a>.<p>Referenced by <a class="el" href="AVRGSM__api_8c-source.html#l00160">API_sendmsg()</a>.<p><pre class="fragment"><div>00188 {00189 00190 ret[ 0 ] = <a class="code" href="AVRGSM__zip_8c.html#a0">hex_lookup</a>[ ( n >> 4 ) & 0x0F ];00191 ret[ 1 ] = <a class="code" href="AVRGSM__zip_8c.html#a0">hex_lookup</a>[ ( n & 0x0F ) ];00192 ret[ 2 ] = <span class="charliteral">'\0'</span>;00193 }</div></pre> </td> </tr></table><hr size="1"><address style="align: right;"><small>Generated on Tue Nov 1 16:21:41 2005 for AVR323 Interfacing GSM modems by<a href="http://www.doxygen.org/index.html"><img src="doxygen.png" alt="doxygen" align="middle" border=0 ></a> 1.3.7 </small></address></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -