| 1 | |
|---|
| 2 | <!DOCTYPE html |
|---|
| 3 | PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> |
|---|
| 4 | <html> |
|---|
| 5 | <head> |
|---|
| 6 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> |
|---|
| 7 | |
|---|
| 8 | <!-- |
|---|
| 9 | This HTML is auto-generated from an M-file. |
|---|
| 10 | To make changes, update the M-file and republish this document. |
|---|
| 11 | --> |
|---|
| 12 | <title>COM_SendPacket</title> |
|---|
| 13 | <meta name="generator" content="MATLAB 7.7"> |
|---|
| 14 | <meta name="date" content="2008-11-05"> |
|---|
| 15 | <meta name="m-file" content="script_COM_SendPacket"> |
|---|
| 16 | <link type="text/css" rel="stylesheet" href="../../style.css"> |
|---|
| 17 | </head> |
|---|
| 18 | <body> |
|---|
| 19 | <p class="header">RWTH - Mindstorms NXT Toolbox</p> |
|---|
| 20 | <div class="content"> |
|---|
| 21 | <h1>COM_SendPacket</h1> |
|---|
| 22 | <!--introduction--> |
|---|
| 23 | <p>Sends a communication protocol packet (byte-array) via a USB or Bluetooth channel (serial port)</p> |
|---|
| 24 | <!--/introduction--> |
|---|
| 25 | <h2>Contents</h2> |
|---|
| 26 | <div> |
|---|
| 27 | <ul> |
|---|
| 28 | <li><a href="#2">Syntax</a></li> |
|---|
| 29 | <li><a href="#4">Description</a></li> |
|---|
| 30 | <li><a href="#10">Example</a></li> |
|---|
| 31 | <li><a href="#12">See also</a></li> |
|---|
| 32 | <li><a href="#14">Signature</a></li> |
|---|
| 33 | </ul> |
|---|
| 34 | </div> |
|---|
| 35 | <h2>Syntax<a name="2"></a></h2> |
|---|
| 36 | <p><tt>COM_SendPacket(Packet, handle)</tt></p> |
|---|
| 37 | <h2>Description<a name="4"></a></h2> |
|---|
| 38 | <p><tt>COM_SendPacket(Packet, handle)</tt> sends the given byte-array <tt>Packet</tt> (column vector), (which can easily be created by the function <tt>COM_CreatePacket</tt>) over the USB or Bluetooth channel specified by the given <tt>handle</tt> (struct) created by the function <tt>COM_OpenNXT</tt> or <tt>COM_OpenNXTEx</tt>, or obtained from <tt>COM_GetDefaultNXT</tt>. |
|---|
| 39 | </p> |
|---|
| 40 | <p><b>Note:</b></p> |
|---|
| 41 | <p>In the case of a Bluetooth connection this function uses the specific settings from the ini-file that was specified when opening |
|---|
| 42 | the handle. Parameters used here are <tt>SendSendPause</tt> and <tt>SendReceivePause</tt>, which will cause this function to wait a certain amount of milliseconds between each consecutive send or receive operation |
|---|
| 43 | to avoid packet loss or buffer overflows inside the blutooth stack. |
|---|
| 44 | </p> |
|---|
| 45 | <h2>Example<a name="10"></a></h2><pre class="codeinput"> COM_MakeBTConfigFile(); |
|---|
| 46 | |
|---|
| 47 | handle = COM_OpenNXT(<span class="string">'bluetooth.ini'</span>, <span class="string">'check'</span>); |
|---|
| 48 | |
|---|
| 49 | [type cmd] = name2commandbytes(<span class="string">'KEEPALIVE'</span>); |
|---|
| 50 | content = []; <span class="comment">% no payload in NXT command KEEPALIVE</span> |
|---|
| 51 | packet = COM_CreatePacket(type, cmd, <span class="string">'dontreply'</span>, content); |
|---|
| 52 | |
|---|
| 53 | COM_SendPacket(packet, bt_handle); |
|---|
| 54 | </pre><h2>See also<a name="12"></a></h2> |
|---|
| 55 | <p><a href="COM_CreatePacket.html">COM_CreatePacket</a>, <a href="COM_CollectPacket.html">COM_CollectPacket</a>, <a href="COM_OpenNXT.html">COM_OpenNXT</a>, <a href="COM_GetDefaultNXT.html">COM_GetDefaultNXT</a>, <a href="COM_MakeBTConfigFile.html">COM_MakeBTConfigFile</a></p> |
|---|
| 56 | <h2>Signature<a name="14"></a></h2> |
|---|
| 57 | <div> |
|---|
| 58 | <ul> |
|---|
| 59 | <li><b>Author:</b> Linus Atorf (see AUTHORS) |
|---|
| 60 | </li> |
|---|
| 61 | <li><b>Date:</b> 2008/07/09 |
|---|
| 62 | </li> |
|---|
| 63 | <li><b>Copyright:</b> 2007-2008, RWTH Aachen University |
|---|
| 64 | </li> |
|---|
| 65 | </ul> |
|---|
| 66 | </div> |
|---|
| 67 | <p class="footer"><br> |
|---|
| 68 | Published with wg_publish; V1.0<br></p> |
|---|
| 69 | </div> |
|---|
| 70 | <!-- |
|---|
| 71 | ##### SOURCE BEGIN ##### |
|---|
| 72 | %% COM_SendPacket |
|---|
| 73 | % Sends a communication protocol packet (byte-array) via a USB or Bluetooth channel (serial port) |
|---|
| 74 | %% |
|---|
| 75 | %% Syntax |
|---|
| 76 | % |COM_SendPacket(Packet, handle)| |
|---|
| 77 | %% |
|---|
| 78 | %% Description |
|---|
| 79 | % |COM_SendPacket(Packet, handle)| sends the given byte-array |Packet| (column vector), |
|---|
| 80 | % (which can easily be created by the function |COM_CreatePacket|) over the USB or Bluetooth |
|---|
| 81 | % channel specified by the given |handle| (struct) created by the function |COM_OpenNXT| or |
|---|
| 82 | % |COM_OpenNXTEx|, or obtained from |COM_GetDefaultNXT|. |
|---|
| 83 | %% |
|---|
| 84 | %% |
|---|
| 85 | % *Note:* |
|---|
| 86 | %% |
|---|
| 87 | %% |
|---|
| 88 | % In the case of a Bluetooth connection this function uses the specific settings from the |
|---|
| 89 | % ini-file that was specified when opening the handle. Parameters used here are |
|---|
| 90 | % |SendSendPause| and |SendReceivePause|, which will cause this function to wait a certain |
|---|
| 91 | % amount of milliseconds between each consecutive send or receive operation to avoid packet |
|---|
| 92 | % loss or buffer overflows inside the blutooth stack. |
|---|
| 93 | %% |
|---|
| 94 | %% Example |
|---|
| 95 | COM_MakeBTConfigFile(); |
|---|
| 96 | |
|---|
| 97 | handle = COM_OpenNXT('bluetooth.ini', 'check'); |
|---|
| 98 | |
|---|
| 99 | [type cmd] = name2commandbytes('KEEPALIVE'); |
|---|
| 100 | content = []; % no payload in NXT command KEEPALIVE |
|---|
| 101 | packet = COM_CreatePacket(type, cmd, 'dontreply', content); |
|---|
| 102 | |
|---|
| 103 | COM_SendPacket(packet, bt_handle); |
|---|
| 104 | %% |
|---|
| 105 | %% See also |
|---|
| 106 | % COM_CreatePacket, COM_CollectPacket, COM_OpenNXT, COM_GetDefaultNXT, COM_MakeBTConfigFile |
|---|
| 107 | %% |
|---|
| 108 | %% Signature |
|---|
| 109 | %% |
|---|
| 110 | % * *Author:* Linus Atorf (see AUTHORS) |
|---|
| 111 | % * *Date:* 2008/07/09 |
|---|
| 112 | % * *Copyright:* 2007-2008, RWTH Aachen University |
|---|
| 113 | % |
|---|
| 114 | |
|---|
| 115 | ##### SOURCE END ##### |
|---|
| 116 | --> |
|---|
| 117 | </body> |
|---|
| 118 | </html> |
|---|