Skip to content

Update seika braille driver for python 3#10961

Merged
feerrenrut merged 14 commits into
nvaccess:betafrom
moyanming:master
Jun 3, 2021
Merged

Update seika braille driver for python 3#10961
feerrenrut merged 14 commits into
nvaccess:betafrom
moyanming:master

Conversation

@moyanming

Copy link
Copy Markdown
Contributor

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.

Update the seika.py by using the Python v3. Have well tested with Seika v3/5/80 devices.
@AppVeyorBot

Copy link
Copy Markdown

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
@feerrenrut

Copy link
Copy Markdown
Contributor

Thanks @moyanming. Since it seems that the intention of this PR to replace #9479, I'll close that PR and communication can continue here.

Comment thread source/brailleDisplayDrivers/seika.py Outdated
Comment thread source/brailleDisplayDrivers/seika.py Outdated
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"

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.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

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.

Can you add this as a comment to the source code please.

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.

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"
True

Then 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'
True

It 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:

Suggested change
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')

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.

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 data

Then 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")

Comment thread source/brailleDisplayDrivers/seika.py Outdated
Comment thread source/brailleDisplayDrivers/seika.py Outdated
@moyanming moyanming requested a review from feerrenrut April 8, 2020 15:27
Comment thread source/brailleDisplayDrivers/seika.py Outdated
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"

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.

Can you add this as a comment to the source code please.

Comment thread source/brailleDisplayDrivers/seika.py Outdated
Comment thread source/brailleDisplayDrivers/seika.py Outdated
@JulienCochuyt

Copy link
Copy Markdown
Contributor

@moyanming,
Could you please address the remaining requested changes on this PR?
We're receiving more and more complaints from our customers of these devices, disappointed to have support dropped for three versions of NVDA now (2019.3, 2019.3.1, 2020.1)

Comment thread source/brailleDisplayDrivers/seika.py Outdated
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"

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.

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"
True

Then 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'
True

It 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:

Suggested change
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')

@Adriani90

Copy link
Copy Markdown
Collaborator

@moyanming just a reminder, if you'd be so kind to follow up on the remaining things to fix on this PR? Thanks.

@Ulf-Beckmann

Copy link
Copy Markdown
Contributor

Hello,
I am unsure whether I have understood the GitHub system correctly and I am even more unsure about the news about the Python3 and Seika customization. Therefore, here again the two current drivers for the Seika Braille displays and the Seika Notetaker.
I deliberately didn't put both of them in one file, which would certainly make sense, but I had to struggle enough with the changes. Unfortunately I have not found any further specifications for adaptation. When studying the other drivers, however, I noticed that some (e.g. hedo) do not work with Python3. But that's a different matter.

best regards, ulf

seika.py.zip
seikantk.py.zip

@AppVeyorBot

Copy link
Copy Markdown

See test results for failed build of commit ee9926a8db

@dpy013

dpy013 commented Nov 12, 2020

Copy link
Copy Markdown
Contributor

hello
@moyanming
Please fix the flake8 error.
thanks

@lukaszgo1 lukaszgo1 left a comment

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.

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.

Comment thread source/brailleDisplayDrivers/seika.py Outdated
Comment thread source/brailleDisplayDrivers/seika.py Outdated
Comment thread source/brailleDisplayDrivers/seika.py Outdated
Comment thread source/brailleDisplayDrivers/seika.py Outdated
Comment thread source/brailleDisplayDrivers/seika.py Outdated
Comment thread source/brailleDisplayDrivers/seika.py Outdated
Comment thread source/brailleDisplayDrivers/seika.py Outdated
@moyanming moyanming requested a review from feerrenrut January 11, 2021 14:06

@moyanming moyanming left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

have checked

Comment thread source/brailleDisplayDrivers/seika.py Outdated
@feerrenrut

Copy link
Copy Markdown
Contributor

Given the time this is taking, would you like me to make the changes I suggest directly?

@moyanming

Copy link
Copy Markdown
Contributor Author

Given the time this is taking, would you like me to make the changes I suggest directly?

Hi @feerrenrut ,
Yes, please make the change directly.
I am sorry for not familiar with GitHub.

@moyanming moyanming closed this Mar 31, 2021
@moyanming

Copy link
Copy Markdown
Contributor Author

Given the time this is taking, would you like me to make the changes I suggest directly?

Hi @feerrenrut ,
Yes, please make the change directly.
I am sorry for not familiar with GitHub.

Hi @feerrenrut ,
Is there new information about this PR?
Any questions please let me know.
Best Regards

