{"id":1075,"date":"2020-03-07T14:47:36","date_gmt":"2020-03-07T14:47:36","guid":{"rendered":"https:\/\/elephantandchicken.co.uk\/stuffandnonsense\/?p=1075"},"modified":"2020-03-08T16:30:52","modified_gmt":"2020-03-08T16:30:52","slug":"smart-box-list-of-commands","status":"publish","type":"post","link":"https:\/\/elephantandchicken.co.uk\/stuffandnonsense\/?p=1075","title":{"rendered":"Smart Box List of Commands"},"content":{"rendered":"\n<h2>Smart Box List of Commands<\/h2>\n\n\n\n<p>Having got a copy of the Economatics Smart Box &#8220;Operating System Serial Protocols&#8221; document curiosity of John and flaxcottage.com, I noted that one of the commands returns the name of a command based on the provided command number. Given that the instruction manual is most likely for an older version of the Smart Box (mine is an &#8220;SB-04&#8221;, rather than the older &#8220;SB-01&#8221;), which is build around a 6502 processor rather than the Mitsubishi microcontroller in mine, I wrote a short program which iterates through every command number between 0 and 99 and returns the &#8220;CodeName&#8221;. The following table shows the resulting output &#8211; I&#8217;ve also included room for other Smart Box variants for when I get access to one, or if someone runs the same program for me.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"\"><tbody><tr><td>Command No.<\/td><td>SB-01<\/td><td>SB-01\/EV<\/td><td>SB-04<\/td><\/tr><tr><td>0<\/td><td>Blank*<\/td><td><\/td><td>Blank<\/td><\/tr><tr><td>1<\/td><td>Version<\/td><td><\/td><td>Version<\/td><\/tr><tr><td>2<\/td><td>Reset<\/td><td><\/td><td>Reset<\/td><\/tr><tr><td>3<\/td><td>NameCode<\/td><td><\/td><td>NameCode<\/td><\/tr><tr><td>4<\/td><td>CodeName<\/td><td><\/td><td>CodeName<\/td><\/tr><tr><td>5<\/td><td>MultipleSetup<\/td><td><\/td><td>MultipleSetup<\/td><\/tr><tr><td>6<\/td><td>MultipleRead<\/td><td><\/td><td>MultipleRead<\/td><\/tr><tr><td>7<\/td><td>MultipleServer<\/td><td><\/td><td>MultipleServer<\/td><\/tr><tr><td>8<\/td><td><\/td><td><\/td><td>IdentSystem<\/td><\/tr><tr><td>9<\/td><td>Credits<\/td><td><\/td><td>Credits<\/td><\/tr><tr><td>10<\/td><td>WriteMotors<\/td><td><\/td><td>WriteMotors<\/td><\/tr><tr><td>11<\/td><td>ReadMotors<\/td><td><\/td><td>ReadMotors<\/td><\/tr><tr><td>12<\/td><td>MotorForward<\/td><td><\/td><td>MotorForward<\/td><\/tr><tr><td>13<\/td><td>MotorReverse<\/td><td><\/td><td>MotorReverse<\/td><\/tr><tr><td>14<\/td><td>MotorHalt<\/td><td><\/td><td>MotorHalt<\/td><\/tr><tr><td>15<\/td><td>MotorPower<\/td><td><\/td><td>MotorPower<\/td><\/tr><tr><td>16<\/td><td>PatchMF*<\/td><td><\/td><td>PatchMF<\/td><\/tr><tr><td>17<\/td><td><\/td><td><\/td><td>MotorVoltage<\/td><\/tr><tr><td>20<\/td><td>WriteOutputs<\/td><td><\/td><td>WriteOutputs<\/td><\/tr><tr><td>21<\/td><td>OutputPower<\/td><td><\/td><td>OutputPower<\/td><\/tr><tr><td>22<\/td><td>GetSensors*<\/td><td><\/td><td>GetSensors<\/td><\/tr><tr><td>23<\/td><td>CheckSensors*<\/td><td><\/td><td>CheckSensors<\/td><\/tr><tr><td>25<\/td><td><\/td><td><\/td><td>ReadSensorTable<\/td><\/tr><tr><td>28<\/td><td>SetBitHigh<\/td><td><\/td><td>SetBitHigh<\/td><\/tr><tr><td>29<\/td><td>SetBitLow<\/td><td><\/td><td>SetBitLow<\/td><\/tr><tr><td>30<\/td><td>ReadADCReg*<\/td><td><\/td><td><\/td><\/tr><tr><td>31<\/td><td>WriteADCReg*<\/td><td><\/td><td><\/td><\/tr><tr><td>32<\/td><td>ReadACIAReg*<\/td><td><\/td><td><\/td><\/tr><tr><td>33<\/td><td>WriteACIAReg*<\/td><td><\/td><td><\/td><\/tr><tr><td>34<\/td><td>ReadVIAReg*<\/td><td><\/td><td><\/td><\/tr><tr><td>35<\/td><td>WriteVIAReg*<\/td><td><\/td><td><\/td><\/tr><tr><td>36<\/td><td>SetVIAHigh*<\/td><td><\/td><td><\/td><\/tr><tr><td>37<\/td><td>SetVIALow*<\/td><td><\/td><td><\/td><\/tr><tr><td>40<\/td><td>ReadADC<\/td><td><\/td><td>ReadADC<\/td><\/tr><tr><td>41<\/td><td>ReadADCs<\/td><td><\/td><td>ReadADCs<\/td><\/tr><tr><td>42<\/td><td>ForcedADCRead<\/td><td><\/td><td>ForcedADCRead<\/td><\/tr><tr><td>44<\/td><td>HighResADC<\/td><td><\/td><td>HighResADC<\/td><\/tr><tr><td>45<\/td><td>LowResADC<\/td><td><\/td><td>LowResADC<\/td><\/tr><tr><td>47<\/td><td>ReadResolution<\/td><td><\/td><td>ReadResolution<\/td><\/tr><tr><td>50<\/td><td>DownloadData<\/td><td><\/td><td>DownloadData375<\/td><\/tr><tr><td>52<\/td><td>UploadData<\/td><td><\/td><td>UploadData375<\/td><\/tr><tr><td>54<\/td><td>ExecuteCode<\/td><td><\/td><td>ExecuteCode375<\/td><\/tr><tr><td>55<\/td><td>StoreByte<\/td><td><\/td><td>StoreByte375<\/td><\/tr><tr><td>56<\/td><td>ReadByte<\/td><td><\/td><td>ReadByte375<\/td><\/tr><tr><td>57<\/td><td>ReadRAMSize<\/td><td><\/td><td><\/td><\/tr><tr><td>59<\/td><td>ExtendCall<\/td><td><\/td><td><\/td><\/tr><tr><td>60<\/td><td>SetClock<\/td><td><\/td><td>SetClock<\/td><\/tr><tr><td>61<\/td><td>ReadClock<\/td><td><\/td><td>ReadClock<\/td><\/tr><tr><td>62<\/td><td>ReadTopmem<\/td><td><\/td><td><\/td><\/tr><tr><td>63<\/td><td>WriteTopmem<\/td><td><\/td><td><\/td><\/tr><tr><td>64<\/td><td>ReadLomem<\/td><td><\/td><td><\/td><\/tr><tr><td>65<\/td><td>WriteLomem<\/td><td><\/td><td><\/td><\/tr><tr><td>66<\/td><td>ReadHimem<\/td><td><\/td><td><\/td><\/tr><tr><td>67<\/td><td>WriteHimem<\/td><td><\/td><td><\/td><\/tr><tr><td>90<\/td><td>ReadInputs<\/td><td><\/td><td>ReadInputs<\/td><\/tr><tr><td>91<\/td><td>ReadBit<\/td><td><\/td><td>ReadBit<\/td><\/tr><tr><td>92<\/td><td><\/td><td><\/td><td>ReadOutputs<\/td><\/tr><tr><td>93<\/td><td><\/td><td><\/td><td>CountReset<\/td><\/tr><tr><td>94<\/td><td><\/td><td><\/td><td>CountRead<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p><em>Items marked with a * in the SB-01 column are undocumented. The SB-01 commands were taken from a machine belonging to mph1708 on the stardot.org.uk forums. The machine was running ROM OS 2.073 dated 12\/07\/96.<\/em><\/p>\n\n\n\n<p>The program I used is as follows &#8211; don&#8217;t forget to change the serial port from &#8220;\/dev\/ttyUSB0&#8221; to whatever is applicable on your setup :<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#!\/usr\/bin\/python\nimport time\nimport serial\n\nser = None\n\ndef getCommandName(cmd):\n        global ser\n        if ser.is_open:\n                ser.write(chr(4)+chr(cmd))\n                time.sleep(0.2)\n                readText = \"\"\n                while ser.inWaiting() > 0:\n                        readText += ser.read(1)\n        return readText\n\nser = serial.Serial('\/dev\/ttyUSB0', 9600, timeout=1)\n\nx=0\nwhile x&lt;100:\n\ttheText = getCommandName(x)\n\tif len(theText)>1:\n\t\tprint str(x)+\" : \"+theText\n\tx+=1\n\nser.close()\n<\/code><\/pre>\n\n\n\n<p>Please let me know if you have any interesting results via my contact page.<\/p>\n\n\n\n<p>Things to note looking at the results, compared to the available documentation&#8230;<\/p>\n\n\n\n<ul><li>Command 0 (Blank) is undocumented<\/li><li>Command 8 (IdentSystem) is undocumented<\/li><li>Command 9 is called &#8220;Credits&#8221; instead of &#8220;Copyright&#8221;<\/li><li>The documentation contains both &#8220;MotorHalt&#8221; and &#8220;MotorPower&#8221; (an typo?) as Command 14. The SB-04 box reports Command 14 as &#8220;MotorHalt&#8221; and Command 15 as &#8220;MotorPower&#8221;<\/li><li>Command 16 (PatchMF) is undocumented<\/li><li>Command 17 (MotorVoltage) is undocumented &#8211; this is not a surprise as some older Smart Boxes used a key to change voltages, whereas it seems that this is a software feature on the SB-04<\/li><li>Command 22 (GetSensors) is undocumented. I assume this reports what sensor types are connected?<\/li><li>Command 23 (CheckSensors) is undocumented<\/li><li>Command 25 (ReadSensorTable) is undocumented<\/li><li>The documentation contains both &#8220;SetBitHigh&#8221; and &#8220;SetBitLow&#8221; (an typo?) as Command 28. The SB-04 box reports Command 28 as &#8220;SetBitHigh&#8221; and Command 29 as &#8220;SetBitLow&#8221;<\/li><li>Command 43 is not present on the SB-04. This is &#8220;ReadSensor&#8221; and may have been replaced by Command 22, 23, and 25<\/li><li>Commands 50, 52, 54, 55 and 56, all of which relate to accessing the Smart Box memory and executing the contents of the memory, have been renamed with &#8220;375&#8221; on the end. I believe this refers to the microcontroller type? I am surprised to see they are still implemented at all.<\/li><li>Commands 51 and 53 have been omitted. These commands related to transferring data to and from the Smart Box using an Xmodem transfer format (with and without error checking)<\/li><li>Command 57 has been omitted (ReadRAMSize)<\/li><li>Command 58 has been omitted (ReadModule). This command seems to be for identifying some kind of hardware additions fitted to the equipment when the Smart Box was used embedded within a machine or similar.<\/li><li>Command 59 has been omitted (ExtendCall) this seems to be a method by which additional commands could be added and it seems unfortunate that it has been excluded. Reference is made to &#8220;Appendix B, machine code programming&#8221;. Unfortunately I don&#8217;t appear to have a copy of this appendix.<\/li><li>Command 62 is omitted (ReadTopMem)<\/li><li>Command 63 is omitted (WriteTopMem)<\/li><li>64, 65, 66 and 67 (&#8220;ReadLoMem&#8221;, &#8220;WriteLowMem&#8221;, &#8220;ReadHiMem&#8221; and &#8220;WriteHiMem&#8221; respectively) are all omitted<\/li><li>Command 93 (CountReset) is undocumented. I guess this is a hardware counter, but don&#8217;t currently know what input it is connected to.<\/li><li>Command 94 (CountRead) is undocumented. I guess this is a hardware counter, but don&#8217;t currently know what input it is connected to.<\/li><\/ul>\n\n\n\n<p>I&#8217;d be very interested to run the same program on an older Smart Box to see if there are any undocumented commands there. A fair few commands appear to have been removed for the SB-04, many of which were likely difficult or impossible to implement on the microcontroller as opposed to the full 6502 embedded computer that existed before.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Smart Box List of Commands Having got a copy of the Economatics Smart Box &#8220;Operating System Serial Protocols&#8221; document curiosity of John and flaxcottage.com, I noted that one of the commands returns the name of a command based on the provided command number. Given that the instruction manual is most likely for an older version [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1046,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"spay_email":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false},"categories":[6,13,12,152,153,260],"tags":[263,247,261,262,250,259,248],"jetpack_featured_media_url":"https:\/\/elephantandchicken.co.uk\/stuffandnonsense\/wp-content\/uploads\/2020\/02\/IMG_20200223_150134.jpg","jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p7g9vY-hl","_links":{"self":[{"href":"https:\/\/elephantandchicken.co.uk\/stuffandnonsense\/index.php?rest_route=\/wp\/v2\/posts\/1075"}],"collection":[{"href":"https:\/\/elephantandchicken.co.uk\/stuffandnonsense\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/elephantandchicken.co.uk\/stuffandnonsense\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/elephantandchicken.co.uk\/stuffandnonsense\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/elephantandchicken.co.uk\/stuffandnonsense\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1075"}],"version-history":[{"count":5,"href":"https:\/\/elephantandchicken.co.uk\/stuffandnonsense\/index.php?rest_route=\/wp\/v2\/posts\/1075\/revisions"}],"predecessor-version":[{"id":1100,"href":"https:\/\/elephantandchicken.co.uk\/stuffandnonsense\/index.php?rest_route=\/wp\/v2\/posts\/1075\/revisions\/1100"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/elephantandchicken.co.uk\/stuffandnonsense\/index.php?rest_route=\/wp\/v2\/media\/1046"}],"wp:attachment":[{"href":"https:\/\/elephantandchicken.co.uk\/stuffandnonsense\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1075"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/elephantandchicken.co.uk\/stuffandnonsense\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1075"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/elephantandchicken.co.uk\/stuffandnonsense\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1075"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}