Skip to content

Commit e8ebe86

Browse files
authored
Handle BrailliantB devices that do not report their number of cells (#17526)
Partially fixes #17518 Summary of the issue: Some HumanWare devices do not report the number of cells in their HID capabilities report. This is the case for Brailliant BI 40X since firmware 2.4. Description of user facing changes The Brailliant BI 40X and similar display with firmware version 2.4 is working correctly again. Description of development approach This PR fixes the issue by using the HID output report size to calculate the number of cells. If the device reports a cell count, this is still being used. Testing strategy: Tested with a Brailliant BI 40X over Bluetooth. Known issues with pull request: Since firmware 2.4 this device is recognized by the Standard HID driver over Bluetooth. However, the keys do not work using that driver. This PR does not fix the Standard HID driver.
1 parent 7df9590 commit e8ebe86

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

source/brailleDisplayDrivers/brailliantB.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,11 +190,27 @@ def __init__(self, port="auto"):
190190

191191
def _initAttempt(self):
192192
if self.isHid:
193+
# Ensure to set self.numCells only at the end of this method to prevent display writes before the capabilities/numCells request
194+
numCells = 0
195+
# First try to get cell count from _writeSize
196+
try:
197+
# _writeSize includes 4 bytes of overhead, so subtract 4
198+
numCells = self._dev._writeSize - 4
199+
except AttributeError:
200+
log.debugWarning("Could not get _writeSize from HID device")
201+
202+
# Adjust numCells based on reported number of cells
193203
try:
194204
data: bytes = self._dev.getFeature(HR_CAPS)
205+
reportedNumCells = data[24]
206+
if reportedNumCells > 0:
207+
# Update numCells based on reported cell count from the device
208+
numCells = reportedNumCells
209+
else:
210+
log.debugWarning("Could not get number of cells from HID device using HR_CAPS")
195211
except WindowsError:
196212
return # Fail!
197-
self.numCells = data[24]
213+
self.numCells = numCells
198214
else:
199215
# This will cause the display to return the number of cells.
200216
# The _serOnReceive callback will see this and set self.numCells.

user_docs/en/changes.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
### Bug Fixes
66

7+
* Humanware Brailliant BI 40X devices running firmware version 2.4 now work as expected. (#17518, @bramd)
8+
79
## 2024.4.1
810

911
This is a patch release to fix a bug when saving speech symbol dictionaries.

0 commit comments

Comments
 (0)