packet.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
  2. <HTML>
  3. <HEAD>
  4. <META NAME="GENERATOR" Content="Visual Page 1.0 for Windows">
  5. <META HTTP-EQUIV="Content-Type" CONTENT="text/html;CHARSET=iso-8859-1">
  6. <TITLE>TI-92 Link Protocol Guide - Packet formats</TITLE>
  7. </HEAD>
  8. <BODY BGCOLOR="#FFFFE8">
  9. <P><B>TI-92 Link Protocol Guide</B> - Packet formats
  10. <CENTER>
  11. <H2>
  12. <HR ALIGN="CENTER">
  13. Packet Formats</H2>
  14. </CENTER>
  15. <P>Texas Instruments calculators always send data and responses in self-contained &quot;packets.&quot; <BR>
  16. Packets have the following format: <BR>
  17. <I>Note - all 2-byte integers are transmitted little-endian Intel-style (least significant byte first).</I>
  18. <TABLE BORDER="1" CELLSPACING="0" WIDTH="92%">
  19. <TR>
  20. <TH WIDTH="7%" BGCOLOR="#008800"><FONT COLOR="#FFFFFF">Offset</FONT></TH>
  21. <TH WIDTH="8%" BGCOLOR="#008800"><FONT COLOR="#FFFFFF">Length</FONT></TH>
  22. <TH WIDTH="85%" BGCOLOR="#008800"><FONT COLOR="#FFFFFF">Description</FONT></TH>
  23. </TR>
  24. <TR>
  25. <TD WIDTH="7%" BGCOLOR="#FFFFFF">0</TD>
  26. <TD WIDTH="8%" BGCOLOR="#FFFFFF">1 byte</TD>
  27. <TD WIDTH="85%" BGCOLOR="#FFFFFF">Machine ID byte</TD>
  28. </TR>
  29. <TR>
  30. <TD WIDTH="7%" BGCOLOR="#FFFFFF">1</TD>
  31. <TD WIDTH="8%" BGCOLOR="#FFFFFF">1 byte</TD>
  32. <TD WIDTH="85%" BGCOLOR="#FFFFFF">Command ID byte</TD>
  33. </TR>
  34. <TR>
  35. <TD WIDTH="7%" BGCOLOR="#FFFFFF">2</TD>
  36. <TD WIDTH="8%" BGCOLOR="#FFFFFF">2 bytes</TD>
  37. <TD WIDTH="85%" BGCOLOR="#FFFFFF">Length of data (see note below)</TD>
  38. </TR>
  39. <TR>
  40. <TD WIDTH="7%" BGCOLOR="#FFFFFF">4</TD>
  41. <TD WIDTH="8%" BGCOLOR="#FFFFFF"><I>n</I> bytes</TD>
  42. <TD WIDTH="85%" BGCOLOR="#FFFFFF">Data (if attached)</TD>
  43. </TR>
  44. <TR>
  45. <TD WIDTH="7%" BGCOLOR="#FFFFFF">4+<I>n</I></TD>
  46. <TD WIDTH="8%" BGCOLOR="#FFFFFF">2 bytes</TD>
  47. <TD WIDTH="85%" BGCOLOR="#FFFFFF">Checksum (if data is attached)</TD>
  48. </TR>
  49. </TABLE>
  50. <I>Note - The &quot;Length of data&quot; element may not be equal to zero if the packet contains no data. In this
  51. case, the Command ID byte will indicate that the packet contains no data.</I>
  52. <H4>The Machine ID Byte</H4>
  53. <P>The Machine ID byte identifies the machine that is sending the packet. It can have one of the following values:
  54. <TABLE BORDER="1" CELLSPACING="0" WIDTH="66%">
  55. <TR>
  56. <TH WIDTH="13%" BGCOLOR="#DDDDDD">Value</TH>
  57. <TH BGCOLOR="#DDDDDD">Description</TH>
  58. </TR>
  59. <TR>
  60. <TD WIDTH="13%">09h</TD>
  61. <TD>Computer sending TI-92 data</TD>
  62. </TR>
  63. <TR>
  64. <TD WIDTH="13%">89h</TD>
  65. <TD>TI-92 to Computer or TI92 to TI92</TD>
  66. </TR>
  67. </TABLE>
  68. <p></P>
  69. <H4>The Command ID Byte</H4>
  70. <P>The Command ID byte identifies the request or response that the machine is sending. It can have one of the following
  71. values:
  72. <TABLE BORDER="1" CELLSPACING="0" WIDTH="66%">
  73. <TR>
  74. <TH WIDTH="22%" BGCOLOR="#DDDDDD">Value</TH>
  75. <TH WIDTH="259" BGCOLOR="#DDDDDD">Description</TH>
  76. <TH BGCOLOR="#DDDDDD">Data Included</TH>
  77. </TR>
  78. <TR>
  79. <TD WIDTH="22%">06h</TD>
  80. <TD WIDTH="259">Variable Header (VAR)</TD>
  81. <TD>A standard or padded <A HREF="#varheader">variable header</A></TD>
  82. </TR>
  83. <TR>
  84. <TD WIDTH="22%">09h</TD>
  85. <TD WIDTH="259">Clear to send (CTS)</TD>
  86. <TD><I>None</I></TD>
  87. </TR>
  88. <TR>
  89. <TD WIDTH="22%">15h</TD>
  90. <TD WIDTH="259">Data packet (DATA)</TD>
  91. <TD>Screenshot/variable/backup data</TD>
  92. </TR>
  93. <TR>
  94. <TD WIDTH="22%">36h</TD>
  95. <TD WIDTH="259">Out of Memory (MEM)</TD>
  96. <TD>Five bytes of unknown data</TD>
  97. </TR>
  98. <TR>
  99. <TD WIDTH="22%">56h</TD>
  100. <TD WIDTH="259">Acknowledge (ACK)</TD>
  101. <TD><I>None</I></TD>
  102. </TR>
  103. <TR>
  104. <TD WIDTH="22%">5Ah</TD>
  105. <TD WIDTH="259">Checksum Error (ERR) <BR>
  106. The previous packet must be sent again.</TD>
  107. <TD><I>None</I></TD>
  108. </TR>
  109. <TR>
  110. <TD WIDTH="22%">68h</TD>
  111. <TD WIDTH="259">Check Ready (RDY)</TD>
  112. <TD><I>None</I></TD>
  113. </TR>
  114. <TR>
  115. <TD WIDTH="22%">6Dh</TD>
  116. <TD WIDTH="259"><I>Silent</I> - Request Screenshot (SCR)</TD>
  117. <TD><I>None</I></TD>
  118. </TR>
  119. <TR>
  120. <TD WIDTH="22%">78h</TD>
  121. <TD WIDTH="259">Continue (CONT)</TD>
  122. <TD><I>None</I></TD>
  123. </TR>
  124. <TR>
  125. <TD WIDTH="22%">87h</TD>
  126. <TD WIDTH="259">Direct command (CMD)</TD>
  127. <TD><I>None - all data needed is in the packet header. There is no checksum.</I></TD>
  128. </TR>
  129. <TR>
  130. <TD WIDTH="22%">92h</TD>
  131. <TD WIDTH="259">End of Transmission (EOT)</TD>
  132. <TD><I>None</I></TD>
  133. </TR>
  134. <TR>
  135. <TD WIDTH="22%">A2h</TD>
  136. <TD WIDTH="259"><I>Silent</I> - Request Variable (REQ)</TD>
  137. <TD>A standard or padded <A HREF="#varheader">variable header</A></TD>
  138. </TR>
  139. <TR>
  140. <TD WIDTH="22%">C9h</TD>
  141. <TD WIDTH="259"><I>Silent</I> - Request to Send Variable (RTS)</TD>
  142. <TD>A standard or padded <A HREF="#varheader">variable header</A></TD>
  143. </TR>
  144. </TABLE>
  145. <H4>The Checksum</H4>
  146. <P>The checksum is a 16-bit value used to verify the integrity of the data in the packet. It only present if data
  147. is present. <BR>
  148. The checksum is calculated by taking the lower 16 bits of the sum of the data bytes, as shown below:</P>
  149. <PRE>int calculateChecksum(unsigned char* data, unsigned short datalength) {
  150. &nbsp;&nbsp; unsigned short x, checksum;
  151. &nbsp;&nbsp; for(x=0; x&lt;datalength; x++) {
  152. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; checksum+=data[x];&nbsp; //overflow automatically limits to 16 bits
  153. &nbsp;&nbsp; }
  154. &nbsp;&nbsp; return checksum;
  155. }</PRE>
  156. <CENTER>
  157. <H3>
  158. <HR ALIGN="CENTER">
  159. <A NAME="varheader"></A>Variable Headers</H3>
  160. </CENTER>
  161. <P>A Variable header contains information about one variable in the calculator. <BR>
  162. <TABLE BORDER="1" CELLSPACING="0" WIDTH="92%">
  163. <TR>
  164. <TH WIDTH="7%" BGCOLOR="#008800"><FONT COLOR="#FFFFFF">Offset</FONT></TH>
  165. <TH WIDTH="8%" BGCOLOR="#008800"><FONT COLOR="#FFFFFF">Length</FONT></TH>
  166. <TH WIDTH="85%" BGCOLOR="#008800"><FONT COLOR="#FFFFFF">Description</FONT></TH>
  167. </TR>
  168. <TR>
  169. <TD WIDTH="7%" BGCOLOR="#FFFFFF">0</TD>
  170. <TD WIDTH="8%" BGCOLOR="#FFFFFF">4 bytes</TD>
  171. <TD WIDTH="85%" BGCOLOR="#FFFFFF">Size of actual variable data, in bytes, with or without the first four bytes of each data packet.</TD>
  172. </TR>
  173. <TR>
  174. <TD WIDTH="7%" BGCOLOR="#FFFFFF">4</TD>
  175. <TD WIDTH="8%" BGCOLOR="#FFFFFF">1 byte</TD>
  176. <TD WIDTH="85%" BGCOLOR="#FFFFFF">Type ID Byte (see type ID's below)</TD>
  177. </TR>
  178. <TR>
  179. <TD WIDTH="7%" BGCOLOR="#FFFFFF">5</TD>
  180. <TD WIDTH="8%" BGCOLOR="#FFFFFF">1 byte</TD>
  181. <TD WIDTH="85%" BGCOLOR="#FFFFFF">Size of variable name, in characters</TD>
  182. </TR>
  183. <TR>
  184. <TD WIDTH="7%" BGCOLOR="#FFFFFF">6</TD>
  185. <TD WIDTH="8%" BGCOLOR="#FFFFFF"><I>n</I> bytes</TD>
  186. <TD WIDTH="85%" BGCOLOR="#FFFFFF">Variable name (not zero-terminated)</TD>
  187. </TR>
  188. </TABLE>
  189. <I>Note: These bytes only make up the &quot;data&quot; section of the packet.</I>
  190. <H4><A NAME="vartypes"></A>The Type ID Byte</H4>
  191. <P>The type ID byte specifies the type of variable that is being transmitted. It can have one of the following
  192. values:
  193. <TABLE BORDER="1" CELLSPACING="0" WIDTH="66%">
  194. <TR>
  195. <TH WIDTH="13%" BGCOLOR="#DDDDDD">Value</TH>
  196. <TH BGCOLOR="#DDDDDD">Description (click for variable format)</TH>
  197. </TR>
  198. <TR>
  199. <TD WIDTH="13%">00h</TD>
  200. <TD><A HREF="vars.html#expr">Expression</A></TD>
  201. </TR>
  202. <TR>
  203. <TD WIDTH="13%">04h</TD>
  204. <TD><A HREF="vars.html#list">List</A></TD>
  205. </TR>
  206. <TR>
  207. <TD WIDTH="13%">06h</TD>
  208. <TD><A HREF="vars.html#matrix">Matrix</A></TD>
  209. </TR>
  210. <TR>
  211. <TD WIDTH="13%">0Ah</TD>
  212. <TD><A HREF="vars.html#data">Data</A></TD>
  213. </TR>
  214. <TR>
  215. <TD WIDTH="13%">0Bh</TD>
  216. <TD><A HREF="vars.html#text">Text</A></TD>
  217. </TR>
  218. <TR>
  219. <TD WIDTH="13%">0Ch</TD>
  220. <TD><A HREF="vars.html#string">String</A></TD>
  221. </TR>
  222. <TR>
  223. <TD WIDTH="13%">0Dh</TD>
  224. <TD><A HREF="vars.html#gdb">GDB</A></TD>
  225. </TR>
  226. <TR>
  227. <TD WIDTH="13%">0Eh</TD>
  228. <TD><A HREF="vars.html#figure">Figure</A></TD>
  229. </TR>
  230. <TR>
  231. <TD WIDTH="13%">10h</TD>
  232. <TD><A HREF="vars.html#gdb">Picture</A></TD>
  233. </TR>
  234. <TR>
  235. <TD WIDTH="13%">12h</TD>
  236. <TD><A HREF="vars.html#program">Program</A></TD>
  237. </TR>
  238. <TR>
  239. <TD WIDTH="13%">13h</TD>
  240. <TD><A HREF="vars.html#program">Function</A></TD>
  241. </TR>
  242. <TR>
  243. <TD WIDTH="13%">14h</TD>
  244. <TD><A HREF="vars.html#program">Macro</A></TD>
  245. </TR>
  246. <TR>
  247. <TD WIDTH="13%"><A NAME="19h"></A>19h</TD>
  248. <TD>Complete Directory<I> (See note below)</I> - only used when requesting a listing of all variables on the calculator.</TD>
  249. </TR>
  250. <TR>
  251. <TD WIDTH="13%">1Dh</TD>
  252. <TD><A HREF="backup.html">Backup</A> <I>(See Backup Header Format below)</I></TD>
  253. </TR>
  254. <TR>
  255. <TD WIDTH="13%">1Fh</TD>
  256. <TD>Folder - only used when listing a directory.</TD>
  257. </TR>
  258. </TABLE>
  259. <I>Note - If the Type ID is 19h or 1Ah, then the name length byte has a value of 0 and the name field is empty.</I>
  260. <H4><A NAME="backup"></A>Backup Header Format</H4>
  261. <P>If the type ID byte specifies a backup, the variable header takes the following format:
  262. <TABLE BORDER="1" CELLSPACING="0" WIDTH="92%">
  263. <TR>
  264. <TH WIDTH="7%" BGCOLOR="#008800"><FONT COLOR="#FFFFFF">Offset</FONT></TH>
  265. <TH WIDTH="8%" BGCOLOR="#008800"><FONT COLOR="#FFFFFF">Length</FONT></TH>
  266. <TH WIDTH="85%" BGCOLOR="#008800"><FONT COLOR="#FFFFFF">Description</FONT></TH>
  267. </TR>
  268. <TR>
  269. <TD WIDTH="7%" BGCOLOR="#FFFFFF">0</TD>
  270. <TD WIDTH="8%" BGCOLOR="#FFFFFF">4 bytes</TD>
  271. <TD WIDTH="85%" BGCOLOR="#FFFFFF">Length, in bytes, of the backup data without the extra four bytes at the beginning of each data packet.</TD>
  272. </TR>
  273. <TR>
  274. <TD WIDTH="7%" BGCOLOR="#FFFFFF">3</TD>
  275. <TD WIDTH="8%" BGCOLOR="#FFFFFF">1 byte</TD>
  276. <TD WIDTH="85%" BGCOLOR="#FFFFFF">Type ID Byte (1Dh in this case).</TD>
  277. </TR>
  278. <TR>
  279. <TD WIDTH="7%" BGCOLOR="#FFFFFF">4</TD>
  280. <TD WIDTH="8%" BGCOLOR="#FFFFFF">1 bytes</TD>
  281. <TD WIDTH="85%" BGCOLOR="#FFFFFF">Length, in characters, of the name field.</TD>
  282. </TR>
  283. <TR>
  284. <TD WIDTH="7%" BGCOLOR="#FFFFFF">5</TD>
  285. <TD WIDTH="8%" BGCOLOR="#FFFFFF">n bytes</TD>
  286. <TD WIDTH="85%" BGCOLOR="#FFFFFF">Name.</TD>
  287. </TR>
  288. </TABLE>
  289. <p></P>
  290. <P>If the header is a request-style header, then the data length field (offset 0) contains 0 and the name field
  291. (offset 5) contains &quot;main\backup&quot;.</P>
  292. <P>If the header is a send-style header, then the data length is the length of the entire backup and the name field
  293. contains the ROM version string (e.g. &quot;1.11&quot; or &quot;2.1&quot;).</P>
  294. <P>If the header is a data-style header, then the data length is the length of the following 1-kilobyte section
  295. and the name field contains the ROM version string. Note that the data length field can be less than 400h if the
  296. following section is the final section.<BR>
  297. &nbsp;
  298. <TABLE BORDER="0" CELLSPACING="0" WIDTH="100%">
  299. <TR>
  300. <TD WIDTH="32%">
  301. <P ALIGN="CENTER"><A HREF="cable.html"><IMG SRC="graphics/prevpage.gif" WIDTH="32" HEIGHT="32" ALIGN="BOTTOM" ALT="[previous page]"
  302. BORDER="2"></A><BR>
  303. <A HREF="cable.html">Link Cables</A>
  304. </TD>
  305. <TD WIDTH="34%">
  306. <P ALIGN="CENTER"><A HREF="index.html"><IMG SRC="graphics/home.gif" WIDTH="32" HEIGHT="32" ALIGN="BOTTOM" ALT="[home]"
  307. BORDER="2"></A><BR>
  308. <A HREF="index.html">Table of Contents</A>
  309. </TD>
  310. <TD WIDTH="34%">
  311. <P ALIGN="CENTER"><A HREF="remote.html"><IMG SRC="graphics/nextpage.gif" WIDTH="32" HEIGHT="32" ALIGN="BOTTOM"
  312. ALT="[next page]" BORDER="2"><BR>
  313. Remote control</A>
  314. </TD>
  315. </TR>
  316. </TABLE>
  317. <HR ALIGN="CENTER">
  318. <I>Site maintained by Romain Li&eacute;vin (</I><A HREF="mailto:roms@lpg.ticalc.org"><I>roms@lpg.ticalc.org</I></A><I>)
  319. and Tim Singer (</I><A HREF="mailto:tsinger@gladstone.uoregon.edu"><I>tsinger@gladstone.uoregon.edu</I></A><I>)</I>
  320. </BODY>
  321. </HTML>