{"id":906,"date":"2016-09-28T19:05:51","date_gmt":"2016-09-28T18:05:51","guid":{"rendered":"http:\/\/axotron.se\/blog\/?p=906"},"modified":"2016-09-28T19:05:51","modified_gmt":"2016-09-28T18:05:51","slug":"fixing-sportident-thermal-printer-issues","status":"publish","type":"post","link":"https:\/\/axotron.se\/blog\/fixing-sportident-thermal-printer-issues\/","title":{"rendered":"Fixing Sportident Thermal Printer Issues"},"content":{"rendered":"<p>The youth section of my orienteering club has a Sportident thermal printer connected to an SI station for use on trainings. This has worked fine for a few years, but for some reason it started printing garbage and I was asked to have a look at it.<\/p>\n<p>I had never used the printer before, but I started troubleshooting. The SI station had old firmware, so I updated that using Sportident Config+, but this did not help. At first I did not get the printer to print anything, but that turned out to be because I had failed to realize that the SI logo was actually a hidden power button one has to press briefly to turn the printer on or off. After the printer was powered on, it did indeed print garbage when I tried to print the contents of an SI card.<\/p>\n<p>The printer is a Martel MCP7830-242 printer with a serial port and I was able to find <a href=\"http:\/\/martelinstruments.com\/printers-by-printer-type\/mobile-printers-portable-printers\/ultra-compact-thermal-printers-a-range-of-connections\">a manual<\/a> for it. It turns out a customized manual is also available from <a href=\"https:\/\/www.sportident.com\/documents\/sets\/printout-set\/MCP7830-242_User-Guide.pdf\">Sportident<\/a>. I suspected the problem might be that the printer was set up to use an incorrect baud rate and I first tried to set the SI station in its two possible states, namely 4800 and 38400 bauds, but that did not help. The manuals have instructions on how to change the baud rate on the printer and according to those instructions, one should keep the power button pressed a couple of seconds until the LED starts blinking, then one should press the button four times and wait for the LED to blink four times (this enters the baud setting mode), then press the button six times to select 4800 baud. Unfortunately this did not help and the printer still printed garbage.<\/p>\n<p>I then decided to talk to the printer from a PC and I wrote a small Python script to try to send commands to it at different baud rates. After some fiddling around, the printer started responding, but at the unexpected baud rate of 600 bauds!<\/p>\n<p>The Python code is shown at the end of this post in case someone is interested.<\/p>\n<p>I retried the baud rate setting, but still with the result of getting the printer to accept 600 bauds. A note above the tables in the manual says one should do a single button press to select 19200 bauds, but the table says the button should be pressed five times. This made me try to press the button three instead of six times (4800 comes two steps after 19200 in the table) and after this, the printer started working at 4800! So the correct sequence for setting the baud rate to 4800 is this:<\/p>\n<ol>\n<li>Printer is off<\/li>\n<li>Hold down the button for a few seconds until the LED starts flashing.<\/li>\n<li>Press the button 4 times.<\/li>\n<li>Wait for the LED to flash 4 times.<\/li>\n<li>Press the button 3 times.<\/li>\n<li>Wait for the LED to flash 3 times.<\/li>\n<li>Done!<\/li>\n<\/ol>\n<p>After I got it all to work I realized that one can check the mode of the printer in the following way:<\/p>\n<ol>\n<li>Printer is off<\/li>\n<li>Hold down the button for two seconds.<\/li>\n<li>The printer prints its status, including the baud rate.<\/li>\n<\/ol>\n<p>If I had known this from the start I might have solved this much quicker.<\/p>\n<p>Below is the Python code.<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\n\r\n#! \/usr\/bin\/python\r\n\r\n&quot;&quot;&quot;\r\ncom-port-sender.py\r\n\r\nRev 0.1, 2016-09-28\r\nPer Magnusson, Axotron, axotron.se\/blog\r\n\r\nThis code is public domain and comes with absolutely no warranty. Enjoy!\r\n\r\nSend some data on a serial port to test a Martel\/Sportident MCP7830 printer.\r\n&quot;&quot;&quot;\r\n\r\nfrom __future__ import print_function\r\nimport serial\r\nimport serial.tools.list_ports\r\nimport sys\r\nimport time\r\nimport msvcrt\r\nimport struct\r\n\r\n\r\n# Look for a COM port that might have a serial port adapter connected\r\nportfound = False\r\nports = list(serial.tools.list_ports.comports())\r\nfor p in ports:\r\n    print(p)\r\n    print(p&#x5B;1])\r\n    if &quot;Prolific&quot; in p&#x5B;1]:\r\n        print(&quot;Found port on &quot; + p&#x5B;0])\r\n        if not portfound:\r\n            portname = p&#x5B;0]\r\n            portfound = True\r\n            print(&quot;Using &quot; + portname)\r\n        else:\r\n            print(&quot;Ignoring this port, using the first one that was found.&quot;)\r\n\r\nif portfound:\r\n    ser = serial.Serial(portname, 4800, timeout=0.1)\r\nelse:\r\n    print(&quot;No good serial port found. Exiting.&quot;)\r\n    time.sleep(10)\r\n    sys.exit(&quot;No good serial port found.&quot;)\r\n\r\n\r\ndef to_printer(ser, data):\r\n    for b in data:\r\n        print(&quot;{:d} &quot;.format(ord(b)), end=&quot;&quot;)\r\n    ser.write(data)\r\n    print(&quot;&quot;)\r\n\r\ndef send_ESC(ser):\r\n    to_printer(ser, b'\\x1b') # 27 == ESC\r\n\r\ndef send_NULL(ser):\r\n    to_printer(ser, b'x&#92;&#48;0')\r\n\r\ndef set_sweden(ser):\r\n    send_ESC(ser)\r\n    to_printer(ser, b'R5')\r\n\r\ndef set_mode_default(ser):\r\n    send_ESC(ser)\r\n    to_printer(ser, b'!\\x00')\r\n\r\ndef reset_printer(ser):\r\n    send_ESC(ser)\r\n    to_printer(ser, b'\\xff')\r\n\r\ndef reset_printer2(ser):\r\n    send_ESC(ser)\r\n    to_printer(ser, b'@')\r\n\r\ndef printer_self_test(ser):\r\n    send_ESC(ser)\r\n    to_printer(ser, b'\\xfe')\r\n\r\ndef printer_move_fwd(ser):\r\n    send_ESC(ser)\r\n    to_printer(ser, b'J\\x08')\r\n\r\ndef printer_print(ser):\r\n    send_ESC(ser)\r\n    to_printer(ser, b'd\\x01')\r\n\r\ndef print_something(ser):\r\n    to_printer(ser, b'abc\\x0d\\x0a\\x0c')\r\n\r\n\r\n#set_sweden(ser)\r\n#printer_self_test(ser)\r\n#reset_printer(ser)\r\n#reset_printer2(ser)\r\n#set_mode_default(ser)\r\n#printer_move_fwd(ser)\r\n#to_printer(ser, b'abc\\x0d\\x0a\\x0c')\r\n#printer_print(ser)\r\n\r\nrates = &#x5B;300, 600, 1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200]\r\n\r\nfor rate in rates:\r\n    print('baud: {:d}'.format(rate))\r\n    ser.setBaudrate(rate)\r\n    print_something(ser)\r\n    time.sleep(5)\r\n\r\nser.close()\r\n\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>The youth section of my orienteering club has a Sportident thermal printer connected to an SI station for use on trainings. This has worked fine for a few years, but for some reason it started printing garbage and I was asked to have a look at it. I had never used the printer before, but &hellip; <a href=\"https:\/\/axotron.se\/blog\/fixing-sportident-thermal-printer-issues\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Fixing Sportident Thermal Printer Issues<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-906","post","type-post","status-publish","format-standard","hentry","category-orienteering"],"_links":{"self":[{"href":"https:\/\/axotron.se\/blog\/wp-json\/wp\/v2\/posts\/906","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/axotron.se\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/axotron.se\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/axotron.se\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/axotron.se\/blog\/wp-json\/wp\/v2\/comments?post=906"}],"version-history":[{"count":7,"href":"https:\/\/axotron.se\/blog\/wp-json\/wp\/v2\/posts\/906\/revisions"}],"predecessor-version":[{"id":1271,"href":"https:\/\/axotron.se\/blog\/wp-json\/wp\/v2\/posts\/906\/revisions\/1271"}],"wp:attachment":[{"href":"https:\/\/axotron.se\/blog\/wp-json\/wp\/v2\/media?parent=906"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/axotron.se\/blog\/wp-json\/wp\/v2\/categories?post=906"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/axotron.se\/blog\/wp-json\/wp\/v2\/tags?post=906"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}