<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="https://wiki.transcends.co/skins/common/feed.css?303"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>https://wiki.transcends.co/index.php?action=history&amp;feed=atom&amp;title=Formatter</id>
		<title>Formatter - Revision history</title>
		<link rel="self" type="application/atom+xml" href="https://wiki.transcends.co/index.php?action=history&amp;feed=atom&amp;title=Formatter"/>
		<link rel="alternate" type="text/html" href="https://wiki.transcends.co/index.php?title=Formatter&amp;action=history"/>
		<updated>2026-04-19T19:12:59Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.23.1</generator>

	<entry>
		<id>https://wiki.transcends.co/index.php?title=Formatter&amp;diff=248&amp;oldid=prev</id>
		<title>Kyle at 17:56, 29 November 2007</title>
		<link rel="alternate" type="text/html" href="https://wiki.transcends.co/index.php?title=Formatter&amp;diff=248&amp;oldid=prev"/>
				<updated>2007-11-29T17:56:52Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;tr style='vertical-align: top;'&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Revision as of 17:56, 29 November 2007&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[category:developerDoc]][[category:&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;engineDoc&lt;/del&gt;]][[category:engineImplementation]]&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[category:developerDoc]][[category:&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;EmulatorDoc&lt;/ins&gt;]][[category:engineImplementation]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The formatter has two important methods:&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The formatter has two important methods:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Kyle</name></author>	</entry>

	<entry>
		<id>https://wiki.transcends.co/index.php?title=Formatter&amp;diff=132&amp;oldid=prev</id>
		<title>Kyle: New page: category:developerDoccategory:engineDoccategory:engineImplementation  The formatter has two important methods: #decode(): The decode method figures out what kind of command the...</title>
		<link rel="alternate" type="text/html" href="https://wiki.transcends.co/index.php?title=Formatter&amp;diff=132&amp;oldid=prev"/>
				<updated>2007-11-08T19:29:49Z</updated>
		
		<summary type="html">&lt;p&gt;New page: &lt;a href=&quot;/index.php/Category:DeveloperDoc&quot; title=&quot;Category:DeveloperDoc&quot;&gt;category:developerDoc&lt;/a&gt;&lt;a href=&quot;/index.php/Category:EngineDoc&quot; title=&quot;Category:EngineDoc&quot;&gt;category:engineDoc&lt;/a&gt;&lt;a href=&quot;/index.php/Category:EngineImplementation&quot; title=&quot;Category:EngineImplementation&quot;&gt;category:engineImplementation&lt;/a&gt;  The formatter has two important methods: #decode(): The decode method figures out what kind of command the...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;[[category:developerDoc]][[category:engineDoc]][[category:engineImplementation]]&lt;br /&gt;
&lt;br /&gt;
The formatter has two important methods:&lt;br /&gt;
#decode(): The decode method figures out what kind of command the incoming message is, and turns the raw command into an arrayList of objects, where the first thing in the object is the identification of the command type that will be used to look up the commandHandler in the reader.xml.  The second argument is the command itself.&lt;br /&gt;
#encode() The decode method performs any operations on the responses that need to happen on the way out.&lt;br /&gt;
&lt;br /&gt;
In the Symbol Formatter, the third byte is the command type, and is used to look up the handler method to use:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
public ArrayList&amp;lt;Object&amp;gt; decode(byte[] arg) {&lt;br /&gt;
    if (arg == null || arg.length &amp;lt; 4) {&lt;br /&gt;
        return null;&lt;br /&gt;
    }&lt;br /&gt;
    ArrayList&amp;lt;Object&amp;gt; retVal = new ArrayList&amp;lt;Object&amp;gt;();&lt;br /&gt;
    retVal.add(ByteAndHexConvertingUtility.toHexString(arg[3]));&lt;br /&gt;
    retVal.add(arg);&lt;br /&gt;
    &lt;br /&gt;
    return retVal;&lt;br /&gt;
	}&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On the way out, a 0x01 needs to be prepended to a response, and the CRC needs to be calculated.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
public ArrayList&amp;lt;Object&amp;gt; encode(ArrayList&amp;lt;Object&amp;gt; arg) {&lt;br /&gt;
&lt;br /&gt;
	ArrayList&amp;lt;Object&amp;gt; retVal = new ArrayList&amp;lt;Object&amp;gt;();&lt;br /&gt;
&lt;br /&gt;
	for (Object o : arg) {&lt;br /&gt;
		byte[] command = (byte[]) o;&lt;br /&gt;
&lt;br /&gt;
		/*&lt;br /&gt;
		 * Create outgoing array list that is 3 slots bigger than incoming&lt;br /&gt;
		 * one: one for start of frame and two for crc bytes&lt;br /&gt;
		 */&lt;br /&gt;
		byte[] outgoingCommand = new byte[command.length + 3];&lt;br /&gt;
		for (int i = 0; i &amp;lt; command.length; i++) {&lt;br /&gt;
			outgoingCommand[i + 1] = command[i];&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		/* Add Start of Frame Byte */&lt;br /&gt;
		outgoingCommand[0] = 0x01;&lt;br /&gt;
&lt;br /&gt;
		// Calculate CRC&lt;br /&gt;
		int crc = CRC16.calculateCRC(command, 0xBEEF,CRC16.XR400_CRC_TABLE, true);&lt;br /&gt;
		byte[] crcBytes = ByteAndHexConvertingUtility.intToByteArray(crc, 2);&lt;br /&gt;
&lt;br /&gt;
		// put crc in outgoingCommand, LSB first&lt;br /&gt;
		outgoingCommand[outgoingCommand.length - 2] = crcBytes[1];&lt;br /&gt;
		outgoingCommand[outgoingCommand.length - 1] = crcBytes[0];&lt;br /&gt;
			&lt;br /&gt;
		logger.debug(ByteAndHexConvertingUtility.toHexString(outgoingCommand));&lt;br /&gt;
			&lt;br /&gt;
			&lt;br /&gt;
		retVal.add(outgoingCommand);&lt;br /&gt;
&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	return retVal;&lt;br /&gt;
}&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;/div&gt;</summary>
		<author><name>Kyle</name></author>	</entry>

	</feed>