39 <a name="l00018"></a>00018 { |
39 <a name="l00018"></a>00018 { |
40 <a name="l00019"></a>00019 <span class="keyword">public</span>: |
40 <a name="l00019"></a>00019 <span class="keyword">public</span>: |
41 <a name="l00020"></a><a class="code" href="classcan__uvccm__win32_1_1error.html">00020</a> <span class="keyword">class </span><a class="code" href="classcan__uvccm__win32_1_1error.html">error</a> |
41 <a name="l00020"></a><a class="code" href="classcan__uvccm__win32_1_1error.html">00020</a> <span class="keyword">class </span><a class="code" href="classcan__uvccm__win32_1_1error.html">error</a> |
42 <a name="l00021"></a>00021 { |
42 <a name="l00021"></a>00021 { |
43 <a name="l00022"></a>00022 }; |
43 <a name="l00022"></a>00022 }; |
44 <a name="l00023"></a>00023 <a class="code" href="classcan__uvccm__win32.html#f4f6d1f25174fd3b7d897a5f73bc363e">can_uvccm_win32</a>(<a class="code" href="structstruct__s__BOARD.html">s_BOARD</a> *board); |
44 <a name="l00023"></a>00023 <a class="code" href="classcan__uvccm__win32.html#44d72452ded768c3fff1addb9ea2dfdb">can_uvccm_win32</a>(<a class="code" href="structstruct__s__BOARD.html">s_BOARD</a> *board); |
45 <a name="l00024"></a>00024 <a class="code" href="classcan__uvccm__win32.html#39bb5c7bb141391d0f2f34b7dd5f487c">~can_uvccm_win32</a>(); |
45 <a name="l00024"></a>00024 <a class="code" href="classcan__uvccm__win32.html#ad2604fb37772689e837f1bbb396ee73">~can_uvccm_win32</a>(); |
46 <a name="l00025"></a>00025 <span class="keywordtype">bool</span> <a class="code" href="classcan__uvccm__win32.html#3358bfa32c0164bc11d220745e3e0430">send</a>(<span class="keyword">const</span> <a class="code" href="structMessage.html">Message</a> *m); |
46 <a name="l00025"></a>00025 <span class="keywordtype">bool</span> <a class="code" href="classcan__uvccm__win32.html#8cdbccec5f1cd2e26056d296c3087290">send</a>(<span class="keyword">const</span> <a class="code" href="structMessage.html">Message</a> *m); |
47 <a name="l00026"></a>00026 <span class="keywordtype">bool</span> <a class="code" href="classcan__uvccm__win32.html#4301393c1d3046b35d0b545e761b94db">receive</a>(<a class="code" href="structMessage.html">Message</a> *m); |
47 <a name="l00026"></a>00026 <span class="keywordtype">bool</span> <a class="code" href="classcan__uvccm__win32.html#a49341f3f4ae90cb45ba7eba2fa22682">receive</a>(<a class="code" href="structMessage.html">Message</a> *m); |
48 <a name="l00027"></a>00027 <span class="keyword">private</span>: |
48 <a name="l00027"></a>00027 <span class="keyword">private</span>: |
49 <a name="l00028"></a>00028 <span class="keywordtype">bool</span> <a class="code" href="classcan__uvccm__win32.html#7fb6732edc691451bc1d3206c07d4715">open_rs232</a>(<span class="keywordtype">int</span> port = 1, <span class="keywordtype">int</span> baud_rate = 57600); |
49 <a name="l00028"></a>00028 <span class="keywordtype">bool</span> <a class="code" href="classcan__uvccm__win32.html#b71c16fad5ab189cb3fabc09228dce61">open_rs232</a>(<span class="keywordtype">int</span> port = 1, <span class="keywordtype">int</span> baud_rate = 57600); |
50 <a name="l00029"></a>00029 <span class="keywordtype">bool</span> <a class="code" href="classcan__uvccm__win32.html#06f9d2fb860a821436471c3233f91dff">close_rs232</a>(); |
50 <a name="l00029"></a>00029 <span class="keywordtype">bool</span> <a class="code" href="classcan__uvccm__win32.html#90d854d7d320ba381ad2b86644f13080">close_rs232</a>(); |
51 <a name="l00030"></a>00030 <span class="keywordtype">bool</span> <a class="code" href="classcan__uvccm__win32.html#c3d1d02a46518b2639beb6060f79f2a2">get_can_data</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>* can_cmd_buf, <span class="keywordtype">long</span>& bufsize, <a class="code" href="structMessage.html">Message</a>* m); |
51 <a name="l00030"></a>00030 <span class="keywordtype">bool</span> <a class="code" href="classcan__uvccm__win32.html#9ffa5f900534ffc1bf5c80a0b29628a6">get_can_data</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>* can_cmd_buf, <span class="keywordtype">long</span>& bufsize, <a class="code" href="structMessage.html">Message</a>* m); |
52 <a name="l00031"></a>00031 <span class="keywordtype">bool</span> <a class="code" href="classcan__uvccm__win32.html#0f2aed9c45f29e6082f37ea17aea46ae">set_can_data</a>(<span class="keyword">const</span> <a class="code" href="structMessage.html">Message</a>& m, std::string& can_cmd); |
52 <a name="l00031"></a>00031 <span class="keywordtype">bool</span> <a class="code" href="classcan__uvccm__win32.html#dd49e9a91baf22fb46704dfdac74cb46">set_can_data</a>(<span class="keyword">const</span> <a class="code" href="structMessage.html">Message</a>& m, std::string& can_cmd); |
53 <a name="l00032"></a>00032 <span class="keyword">private</span>: |
53 <a name="l00032"></a>00032 <span class="keyword">private</span>: |
54 <a name="l00033"></a><a class="code" href="classcan__uvccm__win32.html#3f13c1748b3cd57fd1d478782428859a">00033</a> HANDLE <a class="code" href="classcan__uvccm__win32.html#3f13c1748b3cd57fd1d478782428859a">m_port</a>; |
54 <a name="l00033"></a><a class="code" href="classcan__uvccm__win32.html#16a0781c6112a96ba32e9c14124624a5">00033</a> HANDLE <a class="code" href="classcan__uvccm__win32.html#16a0781c6112a96ba32e9c14124624a5">m_port</a>; |
55 <a name="l00034"></a><a class="code" href="classcan__uvccm__win32.html#cf25e6725871137696ab41b06fa05417">00034</a> HANDLE <a class="code" href="classcan__uvccm__win32.html#cf25e6725871137696ab41b06fa05417">m_read_event</a>; |
55 <a name="l00034"></a><a class="code" href="classcan__uvccm__win32.html#85163a47e3246eba9a55ad63a34727e8">00034</a> HANDLE <a class="code" href="classcan__uvccm__win32.html#85163a47e3246eba9a55ad63a34727e8">m_read_event</a>; |
56 <a name="l00035"></a><a class="code" href="classcan__uvccm__win32.html#544ea7fd0e8a5d7cfb7cf9058d6020a4">00035</a> HANDLE <a class="code" href="classcan__uvccm__win32.html#544ea7fd0e8a5d7cfb7cf9058d6020a4">m_write_event</a>; |
56 <a name="l00035"></a><a class="code" href="classcan__uvccm__win32.html#c633c03ea1777d7ae38f23adae505ba5">00035</a> HANDLE <a class="code" href="classcan__uvccm__win32.html#c633c03ea1777d7ae38f23adae505ba5">m_write_event</a>; |
57 <a name="l00036"></a><a class="code" href="classcan__uvccm__win32.html#d264855657adc02fbc687f37d302fc9f">00036</a> std::string <a class="code" href="classcan__uvccm__win32.html#d264855657adc02fbc687f37d302fc9f">m_residual_buffer</a>; |
57 <a name="l00036"></a><a class="code" href="classcan__uvccm__win32.html#10bd44df6a991527816fc87547a266f5">00036</a> std::string <a class="code" href="classcan__uvccm__win32.html#10bd44df6a991527816fc87547a266f5">m_residual_buffer</a>; |
58 <a name="l00037"></a>00037 }; |
58 <a name="l00037"></a>00037 }; |
59 <a name="l00038"></a>00038 |
59 <a name="l00038"></a>00038 |
60 <a name="l00039"></a><a class="code" href="classcan__uvccm__win32.html#f4f6d1f25174fd3b7d897a5f73bc363e">00039</a> <a class="code" href="classcan__uvccm__win32.html#f4f6d1f25174fd3b7d897a5f73bc363e">can_uvccm_win32::can_uvccm_win32</a>(<a class="code" href="structstruct__s__BOARD.html">s_BOARD</a> *board) : m_port(INVALID_HANDLE_VALUE), |
60 <a name="l00039"></a><a class="code" href="classcan__uvccm__win32.html#44d72452ded768c3fff1addb9ea2dfdb">00039</a> <a class="code" href="classcan__uvccm__win32.html#44d72452ded768c3fff1addb9ea2dfdb">can_uvccm_win32::can_uvccm_win32</a>(<a class="code" href="structstruct__s__BOARD.html">s_BOARD</a> *board) : m_port(INVALID_HANDLE_VALUE), |
61 <a name="l00040"></a>00040 m_read_event(0), |
61 <a name="l00040"></a>00040 m_read_event(0), |
62 <a name="l00041"></a>00041 m_write_event(0) |
62 <a name="l00041"></a>00041 m_write_event(0) |
63 <a name="l00042"></a>00042 { |
63 <a name="l00042"></a>00042 { |
64 <a name="l00043"></a>00043 <span class="keywordflow">if</span> (strcmp( board-><a class="code" href="structstruct__s__BOARD.html#5316679ded23cf846c63c06ab51a4646">baudrate</a>, <span class="stringliteral">"125K"</span>) || !<a class="code" href="classcan__uvccm__win32.html#7fb6732edc691451bc1d3206c07d4715">open_rs232</a>(1)) |
64 <a name="l00043"></a>00043 <span class="keywordflow">if</span> (strcmp( board-><a class="code" href="structstruct__s__BOARD.html#8fa92cf9df3b66e547c079de89b00562">baudrate</a>, <span class="stringliteral">"125K"</span>) || !<a class="code" href="classcan__uvccm__win32.html#b71c16fad5ab189cb3fabc09228dce61">open_rs232</a>(1)) |
65 <a name="l00044"></a>00044 <span class="keywordflow">throw</span> <a class="code" href="classcan__uvccm__win32_1_1error.html">error</a>(); |
65 <a name="l00044"></a>00044 <span class="keywordflow">throw</span> <a class="code" href="classcan__uvccm__win32_1_1error.html">error</a>(); |
66 <a name="l00045"></a>00045 } |
66 <a name="l00045"></a>00045 } |
67 <a name="l00046"></a>00046 |
67 <a name="l00046"></a>00046 |
68 <a name="l00047"></a><a class="code" href="classcan__uvccm__win32.html#39bb5c7bb141391d0f2f34b7dd5f487c">00047</a> <a class="code" href="classcan__uvccm__win32.html#39bb5c7bb141391d0f2f34b7dd5f487c">can_uvccm_win32::~can_uvccm_win32</a>() |
68 <a name="l00047"></a><a class="code" href="classcan__uvccm__win32.html#ad2604fb37772689e837f1bbb396ee73">00047</a> <a class="code" href="classcan__uvccm__win32.html#ad2604fb37772689e837f1bbb396ee73">can_uvccm_win32::~can_uvccm_win32</a>() |
69 <a name="l00048"></a>00048 { |
69 <a name="l00048"></a>00048 { |
70 <a name="l00049"></a>00049 <a class="code" href="classcan__uvccm__win32.html#06f9d2fb860a821436471c3233f91dff">close_rs232</a>(); |
70 <a name="l00049"></a>00049 <a class="code" href="classcan__uvccm__win32.html#90d854d7d320ba381ad2b86644f13080">close_rs232</a>(); |
71 <a name="l00050"></a>00050 } |
71 <a name="l00050"></a>00050 } |
72 <a name="l00051"></a>00051 |
72 <a name="l00051"></a>00051 |
73 <a name="l00052"></a><a class="code" href="classcan__uvccm__win32.html#3358bfa32c0164bc11d220745e3e0430">00052</a> <span class="keywordtype">bool</span> <a class="code" href="classcan__uvccm__win32.html#3358bfa32c0164bc11d220745e3e0430">can_uvccm_win32::send</a>(<span class="keyword">const</span> <a class="code" href="structMessage.html">Message</a> *m) |
73 <a name="l00052"></a><a class="code" href="classcan__uvccm__win32.html#8cdbccec5f1cd2e26056d296c3087290">00052</a> <span class="keywordtype">bool</span> <a class="code" href="classcan__uvccm__win32.html#8cdbccec5f1cd2e26056d296c3087290">can_uvccm_win32::send</a>(<span class="keyword">const</span> <a class="code" href="structMessage.html">Message</a> *m) |
74 <a name="l00053"></a>00053 { |
74 <a name="l00053"></a>00053 { |
75 <a name="l00054"></a>00054 <span class="keywordflow">if</span> (<a class="code" href="classcan__uvccm__win32.html#3f13c1748b3cd57fd1d478782428859a">m_port</a> == INVALID_HANDLE_VALUE) |
75 <a name="l00054"></a>00054 <span class="keywordflow">if</span> (<a class="code" href="classcan__uvccm__win32.html#16a0781c6112a96ba32e9c14124624a5">m_port</a> == INVALID_HANDLE_VALUE) |
76 <a name="l00055"></a>00055 <span class="keywordflow">return</span> <span class="keyword">false</span>; |
76 <a name="l00055"></a>00055 <span class="keywordflow">return</span> <span class="keyword">false</span>; |
77 <a name="l00056"></a>00056 |
77 <a name="l00056"></a>00056 |
78 <a name="l00057"></a>00057 <span class="comment">// build can_uvccm_win32 command string</span> |
78 <a name="l00057"></a>00057 <span class="comment">// build can_uvccm_win32 command string</span> |
79 <a name="l00058"></a>00058 std::string can_cmd; |
79 <a name="l00058"></a>00058 std::string can_cmd; |
80 <a name="l00059"></a>00059 <a class="code" href="classcan__uvccm__win32.html#0f2aed9c45f29e6082f37ea17aea46ae">set_can_data</a>(*m, can_cmd); |
80 <a name="l00059"></a>00059 <a class="code" href="classcan__uvccm__win32.html#dd49e9a91baf22fb46704dfdac74cb46">set_can_data</a>(*m, can_cmd); |
81 <a name="l00060"></a>00060 |
81 <a name="l00060"></a>00060 |
82 <a name="l00061"></a>00061 OVERLAPPED overlapped; |
82 <a name="l00061"></a>00061 OVERLAPPED overlapped; |
83 <a name="l00062"></a>00062 ::memset(&overlapped, 0, <span class="keyword">sizeof</span> overlapped); |
83 <a name="l00062"></a>00062 ::memset(&overlapped, 0, <span class="keyword">sizeof</span> overlapped); |
84 <a name="l00063"></a>00063 overlapped.hEvent = <a class="code" href="classcan__uvccm__win32.html#544ea7fd0e8a5d7cfb7cf9058d6020a4">m_write_event</a>; |
84 <a name="l00063"></a>00063 overlapped.hEvent = <a class="code" href="classcan__uvccm__win32.html#c633c03ea1777d7ae38f23adae505ba5">m_write_event</a>; |
85 <a name="l00064"></a>00064 ::ResetEvent(overlapped.hEvent); |
85 <a name="l00064"></a>00064 ::ResetEvent(overlapped.hEvent); |
86 <a name="l00065"></a>00065 |
86 <a name="l00065"></a>00065 |
87 <a name="l00066"></a>00066 <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> bytes_written = 0; |
87 <a name="l00066"></a>00066 <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> bytes_written = 0; |
88 <a name="l00067"></a>00067 ::WriteFile(<a class="code" href="classcan__uvccm__win32.html#3f13c1748b3cd57fd1d478782428859a">m_port</a>, can_cmd.c_str(), (<span class="keywordtype">unsigned</span> long)can_cmd.size(), &bytes_written, &overlapped); |
88 <a name="l00067"></a>00067 ::WriteFile(<a class="code" href="classcan__uvccm__win32.html#16a0781c6112a96ba32e9c14124624a5">m_port</a>, can_cmd.c_str(), (<span class="keywordtype">unsigned</span> long)can_cmd.size(), &bytes_written, &overlapped); |
89 <a name="l00068"></a>00068 <span class="comment">// wait for write operation completion</span> |
89 <a name="l00068"></a>00068 <span class="comment">// wait for write operation completion</span> |
90 <a name="l00069"></a>00069 <span class="keyword">enum</span> { WRITE_TIMEOUT = 1000 }; |
90 <a name="l00069"></a>00069 <span class="keyword">enum</span> { WRITE_TIMEOUT = 1000 }; |
91 <a name="l00070"></a>00070 ::WaitForSingleObject(overlapped.hEvent, WRITE_TIMEOUT); |
91 <a name="l00070"></a>00070 ::WaitForSingleObject(overlapped.hEvent, WRITE_TIMEOUT); |
92 <a name="l00071"></a>00071 <span class="comment">// get number of bytes written</span> |
92 <a name="l00071"></a>00071 <span class="comment">// get number of bytes written</span> |
93 <a name="l00072"></a>00072 ::GetOverlappedResult(<a class="code" href="classcan__uvccm__win32.html#3f13c1748b3cd57fd1d478782428859a">m_port</a>, &overlapped, &bytes_written, <a class="code" href="def_8h.html#a93f0eb578d23995850d61f7d61c55c1">FALSE</a>); |
93 <a name="l00072"></a>00072 ::GetOverlappedResult(<a class="code" href="classcan__uvccm__win32.html#16a0781c6112a96ba32e9c14124624a5">m_port</a>, &overlapped, &bytes_written, <a class="code" href="def_8h.html#b5b5527380b5b259294fa10ae7e3a59b">FALSE</a>); |
94 <a name="l00073"></a>00073 |
94 <a name="l00073"></a>00073 |
95 <a name="l00074"></a>00074 <span class="keywordtype">bool</span> result = (bytes_written == can_cmd.size()); |
95 <a name="l00074"></a>00074 <span class="keywordtype">bool</span> result = (bytes_written == can_cmd.size()); |
96 <a name="l00075"></a>00075 |
96 <a name="l00075"></a>00075 |
97 <a name="l00076"></a>00076 <span class="keywordflow">return</span> result; |
97 <a name="l00076"></a>00076 <span class="keywordflow">return</span> result; |
98 <a name="l00077"></a>00077 } |
98 <a name="l00077"></a>00077 } |
99 <a name="l00078"></a>00078 |
99 <a name="l00078"></a>00078 |
100 <a name="l00079"></a>00079 |
100 <a name="l00079"></a>00079 |
101 <a name="l00080"></a><a class="code" href="classcan__uvccm__win32.html#4301393c1d3046b35d0b545e761b94db">00080</a> <span class="keywordtype">bool</span> <a class="code" href="classcan__uvccm__win32.html#4301393c1d3046b35d0b545e761b94db">can_uvccm_win32::receive</a>(<a class="code" href="structMessage.html">Message</a> *m) |
101 <a name="l00080"></a><a class="code" href="classcan__uvccm__win32.html#a49341f3f4ae90cb45ba7eba2fa22682">00080</a> <span class="keywordtype">bool</span> <a class="code" href="classcan__uvccm__win32.html#a49341f3f4ae90cb45ba7eba2fa22682">can_uvccm_win32::receive</a>(<a class="code" href="structMessage.html">Message</a> *m) |
102 <a name="l00081"></a>00081 { |
102 <a name="l00081"></a>00081 { |
103 <a name="l00082"></a>00082 <span class="keywordflow">if</span> (<a class="code" href="classcan__uvccm__win32.html#3f13c1748b3cd57fd1d478782428859a">m_port</a> == INVALID_HANDLE_VALUE) |
103 <a name="l00082"></a>00082 <span class="keywordflow">if</span> (<a class="code" href="classcan__uvccm__win32.html#16a0781c6112a96ba32e9c14124624a5">m_port</a> == INVALID_HANDLE_VALUE) |
104 <a name="l00083"></a>00083 <span class="keywordflow">return</span> <span class="keyword">false</span>; |
104 <a name="l00083"></a>00083 <span class="keywordflow">return</span> <span class="keyword">false</span>; |
105 <a name="l00084"></a>00084 |
105 <a name="l00084"></a>00084 |
106 <a name="l00085"></a>00085 <span class="keywordtype">long</span> res_buffer_size = (long)<a class="code" href="classcan__uvccm__win32.html#d264855657adc02fbc687f37d302fc9f">m_residual_buffer</a>.size(); |
106 <a name="l00085"></a>00085 <span class="keywordtype">long</span> res_buffer_size = (long)<a class="code" href="classcan__uvccm__win32.html#10bd44df6a991527816fc87547a266f5">m_residual_buffer</a>.size(); |
107 <a name="l00086"></a>00086 <span class="keywordtype">bool</span> result = <a class="code" href="classcan__uvccm__win32.html#c3d1d02a46518b2639beb6060f79f2a2">get_can_data</a>(<a class="code" href="classcan__uvccm__win32.html#d264855657adc02fbc687f37d302fc9f">m_residual_buffer</a>.c_str(), res_buffer_size, m); |
107 <a name="l00086"></a>00086 <span class="keywordtype">bool</span> result = <a class="code" href="classcan__uvccm__win32.html#9ffa5f900534ffc1bf5c80a0b29628a6">get_can_data</a>(<a class="code" href="classcan__uvccm__win32.html#10bd44df6a991527816fc87547a266f5">m_residual_buffer</a>.c_str(), res_buffer_size, m); |
108 <a name="l00087"></a>00087 <span class="keywordflow">if</span> (result) |
108 <a name="l00087"></a>00087 <span class="keywordflow">if</span> (result) |
109 <a name="l00088"></a>00088 { |
109 <a name="l00088"></a>00088 { |
110 <a name="l00089"></a>00089 <a class="code" href="classcan__uvccm__win32.html#d264855657adc02fbc687f37d302fc9f">m_residual_buffer</a>.erase(0, res_buffer_size); |
110 <a name="l00089"></a>00089 <a class="code" href="classcan__uvccm__win32.html#10bd44df6a991527816fc87547a266f5">m_residual_buffer</a>.erase(0, res_buffer_size); |
111 <a name="l00090"></a>00090 <span class="keywordflow">return</span> <span class="keyword">true</span>; |
111 <a name="l00090"></a>00090 <span class="keywordflow">return</span> <span class="keyword">true</span>; |
112 <a name="l00091"></a>00091 } |
112 <a name="l00091"></a>00091 } |
113 <a name="l00092"></a>00092 |
113 <a name="l00092"></a>00092 |
114 <a name="l00093"></a>00093 <span class="keyword">enum</span> { READ_TIMEOUT = 500 }; |
114 <a name="l00093"></a>00093 <span class="keyword">enum</span> { READ_TIMEOUT = 500 }; |
115 <a name="l00094"></a>00094 |
115 <a name="l00094"></a>00094 |
116 <a name="l00095"></a>00095 OVERLAPPED overlapped; |
116 <a name="l00095"></a>00095 OVERLAPPED overlapped; |
117 <a name="l00096"></a>00096 ::memset(&overlapped, 0, <span class="keyword">sizeof</span> overlapped); |
117 <a name="l00096"></a>00096 ::memset(&overlapped, 0, <span class="keyword">sizeof</span> overlapped); |
118 <a name="l00097"></a>00097 overlapped.hEvent = <a class="code" href="classcan__uvccm__win32.html#cf25e6725871137696ab41b06fa05417">m_read_event</a>; |
118 <a name="l00097"></a>00097 overlapped.hEvent = <a class="code" href="classcan__uvccm__win32.html#85163a47e3246eba9a55ad63a34727e8">m_read_event</a>; |
119 <a name="l00098"></a>00098 ::ResetEvent(overlapped.hEvent); |
119 <a name="l00098"></a>00098 ::ResetEvent(overlapped.hEvent); |
120 <a name="l00099"></a>00099 <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> event_mask = 0; |
120 <a name="l00099"></a>00099 <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> event_mask = 0; |
121 <a name="l00100"></a>00100 |
121 <a name="l00100"></a>00100 |
122 <a name="l00101"></a>00101 <span class="keywordflow">if</span> (<a class="code" href="def_8h.html#a93f0eb578d23995850d61f7d61c55c1">FALSE</a> == ::WaitCommEvent(<a class="code" href="classcan__uvccm__win32.html#3f13c1748b3cd57fd1d478782428859a">m_port</a>, &event_mask, &overlapped) && ERROR_IO_PENDING == ::GetLastError()) |
122 <a name="l00101"></a>00101 <span class="keywordflow">if</span> (<a class="code" href="def_8h.html#b5b5527380b5b259294fa10ae7e3a59b">FALSE</a> == ::WaitCommEvent(<a class="code" href="classcan__uvccm__win32.html#16a0781c6112a96ba32e9c14124624a5">m_port</a>, &event_mask, &overlapped) && ERROR_IO_PENDING == ::GetLastError()) |
123 <a name="l00102"></a>00102 { |
123 <a name="l00102"></a>00102 { |
124 <a name="l00103"></a>00103 <span class="keywordflow">if</span> (WAIT_TIMEOUT == ::WaitForSingleObject(overlapped.hEvent, READ_TIMEOUT)) |
124 <a name="l00103"></a>00103 <span class="keywordflow">if</span> (WAIT_TIMEOUT == ::WaitForSingleObject(overlapped.hEvent, READ_TIMEOUT)) |
125 <a name="l00104"></a>00104 <span class="keywordflow">return</span> <span class="keyword">false</span>; |
125 <a name="l00104"></a>00104 <span class="keywordflow">return</span> <span class="keyword">false</span>; |
126 <a name="l00105"></a>00105 } |
126 <a name="l00105"></a>00105 } |
127 <a name="l00106"></a>00106 |
127 <a name="l00106"></a>00106 |
128 <a name="l00107"></a>00107 <span class="comment">// get number of bytes in the input que</span> |
128 <a name="l00107"></a>00107 <span class="comment">// get number of bytes in the input que</span> |
129 <a name="l00108"></a>00108 COMSTAT stat; |
129 <a name="l00108"></a>00108 COMSTAT stat; |
130 <a name="l00109"></a>00109 ::memset(&stat, 0, <span class="keyword">sizeof</span> stat); |
130 <a name="l00109"></a>00109 ::memset(&stat, 0, <span class="keyword">sizeof</span> stat); |
131 <a name="l00110"></a>00110 <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> errors = 0; |
131 <a name="l00110"></a>00110 <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> errors = 0; |
132 <a name="l00111"></a>00111 ::ClearCommError(<a class="code" href="classcan__uvccm__win32.html#3f13c1748b3cd57fd1d478782428859a">m_port</a>, &errors, &stat); |
132 <a name="l00111"></a>00111 ::ClearCommError(<a class="code" href="classcan__uvccm__win32.html#16a0781c6112a96ba32e9c14124624a5">m_port</a>, &errors, &stat); |
133 <a name="l00112"></a>00112 <span class="keywordflow">if</span> (stat.cbInQue == 0) |
133 <a name="l00112"></a>00112 <span class="keywordflow">if</span> (stat.cbInQue == 0) |
134 <a name="l00113"></a>00113 <span class="keywordflow">return</span> <span class="keyword">false</span>; |
134 <a name="l00113"></a>00113 <span class="keywordflow">return</span> <span class="keyword">false</span>; |
135 <a name="l00114"></a>00114 <span class="keywordtype">char</span> buffer[3000]; |
135 <a name="l00114"></a>00114 <span class="keywordtype">char</span> buffer[3000]; |
136 <a name="l00115"></a>00115 |
136 <a name="l00115"></a>00115 |
137 <a name="l00116"></a>00116 <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> bytes_to_read = min(stat.cbInQue, sizeof (buffer)); |
137 <a name="l00116"></a>00116 <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> bytes_to_read = min(stat.cbInQue, sizeof (buffer)); |
138 <a name="l00117"></a>00117 |
138 <a name="l00117"></a>00117 |
139 <a name="l00118"></a>00118 <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> bytes_read = 0; |
139 <a name="l00118"></a>00118 <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> bytes_read = 0; |
140 <a name="l00119"></a>00119 ::ReadFile(<a class="code" href="classcan__uvccm__win32.html#3f13c1748b3cd57fd1d478782428859a">m_port</a>, buffer, bytes_to_read, &bytes_read, &overlapped); |
140 <a name="l00119"></a>00119 ::ReadFile(<a class="code" href="classcan__uvccm__win32.html#16a0781c6112a96ba32e9c14124624a5">m_port</a>, buffer, bytes_to_read, &bytes_read, &overlapped); |
141 <a name="l00120"></a>00120 <span class="comment">// wait for read operation completion</span> |
141 <a name="l00120"></a>00120 <span class="comment">// wait for read operation completion</span> |
142 <a name="l00121"></a>00121 ::WaitForSingleObject(overlapped.hEvent, READ_TIMEOUT); |
142 <a name="l00121"></a>00121 ::WaitForSingleObject(overlapped.hEvent, READ_TIMEOUT); |
143 <a name="l00122"></a>00122 <span class="comment">// get number of bytes read</span> |
143 <a name="l00122"></a>00122 <span class="comment">// get number of bytes read</span> |
144 <a name="l00123"></a>00123 ::GetOverlappedResult(<a class="code" href="classcan__uvccm__win32.html#3f13c1748b3cd57fd1d478782428859a">m_port</a>, &overlapped, &bytes_read, <a class="code" href="def_8h.html#a93f0eb578d23995850d61f7d61c55c1">FALSE</a>); |
144 <a name="l00123"></a>00123 ::GetOverlappedResult(<a class="code" href="classcan__uvccm__win32.html#16a0781c6112a96ba32e9c14124624a5">m_port</a>, &overlapped, &bytes_read, <a class="code" href="def_8h.html#b5b5527380b5b259294fa10ae7e3a59b">FALSE</a>); |
145 <a name="l00124"></a>00124 result = <span class="keyword">false</span>; |
145 <a name="l00124"></a>00124 result = <span class="keyword">false</span>; |
146 <a name="l00125"></a>00125 <span class="keywordflow">if</span> (bytes_read > 0) |
146 <a name="l00125"></a>00125 <span class="keywordflow">if</span> (bytes_read > 0) |
147 <a name="l00126"></a>00126 { |
147 <a name="l00126"></a>00126 { |
148 <a name="l00127"></a>00127 <a class="code" href="classcan__uvccm__win32.html#d264855657adc02fbc687f37d302fc9f">m_residual_buffer</a>.append(buffer, bytes_read); |
148 <a name="l00127"></a>00127 <a class="code" href="classcan__uvccm__win32.html#10bd44df6a991527816fc87547a266f5">m_residual_buffer</a>.append(buffer, bytes_read); |
149 <a name="l00128"></a>00128 res_buffer_size = (long)<a class="code" href="classcan__uvccm__win32.html#d264855657adc02fbc687f37d302fc9f">m_residual_buffer</a>.size(); |
149 <a name="l00128"></a>00128 res_buffer_size = (long)<a class="code" href="classcan__uvccm__win32.html#10bd44df6a991527816fc87547a266f5">m_residual_buffer</a>.size(); |
150 <a name="l00129"></a>00129 result = <a class="code" href="classcan__uvccm__win32.html#c3d1d02a46518b2639beb6060f79f2a2">get_can_data</a>(<a class="code" href="classcan__uvccm__win32.html#d264855657adc02fbc687f37d302fc9f">m_residual_buffer</a>.c_str(), res_buffer_size, m); |
150 <a name="l00129"></a>00129 result = <a class="code" href="classcan__uvccm__win32.html#9ffa5f900534ffc1bf5c80a0b29628a6">get_can_data</a>(<a class="code" href="classcan__uvccm__win32.html#10bd44df6a991527816fc87547a266f5">m_residual_buffer</a>.c_str(), res_buffer_size, m); |
151 <a name="l00130"></a>00130 <span class="keywordflow">if</span> (result) |
151 <a name="l00130"></a>00130 <span class="keywordflow">if</span> (result) |
152 <a name="l00131"></a>00131 <a class="code" href="classcan__uvccm__win32.html#d264855657adc02fbc687f37d302fc9f">m_residual_buffer</a>.erase(0, res_buffer_size); |
152 <a name="l00131"></a>00131 <a class="code" href="classcan__uvccm__win32.html#10bd44df6a991527816fc87547a266f5">m_residual_buffer</a>.erase(0, res_buffer_size); |
153 <a name="l00132"></a>00132 } |
153 <a name="l00132"></a>00132 } |
154 <a name="l00133"></a>00133 <span class="keywordflow">return</span> result; |
154 <a name="l00133"></a>00133 <span class="keywordflow">return</span> result; |
155 <a name="l00134"></a>00134 } |
155 <a name="l00134"></a>00134 } |
156 <a name="l00135"></a>00135 |
156 <a name="l00135"></a>00135 |
157 <a name="l00136"></a><a class="code" href="classcan__uvccm__win32.html#7fb6732edc691451bc1d3206c07d4715">00136</a> <span class="keywordtype">bool</span> <a class="code" href="classcan__uvccm__win32.html#7fb6732edc691451bc1d3206c07d4715">can_uvccm_win32::open_rs232</a>(<span class="keywordtype">int</span> port, <span class="keywordtype">int</span> baud_rate) |
157 <a name="l00136"></a><a class="code" href="classcan__uvccm__win32.html#b71c16fad5ab189cb3fabc09228dce61">00136</a> <span class="keywordtype">bool</span> <a class="code" href="classcan__uvccm__win32.html#b71c16fad5ab189cb3fabc09228dce61">can_uvccm_win32::open_rs232</a>(<span class="keywordtype">int</span> port, <span class="keywordtype">int</span> baud_rate) |
158 <a name="l00137"></a>00137 { |
158 <a name="l00137"></a>00137 { |
159 <a name="l00138"></a>00138 <span class="keywordflow">if</span> (<a class="code" href="classcan__uvccm__win32.html#3f13c1748b3cd57fd1d478782428859a">m_port</a> != INVALID_HANDLE_VALUE) |
159 <a name="l00138"></a>00138 <span class="keywordflow">if</span> (<a class="code" href="classcan__uvccm__win32.html#16a0781c6112a96ba32e9c14124624a5">m_port</a> != INVALID_HANDLE_VALUE) |
160 <a name="l00139"></a>00139 <span class="keywordflow">return</span> <span class="keyword">true</span>; |
160 <a name="l00139"></a>00139 <span class="keywordflow">return</span> <span class="keyword">true</span>; |
161 <a name="l00140"></a>00140 |
161 <a name="l00140"></a>00140 |
162 <a name="l00141"></a>00141 std::ostringstream device_name; |
162 <a name="l00141"></a>00141 std::ostringstream device_name; |
163 <a name="l00142"></a>00142 device_name << <span class="stringliteral">"COM"</span> << port; |
163 <a name="l00142"></a>00142 device_name << <span class="stringliteral">"COM"</span> << port; |
164 <a name="l00143"></a>00143 |
164 <a name="l00143"></a>00143 |
165 <a name="l00144"></a>00144 <a class="code" href="classcan__uvccm__win32.html#3f13c1748b3cd57fd1d478782428859a">m_port</a> = ::CreateFile(device_name.str().c_str(), |
165 <a name="l00144"></a>00144 <a class="code" href="classcan__uvccm__win32.html#16a0781c6112a96ba32e9c14124624a5">m_port</a> = ::CreateFile(device_name.str().c_str(), |
166 <a name="l00145"></a>00145 GENERIC_READ | GENERIC_WRITE, |
166 <a name="l00145"></a>00145 GENERIC_READ | GENERIC_WRITE, |
167 <a name="l00146"></a>00146 0, <span class="comment">// exclusive access</span> |
167 <a name="l00146"></a>00146 0, <span class="comment">// exclusive access</span> |
168 <a name="l00147"></a>00147 NULL, <span class="comment">// no security</span> |
168 <a name="l00147"></a>00147 NULL, <span class="comment">// no security</span> |
169 <a name="l00148"></a>00148 OPEN_EXISTING, |
169 <a name="l00148"></a>00148 OPEN_EXISTING, |
170 <a name="l00149"></a>00149 FILE_FLAG_OVERLAPPED, <span class="comment">// overlapped I/O</span> |
170 <a name="l00149"></a>00149 FILE_FLAG_OVERLAPPED, <span class="comment">// overlapped I/O</span> |
171 <a name="l00150"></a>00150 NULL); <span class="comment">// null template</span> |
171 <a name="l00150"></a>00150 NULL); <span class="comment">// null template</span> |
172 <a name="l00151"></a>00151 |
172 <a name="l00151"></a>00151 |
173 <a name="l00152"></a>00152 <span class="comment">// Check the returned handle for INVALID_HANDLE_VALUE and then set the buffer sizes.</span> |
173 <a name="l00152"></a>00152 <span class="comment">// Check the returned handle for INVALID_HANDLE_VALUE and then set the buffer sizes.</span> |
174 <a name="l00153"></a>00153 <span class="keywordflow">if</span> (<a class="code" href="classcan__uvccm__win32.html#3f13c1748b3cd57fd1d478782428859a">m_port</a> == INVALID_HANDLE_VALUE) |
174 <a name="l00153"></a>00153 <span class="keywordflow">if</span> (<a class="code" href="classcan__uvccm__win32.html#16a0781c6112a96ba32e9c14124624a5">m_port</a> == INVALID_HANDLE_VALUE) |
175 <a name="l00154"></a>00154 <span class="keywordflow">return</span> <span class="keyword">false</span>; |
175 <a name="l00154"></a>00154 <span class="keywordflow">return</span> <span class="keyword">false</span>; |
176 <a name="l00155"></a>00155 |
176 <a name="l00155"></a>00155 |
177 <a name="l00156"></a>00156 <span class="comment">// SetCommMask(m_hCom,EV_RXCHAR|EV_TXEMPTY|EV_CTS|EV_DSR|EV_RLSD|EV_BREAK|EV_ERR|EV_RING); //</span> |
177 <a name="l00156"></a>00156 <span class="comment">// SetCommMask(m_hCom,EV_RXCHAR|EV_TXEMPTY|EV_CTS|EV_DSR|EV_RLSD|EV_BREAK|EV_ERR|EV_RING); //</span> |
178 <a name="l00157"></a>00157 ::SetCommMask(<a class="code" href="classcan__uvccm__win32.html#3f13c1748b3cd57fd1d478782428859a">m_port</a>, EV_RXFLAG); |
178 <a name="l00157"></a>00157 ::SetCommMask(<a class="code" href="classcan__uvccm__win32.html#16a0781c6112a96ba32e9c14124624a5">m_port</a>, EV_RXFLAG); |
179 <a name="l00158"></a>00158 |
179 <a name="l00158"></a>00158 |
180 <a name="l00159"></a>00159 COMMTIMEOUTS timeouts; |
180 <a name="l00159"></a>00159 COMMTIMEOUTS timeouts; |
181 <a name="l00160"></a>00160 ::memset(&timeouts, 0, <span class="keyword">sizeof</span> (timeouts)); |
181 <a name="l00160"></a>00160 ::memset(&timeouts, 0, <span class="keyword">sizeof</span> (timeouts)); |
182 <a name="l00161"></a>00161 timeouts.ReadIntervalTimeout = -1; |
182 <a name="l00161"></a>00161 timeouts.ReadIntervalTimeout = -1; |
183 <a name="l00162"></a>00162 timeouts.ReadTotalTimeoutConstant = 0; |
183 <a name="l00162"></a>00162 timeouts.ReadTotalTimeoutConstant = 0; |
184 <a name="l00163"></a>00163 timeouts.ReadTotalTimeoutMultiplier = 0; |
184 <a name="l00163"></a>00163 timeouts.ReadTotalTimeoutMultiplier = 0; |
185 <a name="l00164"></a>00164 timeouts.WriteTotalTimeoutConstant = 5000; |
185 <a name="l00164"></a>00164 timeouts.WriteTotalTimeoutConstant = 5000; |
186 <a name="l00165"></a>00165 timeouts.WriteTotalTimeoutMultiplier = 0; |
186 <a name="l00165"></a>00165 timeouts.WriteTotalTimeoutMultiplier = 0; |
187 <a name="l00166"></a>00166 SetCommTimeouts(<a class="code" href="classcan__uvccm__win32.html#3f13c1748b3cd57fd1d478782428859a">m_port</a>, &timeouts); <span class="comment">//</span> |
187 <a name="l00166"></a>00166 SetCommTimeouts(<a class="code" href="classcan__uvccm__win32.html#16a0781c6112a96ba32e9c14124624a5">m_port</a>, &timeouts); <span class="comment">//</span> |
188 <a name="l00167"></a>00167 |
188 <a name="l00167"></a>00167 |
189 <a name="l00168"></a>00168 ::SetupComm(<a class="code" href="classcan__uvccm__win32.html#3f13c1748b3cd57fd1d478782428859a">m_port</a>, 1024, 512); <span class="comment">// set buffer sizes</span> |
189 <a name="l00168"></a>00168 ::SetupComm(<a class="code" href="classcan__uvccm__win32.html#16a0781c6112a96ba32e9c14124624a5">m_port</a>, 1024, 512); <span class="comment">// set buffer sizes</span> |
190 <a name="l00169"></a>00169 |
190 <a name="l00169"></a>00169 |
191 <a name="l00170"></a>00170 <span class="comment">// Port settings are specified in a Data Communication Block (DCB). The easiest way to initialize a DCB is to call GetCommState to fill in its default values, override the values that you want to change and then call SetCommState to set the values.</span> |
191 <a name="l00170"></a>00170 <span class="comment">// Port settings are specified in a Data Communication Block (DCB). The easiest way to initialize a DCB is to call GetCommState to fill in its default values, override the values that you want to change and then call SetCommState to set the values.</span> |
192 <a name="l00171"></a>00171 DCB dcb; |
192 <a name="l00171"></a>00171 DCB dcb; |
193 <a name="l00172"></a>00172 ::memset(&dcb, 0, <span class="keyword">sizeof</span> (dcb)); |
193 <a name="l00172"></a>00172 ::memset(&dcb, 0, <span class="keyword">sizeof</span> (dcb)); |
194 <a name="l00173"></a>00173 ::GetCommState(<a class="code" href="classcan__uvccm__win32.html#3f13c1748b3cd57fd1d478782428859a">m_port</a>, &dcb); |
194 <a name="l00173"></a>00173 ::GetCommState(<a class="code" href="classcan__uvccm__win32.html#16a0781c6112a96ba32e9c14124624a5">m_port</a>, &dcb); |
195 <a name="l00174"></a>00174 dcb.BaudRate = baud_rate; |
195 <a name="l00174"></a>00174 dcb.BaudRate = baud_rate; |
196 <a name="l00175"></a>00175 dcb.ByteSize = 8; |
196 <a name="l00175"></a>00175 dcb.ByteSize = 8; |
197 <a name="l00176"></a>00176 dcb.Parity = NOPARITY; |
197 <a name="l00176"></a>00176 dcb.Parity = NOPARITY; |
198 <a name="l00177"></a>00177 dcb.StopBits = ONESTOPBIT; |
198 <a name="l00177"></a>00177 dcb.StopBits = ONESTOPBIT; |
199 <a name="l00178"></a>00178 dcb.fAbortOnError = <a class="code" href="def_8h.html#a8cecfc5c5c054d2875c03e77b7be15d">TRUE</a>; |
199 <a name="l00178"></a>00178 dcb.fAbortOnError = <a class="code" href="def_8h.html#528a67cfb212764fdec08c7c065a04f8">TRUE</a>; |
200 <a name="l00179"></a>00179 dcb.EvtChar = 0x0A; <span class="comment">// '\n' character</span> |
200 <a name="l00179"></a>00179 dcb.EvtChar = 0x0A; <span class="comment">// '\n' character</span> |
201 <a name="l00180"></a>00180 ::SetCommState(<a class="code" href="classcan__uvccm__win32.html#3f13c1748b3cd57fd1d478782428859a">m_port</a>, &dcb); |
201 <a name="l00180"></a>00180 ::SetCommState(<a class="code" href="classcan__uvccm__win32.html#16a0781c6112a96ba32e9c14124624a5">m_port</a>, &dcb); |
202 <a name="l00181"></a>00181 |
202 <a name="l00181"></a>00181 |
203 <a name="l00182"></a>00182 ::PurgeComm(<a class="code" href="classcan__uvccm__win32.html#3f13c1748b3cd57fd1d478782428859a">m_port</a>, PURGE_RXABORT | PURGE_RXCLEAR | PURGE_TXABORT | PURGE_TXCLEAR); |
203 <a name="l00182"></a>00182 ::PurgeComm(<a class="code" href="classcan__uvccm__win32.html#16a0781c6112a96ba32e9c14124624a5">m_port</a>, PURGE_RXABORT | PURGE_RXCLEAR | PURGE_TXABORT | PURGE_TXCLEAR); |
204 <a name="l00183"></a>00183 |
204 <a name="l00183"></a>00183 |
205 <a name="l00184"></a>00184 <a class="code" href="classcan__uvccm__win32.html#cf25e6725871137696ab41b06fa05417">m_read_event</a> = ::CreateEvent(NULL, <a class="code" href="def_8h.html#a8cecfc5c5c054d2875c03e77b7be15d">TRUE</a>, <a class="code" href="def_8h.html#a93f0eb578d23995850d61f7d61c55c1">FALSE</a>, NULL); |
205 <a name="l00184"></a>00184 <a class="code" href="classcan__uvccm__win32.html#85163a47e3246eba9a55ad63a34727e8">m_read_event</a> = ::CreateEvent(NULL, <a class="code" href="def_8h.html#528a67cfb212764fdec08c7c065a04f8">TRUE</a>, <a class="code" href="def_8h.html#b5b5527380b5b259294fa10ae7e3a59b">FALSE</a>, NULL); |
206 <a name="l00185"></a>00185 <a class="code" href="classcan__uvccm__win32.html#544ea7fd0e8a5d7cfb7cf9058d6020a4">m_write_event</a> = ::CreateEvent(NULL, TRUE, FALSE, NULL); |
206 <a name="l00185"></a>00185 <a class="code" href="classcan__uvccm__win32.html#c633c03ea1777d7ae38f23adae505ba5">m_write_event</a> = ::CreateEvent(NULL, TRUE, FALSE, NULL); |
207 <a name="l00186"></a>00186 |
207 <a name="l00186"></a>00186 |
208 <a name="l00187"></a>00187 <span class="keywordflow">return</span> <span class="keyword">true</span>; |
208 <a name="l00187"></a>00187 <span class="keywordflow">return</span> <span class="keyword">true</span>; |
209 <a name="l00188"></a>00188 } |
209 <a name="l00188"></a>00188 } |
210 <a name="l00189"></a>00189 |
210 <a name="l00189"></a>00189 |
211 <a name="l00190"></a><a class="code" href="classcan__uvccm__win32.html#06f9d2fb860a821436471c3233f91dff">00190</a> <span class="keywordtype">bool</span> <a class="code" href="classcan__uvccm__win32.html#06f9d2fb860a821436471c3233f91dff">can_uvccm_win32::close_rs232</a>() |
211 <a name="l00190"></a><a class="code" href="classcan__uvccm__win32.html#90d854d7d320ba381ad2b86644f13080">00190</a> <span class="keywordtype">bool</span> <a class="code" href="classcan__uvccm__win32.html#90d854d7d320ba381ad2b86644f13080">can_uvccm_win32::close_rs232</a>() |
212 <a name="l00191"></a>00191 { |
212 <a name="l00191"></a>00191 { |
213 <a name="l00192"></a>00192 <span class="keywordflow">if</span> (<a class="code" href="classcan__uvccm__win32.html#3f13c1748b3cd57fd1d478782428859a">m_port</a> != INVALID_HANDLE_VALUE) |
213 <a name="l00192"></a>00192 <span class="keywordflow">if</span> (<a class="code" href="classcan__uvccm__win32.html#16a0781c6112a96ba32e9c14124624a5">m_port</a> != INVALID_HANDLE_VALUE) |
214 <a name="l00193"></a>00193 { |
214 <a name="l00193"></a>00193 { |
215 <a name="l00194"></a>00194 ::PurgeComm(<a class="code" href="classcan__uvccm__win32.html#3f13c1748b3cd57fd1d478782428859a">m_port</a>, PURGE_RXABORT | PURGE_RXCLEAR | PURGE_TXABORT | PURGE_TXCLEAR); |
215 <a name="l00194"></a>00194 ::PurgeComm(<a class="code" href="classcan__uvccm__win32.html#16a0781c6112a96ba32e9c14124624a5">m_port</a>, PURGE_RXABORT | PURGE_RXCLEAR | PURGE_TXABORT | PURGE_TXCLEAR); |
216 <a name="l00195"></a>00195 ::CloseHandle(<a class="code" href="classcan__uvccm__win32.html#3f13c1748b3cd57fd1d478782428859a">m_port</a>); |
216 <a name="l00195"></a>00195 ::CloseHandle(<a class="code" href="classcan__uvccm__win32.html#16a0781c6112a96ba32e9c14124624a5">m_port</a>); |
217 <a name="l00196"></a>00196 <a class="code" href="classcan__uvccm__win32.html#3f13c1748b3cd57fd1d478782428859a">m_port</a> = INVALID_HANDLE_VALUE; |
217 <a name="l00196"></a>00196 <a class="code" href="classcan__uvccm__win32.html#16a0781c6112a96ba32e9c14124624a5">m_port</a> = INVALID_HANDLE_VALUE; |
218 <a name="l00197"></a>00197 ::CloseHandle(<a class="code" href="classcan__uvccm__win32.html#cf25e6725871137696ab41b06fa05417">m_read_event</a>); |
218 <a name="l00197"></a>00197 ::CloseHandle(<a class="code" href="classcan__uvccm__win32.html#85163a47e3246eba9a55ad63a34727e8">m_read_event</a>); |
219 <a name="l00198"></a>00198 <a class="code" href="classcan__uvccm__win32.html#cf25e6725871137696ab41b06fa05417">m_read_event</a> = 0; |
219 <a name="l00198"></a>00198 <a class="code" href="classcan__uvccm__win32.html#85163a47e3246eba9a55ad63a34727e8">m_read_event</a> = 0; |
220 <a name="l00199"></a>00199 ::CloseHandle(<a class="code" href="classcan__uvccm__win32.html#544ea7fd0e8a5d7cfb7cf9058d6020a4">m_write_event</a>); |
220 <a name="l00199"></a>00199 ::CloseHandle(<a class="code" href="classcan__uvccm__win32.html#c633c03ea1777d7ae38f23adae505ba5">m_write_event</a>); |
221 <a name="l00200"></a>00200 <a class="code" href="classcan__uvccm__win32.html#544ea7fd0e8a5d7cfb7cf9058d6020a4">m_write_event</a> = 0; |
221 <a name="l00200"></a>00200 <a class="code" href="classcan__uvccm__win32.html#c633c03ea1777d7ae38f23adae505ba5">m_write_event</a> = 0; |
222 <a name="l00201"></a>00201 <a class="code" href="classcan__uvccm__win32.html#d264855657adc02fbc687f37d302fc9f">m_residual_buffer</a>.clear(); |
222 <a name="l00201"></a>00201 <a class="code" href="classcan__uvccm__win32.html#10bd44df6a991527816fc87547a266f5">m_residual_buffer</a>.clear(); |
223 <a name="l00202"></a>00202 } |
223 <a name="l00202"></a>00202 } |
224 <a name="l00203"></a>00203 <span class="keywordflow">return</span> <span class="keyword">true</span>; |
224 <a name="l00203"></a>00203 <span class="keywordflow">return</span> <span class="keyword">true</span>; |
225 <a name="l00204"></a>00204 } |
225 <a name="l00204"></a>00204 } |
226 <a name="l00205"></a>00205 |
226 <a name="l00205"></a>00205 |
227 <a name="l00206"></a><a class="code" href="classcan__uvccm__win32.html#c3d1d02a46518b2639beb6060f79f2a2">00206</a> <span class="keywordtype">bool</span> <a class="code" href="classcan__uvccm__win32.html#c3d1d02a46518b2639beb6060f79f2a2">can_uvccm_win32::get_can_data</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>* can_cmd_buf, <span class="keywordtype">long</span>& bufsize, <a class="code" href="structMessage.html">Message</a>* m) |
227 <a name="l00206"></a><a class="code" href="classcan__uvccm__win32.html#9ffa5f900534ffc1bf5c80a0b29628a6">00206</a> <span class="keywordtype">bool</span> <a class="code" href="classcan__uvccm__win32.html#9ffa5f900534ffc1bf5c80a0b29628a6">can_uvccm_win32::get_can_data</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>* can_cmd_buf, <span class="keywordtype">long</span>& bufsize, <a class="code" href="structMessage.html">Message</a>* m) |
228 <a name="l00207"></a>00207 { |
228 <a name="l00207"></a>00207 { |
229 <a name="l00208"></a>00208 <span class="keywordflow">if</span> (bufsize < 5) |
229 <a name="l00208"></a>00208 <span class="keywordflow">if</span> (bufsize < 5) |
230 <a name="l00209"></a>00209 { |
230 <a name="l00209"></a>00209 { |
231 <a name="l00210"></a>00210 bufsize = 0; |
231 <a name="l00210"></a>00210 bufsize = 0; |
232 <a name="l00211"></a>00211 <span class="keywordflow">return</span> <span class="keyword">false</span>; |
232 <a name="l00211"></a>00211 <span class="keywordflow">return</span> <span class="keyword">false</span>; |