Update seika braille driver for python 3#10961
Conversation
Update the seika.py by using the Python v3. Have well tested with Seika v3/5/80 devices.
See test results for failed build of commit a9d35d0c53 |
Fixed errors:
source/brailleDisplayDrivers/seika.py:6:1: E265 block comment should start with '# '
#Copyright (C) 2012/20 Ulf Beckmann <beckmann@flusoft.de>
^
source/brailleDisplayDrivers/seika.py:105:13: E203 whitespace before ':'
lineBytes : bytes = self.s40 + bytes(cells) + cellPadding
^
source/brailleDisplayDrivers/seika.py:199:1: W391 blank line at end of file
^
1 E203 whitespace before ':'
1 E265 block comment should start with '# '
1 W391 blank line at end of file
|
Thanks @moyanming. Since it seems that the intention of this PR to replace #9479, I'll close that PR and communication can continue here. |
| if versionS.startswith(b"seika80"): | ||
| log.info("Found Seika80 connected via {port} Version {versionS}".format(port=port, versionS=versionS)) | ||
| self.numCells = 80 | ||
| self.s40 = b"\xff\xff\x73\x38\x30\x00\x00\x00" |
There was a problem hiding this comment.
Can you add a comment to explain what this is for, or what these values mean? This will be very helpful if the community has to maintain this file in the future.
There was a problem hiding this comment.
There needs handshake between Seika v3/5/80 and NVDA before any actual Braille data. The handshake data (\xff\xff\x73\x38\x30\x00\x00\x00) is one part of the transmit protocol of the Seika v3/5/80.
There was a problem hiding this comment.
Can you add this as a comment to the source code please.
There was a problem hiding this comment.
s40 as a property name doesn't make much sense when it applies both to seika80 and 40.
Please rename to sendHeader based on the comment on line 105:
# every transmitted line consists of the preamble SEIKA_SENDHEADER and the Cells
Looking at this again, I have realized what this encodes:
- Two bytes of
b'\xFF' - The code for the display
b"s80" - Null characters until the length is 8.
Note, this value:
>>> b"\xff\xff\x73\x38\x30\x00\x00\x00"
b'\xff\xffs80\x00\x00\x00'
>>> "s80".encode() == b"\x73\x38\x30"
TrueThen from the later value where s40 is defined for 40 cell v3, v5.
>>> b"\xFF\xFF\x73\x65\x69\x6B\x61\x00"
b'\xff\xffseika\x00'
>>> b'\x73\x65\x69\x6B\x61' == b'seika'
TrueIt would be way clearer if these could be constructed:
def createDeviceVersionHandshake(deviceVersion:bytes)->bytes:
""" Creates an 8 byte string containing the device version appropriately formatted for the handshake.
if 5 < len(deviceVersion) < 1:
raise ArgumentError("At least one character must be supplied. Only space in handshake for a total of 8 bytes. Requires 2 Leading 0xFF chars, and one trailing 0x0 char")
totalChars = 8
prefixChars = b"\xFF" * 2
trailingChars = b"\x00" * (totalChars - len(prefixChars) - len(deviceVersion))
return = prefixChars + deviceVersion + trailingChars Then here you can do something like:
| self.s40 = b"\xff\xff\x73\x38\x30\x00\x00\x00" | |
| self.sendHeader= createDeviceVersionHandshake(b's80') | |
And a bit further down for the v3, v5:
self.sendHeader=createDeviceVersionHandshake(b'seika')There was a problem hiding this comment.
We have understood how to construct these headers, and what they encode. I would like this to be more obvious in the code.
Please add the following function:
def createDeviceVersionHandshake(deviceVersion:bytes)->bytes:
""" Creates an 8 byte string containing the device version appropriately formatted for the handshake.
if 5 < len(deviceVersion) < 1:
raise ArgumentError(
"At least one character must be supplied."
" Only space in handshake for a total of 8 bytes."
" Requires 2 Leading 0xFF chars, and one trailing 0x0 char"
)
totalChars = 8
prefixChars = b"\xFF" * 2
data = prefixChars + deviceVersion
# pad to required length
data = data.ljust(totalChars, b'\x00')
return dataThen where b"\xff\xff\x73\x38\x30\x00\x00\x00" is used change to s80Header = createDeviceVersionHandshake(b"s80")
and where b"\xFF\xFF\x73\x65\x69\x6B\x61\x00" is used change to seikaHeader = createDeviceVersionHandshake(b"seika")
| if versionS.startswith(b"seika80"): | ||
| log.info("Found Seika80 connected via {port} Version {versionS}".format(port=port, versionS=versionS)) | ||
| self.numCells = 80 | ||
| self.s40 = b"\xff\xff\x73\x38\x30\x00\x00\x00" |
There was a problem hiding this comment.
Can you add this as a comment to the source code please.
|
@moyanming, |
| if versionS.startswith(b"seika80"): | ||
| log.info("Found Seika80 connected via {port} Version {versionS}".format(port=port, versionS=versionS)) | ||
| self.numCells = 80 | ||
| self.s40 = b"\xff\xff\x73\x38\x30\x00\x00\x00" |
There was a problem hiding this comment.
s40 as a property name doesn't make much sense when it applies both to seika80 and 40.
Please rename to sendHeader based on the comment on line 105:
# every transmitted line consists of the preamble SEIKA_SENDHEADER and the Cells
Looking at this again, I have realized what this encodes:
- Two bytes of
b'\xFF' - The code for the display
b"s80" - Null characters until the length is 8.
Note, this value:
>>> b"\xff\xff\x73\x38\x30\x00\x00\x00"
b'\xff\xffs80\x00\x00\x00'
>>> "s80".encode() == b"\x73\x38\x30"
TrueThen from the later value where s40 is defined for 40 cell v3, v5.
>>> b"\xFF\xFF\x73\x65\x69\x6B\x61\x00"
b'\xff\xffseika\x00'
>>> b'\x73\x65\x69\x6B\x61' == b'seika'
TrueIt would be way clearer if these could be constructed:
def createDeviceVersionHandshake(deviceVersion:bytes)->bytes:
""" Creates an 8 byte string containing the device version appropriately formatted for the handshake.
if 5 < len(deviceVersion) < 1:
raise ArgumentError("At least one character must be supplied. Only space in handshake for a total of 8 bytes. Requires 2 Leading 0xFF chars, and one trailing 0x0 char")
totalChars = 8
prefixChars = b"\xFF" * 2
trailingChars = b"\x00" * (totalChars - len(prefixChars) - len(deviceVersion))
return = prefixChars + deviceVersion + trailingChars Then here you can do something like:
| self.s40 = b"\xff\xff\x73\x38\x30\x00\x00\x00" | |
| self.sendHeader= createDeviceVersionHandshake(b's80') | |
And a bit further down for the v3, v5:
self.sendHeader=createDeviceVersionHandshake(b'seika')|
@moyanming just a reminder, if you'd be so kind to follow up on the remaining things to fix on this PR? Thanks. |
|
Hello, best regards, ulf |
See test results for failed build of commit ee9926a8db |
|
hello |
There was a problem hiding this comment.
Aside from failing Linter checks and my comments it looks like most changes requested by @feerrenrut were just marked as resolved but no changes to the source code were made. Please address these.
|
Given the time this is taking, would you like me to make the changes I suggest directly? |
Hi @feerrenrut , |
Hi @feerrenrut , |
Hi @cary-rowen BTW, Mini16/24 and V6 (40-cells) are kind of Seika Notetaker, please chose the Seika Notetaker within the NVDA. |
|
@moyanming Can you confirm this driver is working? I'd like to get this reviewed and merged. |
Hi @feerrenrut , |
Since I'm a contributor now, I shouldn't be a reviewer.
|
I'm aware, thanks @dingpengyu. It is just the changes file, I'll get these changes reviewed, then I'll resolve conflicts in the changes file before merging. |
|
Sorry for the late report. @moyanming, could you please confirm if the CP210x USB to UART Bridge Driver is required or not to use the Seika Displays driver as of this PR? |
Hi @JulienCochuyt |
|
@feerrenrut @michaelDCurran May I ask when this is going to be looked at? As it stands people who've purchased this display cannot use it with NVDA for year and a half now. People are complaining about support for Seika displays on users list from time to time and this seems to be ready aside from being reviewed. |
|
|
The other is Seika Notetaker. I also tested it. I think this is an important feature. It will affect those NVDA users who use Seika. Does anyone care about this PR? |
Hi, @feerrenrut |
michaelDCurran
left a comment
There was a problem hiding this comment.
Looks okay to me, including @seanbudd 's suggestions.
|
@moyanming Can you change this? |
|
@cary-rowen, No NV Access is addressing the items on this PR now. |
Co-authored-by: Sean Budd <seanbudd123@gmail.com>
Update the seika.py by using the Python v3. Have well tested with Seika v3/5/80 devices.
Refer to issue #10787
Link to issue number:
#10787
Summary of the issue:
Seika Braille Display can't be loaded in NVDA 2019.3
Description of how this pull request fixes the issue:
Update the seika.py by using the Python v3.
Testing performed:
Have well tested with the Seika v3/5/80 devices by the manufacturer of the Seika device. The Seika v3/5/80 can be connected automatically after selected.
Known issues with pull request:
None.
Change log entry:
Section: New features, Changes, Bug fixes
Bug fixes.