Skip to content

Commit

Permalink
Updated seika driver supporting older protocol.
Browse files Browse the repository at this point in the history
Authors: Ulf Beckmann <beckmann@flusoft.de>, James Teh <jamie@jantrid.net>
Fixes #2606.
  • Loading branch information
jcsteh committed Aug 22, 2012
1 parent e2114a0 commit cf7b84a
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions source/brailleDisplayDrivers/seika.py
Expand Up @@ -11,7 +11,7 @@
# This file represents the braille display driver for
# Seika3 V2.00, Seika80, a product from Nippon Telesoft
# see www.seika-braille.com for more details
# 20.06.2012
# 18.08.2012 13:54

import time
import wx
Expand Down Expand Up @@ -49,19 +49,36 @@ def __init__(self):
self._ser = serial.Serial(port, baudrate=BAUDRATE, timeout=TIMEOUT, writeTimeout=TIMEOUT, parity=serial.PARITY_ODD, bytesize=serial.EIGHTBITS, stopbits=serial.STOPBITS_ONE)
except serial.SerialException:
continue
log.debug("serial port open {port}".format(port=port))
self._ser.write("\xFF\xFF\x1C")
self._ser.flush()
# Read out the input buffer
time.sleep(0.1)
versionS = self._ser.read(13)
log.debug("receive {p}".format(p=versionS))
if versionS.startswith("seika80"):
log.info("Found Seika80 connected via {port} Version {versionS}".format(port=port, versionS=versionS))
self.numCells = 80
break
elif versionS.startswith("seika3"):
if versionS.startswith("seika3"):
log.info("Found Seika40 connected via {port} Version {versionS}".format(port=port, versionS=versionS))
self.numCells = 40
self.s40 = "\xFF\xFF\x73\x65\x69\x6B\x61\x00"
break
# is it a old Seika3?
log.debug("test if it is a old Seika3")
self._ser.write("\xFF\xFF\x0A")
self._ser.flush()
# Read out the input buffer
time.sleep(0.1)
versionS = self._ser.read(12)
log.debug("receive {p}".format(p=versionS))
if versionS.startswith("\x00\x05\x28\x08\x76\x35\x2E\x30\x01\x01\x01\x01") or versionS.startswith("\x00\x05\x28\x08\x73\x65\x69\x6b\x61\x00"):
log.info("Found Seika3 old Version connected via {port} Version {versionS}".format(port=port, versionS=versionS))
self.numCells = 40
self.s40 = "\xFF\xFF\x04\x00\x63\x00\x50\x00"
break
self._ser.close()
else:
raise RuntimeError("No SEIKA40/80 display found")
self._readTimer = wx.PyTimer(self.handleResponses)
Expand All @@ -80,7 +97,7 @@ def display(self, cells):
if self.numCells==80:
line = "\xff\xff\x73\x38\x30\x00\x00\x00"+"".join(chr(cell) for cell in cells)
else:
line = "\xff\xff\x73\x65\x69\x6b\x61\x00"+"".join("\0"+chr(cell) for cell in cells)
line = self.s40+"".join("\0"+chr(cell) for cell in cells)
self._ser.write(line)

def handleResponses(self):
Expand All @@ -93,7 +110,7 @@ def handleResponses(self):
chars[0] = ord(self._ser.read())
chars[1] = ord(self._ser.read())
keytyp=1
if not chars[0] & 0xe0: # a cursorrouting block is expected
if not chars[0] & 0x60: # a cursorrouting block is expected
char = self._ser.read(max)
chars = [ord(c) for c in char]
keytyp=2
Expand Down

0 comments on commit cf7b84a

Please sign in to comment.