Repository navigation
Driver for Tivomatic Caiku Albatross 46/80 displays #13045
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 161 commits
Commits
Show all changes
164 commits
Select commit
Hold shift + click to select a range
1b5ef12
Driver for Tivomatic Caiku Albatross 46/80 displays; supports automat…
burmancomp b2092dd
Initialized oldCells data earlier to improve stability.
burmancomp 6a098e7
Handling situation where value byte is the first one read during conn…
burmancomp 9b57547
Fixed braille terminate error caused by NoneType object.
burmancomp 125cc01
Removed redundant code and minor changes.
burmancomp 84cc2ff
One command lacked from command list.
burmancomp 2706c96
Finnish user guide reverted.
burmancomp 3617b39
Code refactoring.
burmancomp a005772
Command modifications, and some refactoring of connection establishment.
burmancomp 8a3df6a
Resolved merge conflicts.
burmancomp 4608e3c
Merge branch 'master' into albatrossDriver
burmancomp 6d16e1c
Some modifications on the basis of change request
burmancomp 59e4669
Merge branch 'master' into albatrossDriver
burmancomp 7a331c4
Timer related modifications, and proper display update after reconnect
burmancomp 5071b76
More reliable startup, onReceive code to simpler functions
burmancomp 6989705
Merge branch 'master' into albatrossDriver
burmancomp d84a74f
Merge branch 'master' into albatrossDriver
burmancomp 276f6d3
Merge branch 'master' into albatrossDriver
burmancomp 1681a87
Fixes/improvements
burmancomp c4357e3
Merge branch 'master' into albatrossDriver
burmancomp 1f0bc20
Merge branch 'master' into albatrossDriver
burmancomp 89792dc
Merge branch 'master' into albatrossDriver
burmancomp ef15803
Merge branch 'master' into albatrossDriver
burmancomp 3fa43e7
Merge branch 'master' into albatrossDriver
burmancomp 7600e69
Merge branch 'master' into albatrossDriver
burmancomp 332cc33
Merge branch 'master' into albatrossDriver
burmancomp 4cdec93
Merge branch 'master' into albatrossDriver
burmancomp 08f1b3c
Refactored code without hwIo
burmancomp d2fe4c3
Merge branch 'master' into albatrossDriver
burmancomp 1bdec93
Some code optimization/refactoring and debug logging adjustments
burmancomp fa0dffc
Merge branch 'master' into albatrossDriver
burmancomp 561f221
Merge branch 'master' into albatrossDriver
burmancomp 5aed563
Some code refactoring
burmancomp ca38aab
Merge branch 'master' into albatrossDriver
burmancomp 7915486
Revert of changing between models on the fly
burmancomp f5220c4
Revert "Revert of changing between models on the fly"
burmancomp 795de03
Trying again to apply revert of changing model on the fly
burmancomp 8ce7694
Merge branch 'master' into albatrossDriver
burmancomp e61714b
Merge branch 'master' into albatrossDriver
burmancomp ff7d5ee
Merge branch 'master' into albatrossDriver
burmancomp 1b26761
Merge branch 'master' into albatrossDriver
burmancomp 74f8806
Merge branch 'master' into albatrossDriver
burmancomp 712f4c7
Merge branch 'master' into albatrossDriver
burmancomp a6aefce
Merge branch 'master' into albatrossDriver
burmancomp 9eba34a
Merge branch 'master' into albatrossDriver
burmancomp 811aab8
Merge branch 'master' into albatrossDriver
burmancomp 068be19
Merge branch 'master' into albatrossDriver
burmancomp a776992
Merge branch 'master' into albatrossDriver
burmancomp 917a09f
Merge branch 'master' into albatrossDriver
burmancomp 9391a15
Merge branch 'master' into albatrossDriver
burmancomp 849d4b3
Merge branch 'master' into albatrossDriver
burmancomp 0db63a5
Merge branch 'master' into albatrossDriver
burmancomp a35cbb8
Merge branch 'master' into albatrossDriver
burmancomp 359571f
Merge branch 'master' into albatrossDriver
burmancomp af268fa
Merge branch 'master' into albatrossDriver
burmancomp 7067f2c
Merge branch 'master' into albatrossDriver
burmancomp d5341e1
Merge branch 'master' into albatrossDriver
burmancomp 7849cb3
Merge branch 'master' into albatrossDriver
burmancomp 43de707
Some suggested changes
burmancomp 9869d0e
Encapsulated keys
burmancomp 02c1042
Driver moved to submodule albatross
burmancomp 9484b1a
Merge branch 'master' into albatrossDriver
burmancomp eee102e
Changes for Flake8
burmancomp a4a5dea
Fix for Flake8 F401 Module imported but unused error
burmancomp 127756e
Merge branch 'master' into albatrossDriver
burmancomp 00c64a6
Replaced raising exceptions with _disableFunction() and continue
burmancomp 29ca803
Merge branch 'master' into albatrossDriver
burmancomp 7da9a2b
Merge branch 'master' into albatrossDriver
burmancomp adcb56e
Merge branch 'master' into albatrossDriver
burmancomp f06545e
Merge branch 'master' into albatrossDriver
burmancomp 8400f3f
Minor userGuide fixes, Docstrings and some code refactoring
burmancomp 5e70106
Merge branch 'master' into albatrossDriver
burmancomp e1f75f0
Requested changes
burmancomp d5884db
Merge branch 'master' into albatrossDriver
burmancomp 4fa9b26
Translation comment fix
burmancomp 76a5d74
Try to fix the first valid key press was not recognized as a gesture
burmancomp 492a20d
Merge branch 'master' into albatrossDriver
burmancomp 6fae847
Code refactoring for "first key not recognized"
burmancomp c036932
retry build
burmancomp b8c895c
Merge branch 'master' into albatrossDriver
burmancomp 864d4dc
Merge branch 'master' into albatrossDriver
burmancomp bac01ba
Support for Windows secure screens when normal copy is running
burmancomp f873211
Added albatross subpackage to the package list
burmancomp 0823bcb
Merge branch 'master' into albatrossDriver
burmancomp 18a54b8
retry build
burmancomp 7e799e4
Merge branch 'master' into albatrossDriver
burmancomp 663628f
Requested changes
burmancomp 84af3ae
retry build
burmancomp 3a38ab5
updated file name to _threads.py
burmancomp 78301fc
Merge branch 'master' into albatrossDriver
burmancomp d5f35a0
missed change requests
burmancomp 0611660
Merge branch 'master' into albatrossDriver
burmancomp b690935
Updated/added comment of try/except for in_waiting
burmancomp 99096db
Moved one in_waiting comment down by one line
burmancomp b6d3c96
Removed redundant try except from _readSettingsByte function
burmancomp 4623c79
Requested changes
burmancomp e99ccae
Merge branch 'master' into albatrossDriver
burmancomp c20e87f
Lacking blank line
burmancomp 618f929
Minor userguide fix
burmancomp 8e87cc3
Merge branch 'master' into albatrossDriver
burmancomp 31a89c4
Removed extra parentheses, and corrected typos
burmancomp 229bd00
Simpler timer implementation is adequate
burmancomp 242ef77
retry build
burmancomp bdc6ae9
Merge branch 'master' into albatrossDriver
burmancomp 4f18f2b
Merge branch 'master' into albatrossDriver
burmancomp fecb0b6
Merge branch 'master' into albatrossDriver
burmancomp a81d94a
Merge branch 'master' into albatrossDriver
burmancomp b9b9f88
Merge branch 'master' into albatrossDriver
burmancomp 0b90baa
Merge branch 'master' into albatrossDriver
burmancomp 526047f
Merge branch 'master' into albatrossDriver
burmancomp 137ffea
Merge branch 'master' into albatrossDriver
burmancomp 83993fb
Merge branch 'master' into albatrossDriver
burmancomp dfaeb0d
Merge branch 'master' into albatrossDriver
burmancomp e1b5ba3
Merge branch 'master' into albatrossDriver
burmancomp cd104ee
Merge branch 'master' into albatrossDriver
burmancomp 62198f8
Merge branch 'master' into albatrossDriver
burmancomp 2a7f7ef
Merge branch 'master' into albatrossDriver
burmancomp 3a3c9c0
Merge branch 'master' into albatrossDriver
burmancomp 35d5949
Merge branch 'master' into albatrossDriver
burmancomp c2f53d7
Merge branch 'master' into albatrossDriver
burmancomp 7e30502
Merge branch 'master' into albatrossDriver
burmancomp 7a8b087
Merge branch 'master' into albatrossDriver
burmancomp 2e95583
Merge branch 'master' into albatrossDriver
burmancomp 2085a89
Merge branch 'master' into albatrossDriver
burmancomp 60ab848
Merge branch 'master' into albatrossDriver
burmancomp 6f26fce
Merge branch 'master' into albatrossDriver
burmancomp c3e01ad
Support for more display internal menu settings
burmancomp 35f763b
Docstrings refactoring
burmancomp 1c10e90
Merge branch 'master' into albatrossDriver
burmancomp 5975d09
Merge branch 'master' into albatrossDriver
burmancomp 9090d92
Updated readme.md
burmancomp 66b3661
Edited docstrings and some variable renaming
burmancomp fe63c08
restart build
burmancomp e7e4eb0
Merge branch 'master' into albatrossDriver
burmancomp 0cdfc1b
Using dictionary instead of tuples for left and right side keys
burmancomp ca96dce
Merge branch 'master' into albatrossDriver
burmancomp 670eaf0
Merge branch 'master' into albatrossDriver
burmancomp e1ecd00
Modifications related to (PR #14312)
burmancomp f3bb228
Minor modification for better readability
burmancomp dc7f276
Merge branch 'master' into albatrossDriver
burmancomp 7d91e7b
Merge branch 'master' into albatrossDriver
burmancomp 298e4fa
Requested changes and similar ones to other docstrings
burmancomp 766d0a2
Merge branch 'master' into albatrossDriver
burmancomp d084f96
Merge branch 'master' into albatrossDriver
burmancomp 4f96d65
Some style issues corrected
burmancomp c376337
Merge branch 'master' into albatrossDriver
burmancomp 63cff05
Merge branch 'master' into albatrossDriver
burmancomp 55f6cce
Merge branch 'master' into albatrossDriver
burmancomp 672c854
Merge branch 'master' into albatrossDriver
burmancomp 6dd5573
Merge branch 'master' into albatrossDriver
burmancomp 58c97e3
Merge branch 'master' into albatrossDriver
burmancomp 3f2dcd9
Merge branch 'master' into albatrossDriver
burmancomp 5805d11
Merge branch 'master' into albatrossDriver
burmancomp 81c1418
Merge branch 'master' into albatrossDriver
burmancomp ae05254
Merge branch 'master' into albatrossDriver
burmancomp b008acd
Merge branch 'master' into albatrossDriver
burmancomp 70c9cc5
Updated year of copyright
burmancomp 1baa9e5
Merge branch 'master' into albatrossDriver
burmancomp 74cde7a
Merge branch 'master' into albatrossDriver
burmancomp f39912d
Merge branch 'master' into albatrossDriver
burmancomp 7ae767f
Requested changes and some others
burmancomp a1029b2
requested changes and one missplaced quotation mark
burmancomp 4e20b70
Merge remote-tracking branch 'origin/master' into albatrossDriver
seanbudd 385dd01
update changes
seanbudd File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| # A part of NonVisual Desktop Access (NVDA) | ||
| # This file is covered by the GNU General Public License. | ||
| # See the file COPYING for more details. | ||
| # Copyright (C) 2023 NV Access Limited, Burman's Computer and Education Ltd. | ||
|
|
||
| """Braille display driver for Tivomatic Caiku albatross 46 and 80 displays.""" | ||
|
|
||
| # Imported here so that braille._getDisplayDriver can import | ||
| from .driver import BrailleDisplayDriver # noqa: F401 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,156 @@ | ||
| # A part of NonVisual Desktop Access (NVDA) | ||
| # This file is covered by the GNU General Public License. | ||
| # See the file COPYING for more details. | ||
| # Copyright (C) 2023 NV Access Limited, Burman's Computer and Education Ltd. | ||
|
|
||
| """Threads for Tivomatic Caiku Albatross braille display driver. | ||
| Classes: | ||
| - L{ReadThread}; manages reconnection retries and works as a trigger | ||
| for read operations excluding initial connection establishment | ||
| - L{RepeatedTimer}; timer to check periodically if data needs to be sent | ||
| to display to keep connection. If display gets nothing within approximately | ||
| 2 seconds, it falls back to "wait for connection" state. | ||
| """ | ||
|
|
||
| import ctypes | ||
| import serial | ||
|
|
||
| from ctypes import byref | ||
| from ctypes.wintypes import DWORD | ||
| from logHandler import log | ||
| from serial.win32 import ( | ||
| ERROR_IO_PENDING, | ||
| EV_RXCHAR, | ||
| GetLastError, | ||
| SetCommMask, | ||
| ) | ||
| from threading import ( | ||
| Event, | ||
| Thread, | ||
| Timer, | ||
| ) | ||
| from typing import Callable | ||
|
|
||
| from .constants import KC_INTERVAL | ||
|
|
||
|
|
||
| class ReadThread(Thread): | ||
| """Controls most of read operations and tries to reconnect when needed.""" | ||
|
|
||
| def __init__( | ||
| self, | ||
| readFunction: Callable[[], None], | ||
| disableFunction: Callable[[], None], | ||
| event: Event, | ||
| dev: serial.Serial, | ||
| *args, | ||
| **kwargs | ||
| ): | ||
| """Constructor. | ||
| @param readFunction: Handles read operations and reconnection. | ||
| @param disableFunction: Called on connection failure. | ||
| @param event: Exit thread when set. | ||
| @param dev: Port object. | ||
| """ | ||
|
burmancomp marked this conversation as resolved.
|
||
| super().__init__(*args, **kwargs) | ||
| self._readFunction = readFunction | ||
| self._disableFunction = disableFunction | ||
| self._event = event | ||
| self._dev = dev | ||
|
|
||
| def run(self): | ||
| data = dwEvtMask = DWORD() | ||
| log.debug(f"{self.name} started") | ||
| while not self._event.isSet(): | ||
| # Try to reconnect if port is not open | ||
| if not self._dev.is_open: | ||
| log.debug( | ||
| f"Calling {self._readFunction.__name__}, port {self._dev.name} not open" | ||
| ) | ||
| self._readFunction() | ||
| if not self._dev.is_open: | ||
| log.debug( | ||
| f"Sleepin {KC_INTERVAL} seconds, port {self._dev.name} not open" | ||
| ) | ||
| self._event.wait(KC_INTERVAL) | ||
| continue | ||
| # If any of I/O function fails, it should not crash the thread. | ||
| try: | ||
| if not SetCommMask(self._dev._port_handle, EV_RXCHAR): | ||
| # Exiting | ||
| if self._event.isSet(): | ||
| break | ||
| self._disableFunction() | ||
| log.debug("SetCommMask failed") | ||
| continue | ||
| result = ctypes.windll.kernel32.WaitCommEvent( | ||
| self._dev._port_handle, | ||
| byref(dwEvtMask), | ||
| byref(self._dev._overlapped_read) | ||
| ) | ||
| if not result and GetLastError() != ERROR_IO_PENDING: | ||
| if self._event.isSet(): | ||
| break | ||
| self._disableFunction() | ||
| log.debug("WaitCommEvent failed") | ||
| continue | ||
| result = ctypes.windll.kernel32.GetOverlappedResult( | ||
| self._dev._port_handle, | ||
| byref(self._dev._overlapped_read), | ||
| byref(data), True | ||
|
burmancomp marked this conversation as resolved.
Outdated
|
||
| ) | ||
| if result: | ||
| log.debug(f"Calling function {self._readFunction.__name__} for read") | ||
| self._readFunction() | ||
| else: | ||
| if self._event.isSet(): | ||
| break | ||
| log.debug(f"GetOverLappedResult failed {ctypes.WinError()}") | ||
| self._disableFunction() | ||
| # Considering situation where "albatross_read" thread is about to read | ||
| # but writing to display fails during it - or vice versa - AttributeError | ||
| # or TypeError might raise. | ||
| except (OSError, AttributeError, TypeError): | ||
|
burmancomp marked this conversation as resolved.
Outdated
|
||
| if self._event.isSet(): | ||
| break | ||
| else: | ||
| self._disableFunction() | ||
| log.debug("", exc_info=True) | ||
| log.debug(f"Exiting {self.name}") | ||
|
|
||
|
|
||
| class RepeatedTimer: | ||
| """Repeating timer. | ||
| Timer is used to check if data needs to be sent to display to keep | ||
| connected. | ||
| """ | ||
|
|
||
| def __init__( | ||
| self, | ||
| interval: float, | ||
| feedFunction: Callable[[], None] | ||
| ): | ||
| """Constructor. | ||
| @param interval: Checking frequency | ||
|
burmancomp marked this conversation as resolved.
|
||
| @param feedFunction: feeds display with data if needed | ||
| """ | ||
| self._interval = interval | ||
| self._timer = Timer(self._interval, self._run) | ||
| self._feedFunction = feedFunction | ||
| self.is_running = False | ||
| self.start() | ||
|
|
||
| def _run(self): | ||
| self.is_running = False | ||
| self.start() | ||
| self._feedFunction() | ||
|
|
||
| def start(self): | ||
| if not self.is_running: | ||
| self._timer = Timer(self._interval, self._run) | ||
| self._timer.start() | ||
| self.is_running = True | ||
|
|
||
| def stop(self): | ||
| self._timer.cancel() | ||
| self.is_running = False | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.