@moyanming

Copy link
Copy Markdown
Contributor Author

I use "Seika Notetaker Mini24" to test and select "Seika" in the list. It can't be used at all.
@moyanming Does the PR support the device?

Hi @cary-rowen
Please test this PR build for Seika Notetaker Mini24.

BTW, Mini16/24 and V6 (40-cells) are kind of Seika Notetaker, please chose the Seika Notetaker within the NVDA.

@feerrenrut feerrenrut self-assigned this Apr 8, 2021
@feerrenrut

Copy link
Copy Markdown
Contributor

@moyanming Can you confirm this driver is working? I'd like to get this reviewed and merged.

@moyanming

Copy link
Copy Markdown
Contributor Author

@moyanming Can you confirm this driver is working? I'd like to get this reviewed and merged.

Hi @feerrenrut ,
We have tested Seika v3/5/80 Braille display with the PR build and all work fine.
The code is ready for merge now.

@feerrenrut feerrenrut dismissed their stale review April 9, 2021 07:36

Since I'm a contributor now, I shouldn't be a reviewer.

@feerrenrut

Copy link
Copy Markdown
Contributor

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.

@JulienCochuyt

Copy link
Copy Markdown
Contributor

Sorry for the late report.
Everything seems good here with a Seika v5.

@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?
Long story short, we've recently faced some broken installation of this CP210x USB to UART Bridge Driver after updating to Windows 10 20H2 19042.928. Reinstalling this bridge driver fixed the issue and allows again to use the Seika Displays driver that we ship as an extension to NVDA 2019.3 > 2020.4, and we'd like to be sure on what to communicate to the users regarding the future release.

@moyanming

Copy link
Copy Markdown
Contributor Author

Sorry for the late report.
Everything seems good here with a Seika v5.

@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?
Long story short, we've recently faced some broken installation of this CP210x USB to UART Bridge Driver after updating to Windows 10 20H2 19042.928. Reinstalling this bridge driver fixed the issue and allows again to use the Seika Displays driver that we ship as an extension to NVDA 2019.3 > 2020.4, and we'd like to be sure on what to communicate to the users regarding the future release.

Hi @JulienCochuyt
The Seika v5, and Seika v3/v80, need the CP210x driver insalled.
It seems that the updating of Windows 10 OS broken/deleted the CP210x driver, please reinstall the CP210x driver to fix it.

@lukaszgo1

Copy link
Copy Markdown
Contributor

@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.

@cary-rowen

Copy link
Copy Markdown
Contributor
 I have manually tested the build of this PR and it works as expected. Why can't we resolve the conflict as soon as possible to integrate it into NVDA as soon as possible?

@cary-rowen

Copy link
Copy Markdown
Contributor

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?

@moyanming

Copy link
Copy Markdown
Contributor Author

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.

Hi, @feerrenrut
I think it's time to merge this PR now.
If there need my work on this PR please let me know.
Thank you for your great work.

@seanbudd seanbudd changed the title Update the seika.py by using the Python v3 Update seika braille driver for python 3 Jun 3, 2021
@feerrenrut feerrenrut changed the base branch from master to beta June 3, 2021 03:21
@feerrenrut feerrenrut requested a review from a team as a code owner June 3, 2021 03:21
Comment thread source/brailleDisplayDrivers/seika.py Outdated
Comment thread source/brailleDisplayDrivers/seika.py Outdated
Comment thread source/brailleDisplayDrivers/seika.py Outdated
Comment thread source/brailleDisplayDrivers/seika.py Outdated
Comment thread source/brailleDisplayDrivers/seika.py Outdated
michaelDCurran
michaelDCurran previously approved these changes Jun 3, 2021

@michaelDCurran michaelDCurran left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks okay to me, including @seanbudd 's suggestions.

@cary-rowen

Copy link
Copy Markdown
Contributor

@moyanming Can you change this?
Thanks.

@feerrenrut

Copy link
Copy Markdown
Contributor

@cary-rowen, No NV Access is addressing the items on this PR now.

feerrenrut and others added 2 commits June 3, 2021 14:43
Co-authored-by: Sean Budd <seanbudd123@gmail.com>
@feerrenrut feerrenrut merged commit ed0f900 into nvaccess:beta Jun 3, 2021
@nvaccessAuto nvaccessAuto added this to the 2021.2 milestone Jun 3, 2021
@seanbudd seanbudd modified the milestones: 2021.2, 2021.1 Jun 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.