Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Address review comments for superBraille driver and also rename its f…
…ile to superBrl,matching its name attribute. It can't internally be called superBraille as clashing with the existing add-on would make debugging tricky.
  • Loading branch information
michaelDCurran committed Jul 4, 2017
commit 838c17a5b4c29437b2b14c268fe6260b864ae574
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ class BrailleDisplayDriver(braille.BrailleDisplayDriver):
# Translators: Names of braille displays.
description = _("SuperBraille")
isThreadSafe=True
_dev=None

USB_IDs = {
"USB\\VID_10C4&PID_EA60", # SuperBraille 3.2
Expand All @@ -44,7 +43,6 @@ def getPossiblePorts(cls):
for portInfo in comPorts:
# Translators: Name of a serial communications port.
ports[portInfo["port"]] = _("Serial: {portName}").format(portName=portInfo["friendlyName"])
print "ports: %s"%ports
return ports

@classmethod
Expand All @@ -64,16 +62,13 @@ def check(cls):

def __init__(self,port="Auto"):
super(BrailleDisplayDriver, self).__init__()
found = False
if port == "auto":
tryPorts = self._getAutoPorts(hwPortUtils.listComPorts(onlyAvailable=True))
else:
tryPorts = ((port, "serial"),)
for port, portType in tryPorts:
log.debug("Checking port %s for a SuperBraille", port)
try:
self._dev = hwIo.Serial(port, baudrate=BAUD_RATE, stopbits=serial.STOPBITS_ONE, parity=serial.PARITY_NONE, timeout=TIMEOUT, writeTimeout=TIMEOUT, onReceive=self._onReceive)
log.debug("Port opened.")
except EnvironmentError:
continue

Expand All @@ -84,22 +79,16 @@ def __init__(self,port="Auto"):
if self.numCells:
# ok, it is a SuperBraille
log.info("Found superBraille device, version %s"%self.version)
found = True
break
else:
self._dev.close()
else:
self._dev.close()
if not found:
raise RuntimeError, "No SuperBralle found"
raise RuntimeError, "No SuperBraille found"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, missed this. This is old Python syntax. Please change to:

raise RuntimeError("No SuperBraille found")

That is, pass the message to the exception's constructor.


def terminate(self):
try:
super(BrailleDisplayDriver, self).terminate()
finally:
self._closeComPort()

def _closeComPort(self):
if self._dev is not None:
log.debug("Closing port %s", self._dev.port)
# We must sleep before closing the COM port as not doing this can leave the display in a bad state where it can not be re-initialized
time.sleep(TIMEOUT)
self._dev.close()
Expand All @@ -109,29 +98,20 @@ def _onReceive(self,data):
# The only info this display ever sends is number of cells and the display version.
# It sends 0x00, 0x05, number of cells, then version string of 8 bytes.
if data!='\x00':
log.info("unknown first byte")
return
data=self._dev.read(1)
if data!='\x05':
log.info("Unknown second byte")
return
self.numCells = ord(self._dev.read(1))
self._dev.read(1)
self.version=self._dev.read(8)

def display(self, cells):
# if the serial port is not open don't even try to write
if self._dev is None:
return
out = []
for cell in cells:
out.append("\x00")
out.append(chr(cell))
try:
self._dev.write(DISPLAY_TAG + "".join(out))
except EnvironmentError as e:
self._closeComPort()
raise e
self._dev.write(DISPLAY_TAG + "".join(out))

gestureMap = inputCore.GlobalGestureMap({
"globalCommands.GlobalCommands": {
Expand Down
2 changes: 1 addition & 1 deletion user_docs/en/userGuide.t2t
Original file line number Diff line number Diff line change
Expand Up @@ -2231,7 +2231,7 @@ Please see the [EcoBraille documentation ftp://ftp.once.es/pub/utt/bibliotecnia/
| Toggle braille tethered to | A |
%kc:endInclude

++ Super Braille ++
++ SuperBraille ++
The SuperBraille device, mostly available in Taiwan, can be connected to by either USB or serial.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there any links we need to/can provide here for USB drivers or the like? I get this thing isn't overly well documented (at least in English), so we can always add that later if you have no idea and someone asks for it.

As the SuperBraille does not have any physical typing keys or scrolling buttons, all input must be performed via a standard computer keyboard.
Due to this, and to maintain compatibility with other screen readers in Taiwan, two key bindings for scrolling the braille display have been provided:
Expand Down