school510587 / MetecBD-driver

The driver addon for MetecBD (光點) compatible with NVDA versions 2017.3 and later.
GNU General Public License v2.0
0 stars 0 forks source link

Make add-on compatible with the latest NVDA #2

Open cary-rowen opened 1 month ago

cary-rowen commented 1 month ago

Hi @school510587

Will you upgrade this add-on to be compatible with NVDA2024.4 or even 2025.1?

school510587 commented 1 month ago

Hi @cary-rowen,

Sorry, I don't have any computer with MetecBD driver installed, which is hard to be accomplished without sight.

You may do the following steps to help me update the addon:

  1. Find a computer with MetecBD driver installed, e.g. your own computer.
  2. Install the addon on NVDA 2020.3 in the computer. You can use a portable version for convenience.
  3. Open the user settings directory, and edit addons\MetecBD\manifest.ini by notepad.
  4. Modify its lastTestedNVDAVersion to the recent available version, e.g. 2024.4.
  5. Update the (portable) NVDA to the recent available version.
  6. Tell me whether the addon works. Show me the error log if it does not work.

Thanks.

cary-rowen commented 1 month ago

Hi After upgrading to the latest version of NVDA, the way of loading DLL seems to have changed a little. I made some changes. But still getting the error, I haven't looked into it carefully yet!

IO - braille.BrailleBuffer.update (19:20:47.528) - MainThread (4360):
Braille regions text: ['日志片段开始点已标记,再按一次复制到剪贴板']
IO - braille.BrailleHandler.update (19:20:47.528) - MainThread (4360):
Braille window dots: 
IO - speech.speech.speak (19:20:47.528) - MainThread (4360):
Speaking ['日志片段开始点已标记,再按一次复制到剪贴板']
IO - inputCore.InputManager.executeGesture (19:20:48.300) - winInputHook (9120):
Input: kb(laptop):enter
DEBUG - autoSettingsUtils.autoSettings.AutoSettings._registerConfigSaveAction (19:20:48.300) - MainThread (4360):
registering pre_configSave action: <class 'brailleDisplayDrivers.MetecBD.BrailleDisplayDriver'>
ERROR - braille.BrailleHandler.setDisplayByName (19:20:51.490) - MainThread (4360):
Error initializing display driver 'MetecBD'
Traceback (most recent call last):
  File "braille.pyc", line 2304, in setDisplayByName
  File "braille.pyc", line 2371, in _setDisplay
  File "braille.pyc", line 2341, in _switchDisplay
  File "extensionPoints\util.pyc", line 216, in callWithSupportedKwargs
  File "C:\Users\Administrator\AppData\Roaming\nvda\addons\MetecBD\brailleDisplayDrivers\MetecBD.py", line 180, in __init__
    raise RuntimeError("No MetecBD found")
RuntimeError: No MetecBD found
IO - braille.BrailleBuffer.update (19:20:51.571) - MainThread (4360):
Braille regions text: ['点显器错误 对话框 无法加载 MetecBD 显示。']
IO - braille.BrailleHandler.update (19:20:51.571) - MainThread (4360):
Braille window dots: 
IO - speech.speech.speak (19:20:51.571) - MainThread (4360):
Speaking ['点显器错误', '对话框', '无法加载 MetecBD 显示。', CancellableSpeech (still valid)]
IO - braille.BrailleBuffer.update (19:20:51.576) - MainThread (4360):
Braille regions text: ['点显器错误 对话框 无法加载 MetecBD 显示。', ' 确认 按钮']
IO - braille.BrailleHandler.update (19:20:51.576) - MainThread (4360):
Braille window dots: 
IO - speech.speech.speak (19:20:51.576) - MainThread (4360):
Speaking ['确认', '按钮', CancellableSpeech (still valid)]
IO - inputCore.InputManager.executeGesture (19:20:52.302) - winInputHook (9120):
Input: kb(laptop):enter
IO - braille.BrailleBuffer.update (19:20:52.363) - MainThread (4360):
Braille regions text: ['选择盲文点显器 对话框']
IO - braille.BrailleHandler.update (19:20:52.363) - MainThread (4360):
Braille window dots: 
IO - speech.speech.speak (19:20:52.363) - MainThread (4360):
Speaking ['选择盲文点显器', '对话框', CancellableSpeech (still valid)]
IO - braille.BrailleBuffer.update (19:20:52.363) - MainThread (4360):
Braille regions text: ['选择盲文点显器 对话框', ' 点显器(D): 组合框 METEC USP Devices 已折叠 Alt+d']
IO - braille.BrailleHandler.update (19:20:52.363) - MainThread (4360):
Braille window dots: 
IO - speech.speech.speak (19:20:52.363) - MainThread (4360):
Speaking ['点显器(D):', '组合框', 'METEC USP Devices', '已折叠', 'Alt+d', CancellableSpeech (still valid)]
DEBUGWARNING - IAccessibleHandler.internalWinEventHandler._shouldGetEvents (19:20:52.637) - MainThread (4360):
Foreground took too long to change. Foreground still 6227040 (#32770). Should be 721898 (CherryWindowClass)
DEBUG - speech.manager.SpeechManager._handleIndex (19:20:53.013) - MainThread (4360):
Unknown index 69, speech probably cancelled from main thread.
IO - inputCore.InputManager.executeGesture (19:20:53.237) - winInputHook (9120):
Input: kb(laptop):NVDA+shift+control+f1
cary-rowen commented 1 month ago

Here is the code block I changed:

DLL_NAME = "MetecBD.dll"
path = os.environ.get('PATH')
currentPath = os.path.dirname(__file__)
if currentPath not in path.split(os.pathsep):
    os.environ['PATH'] = os.pathsep.join([path, currentPath])
dllPath = os.path.join(currentPath, DLL_NAME)

try:
    MetecBD = cdll.LoadLibrary(dllPath)
except:
    MetecBD = None
    log.error("LoadLibrary failed " + dllPath)
school510587 commented 1 month ago

Hi @cary-rowen,

Could you give me the initial error log before any modification, please?

Line 180 is not raise RuntimeError("No MetecBD found") in the original MetecBD.py.

Furthermore, from your current log, the error is caused by the improper returned value of a dll function BrdInitDevice.

I cannot determine the reason of the error. Could you find the FIRST NVDA version where the error appears?

cary-rowen commented 1 month ago

Hi @school510587

Here is the original error log, I managed to capture it: I reproduced the error below using NVDA-2024.4rc1 and using the latest master code from the repo.

log``` ERROR - external:brailleDisplayDrivers.MetecBD (23:52:32.100) - MainThread (22252): LoadLibrary failed MetecBD.dll ERROR - braille.getDisplayDrivers (23:52:32.100) - MainThread (22252): Error while importing braille display driver MetecBD Traceback (most recent call last): File "braille.pyc", line 3674, in getDisplayDrivers File "braille.pyc", line 462, in _getDisplayDriver File "importlib__init__.pyc", line 126, in import_module File "", line 1204, in _gcd_import File "", line 1176, in _find_and_load File "", line 1147, in _find_and_load_unlocked File "", line 690, in _load_unlocked File "", line 940, in exec_module File "", line 241, in _call_with_frames_removed File "C:\Users\cary\AppData\Roaming\nvda\addons\MetecBD\brailleDisplayDrivers\MetecBD.py", line 76, in MetecBD = cdll.LoadLibrary(DLL_NAME) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "ctypes__init.pyc", line 454, in LoadLibrary File "ctypes\init.pyc", line 376, in init__ FileNotFoundError: Could not find module 'MetecBD.dll' (or one of its dependencies). Try using the full path with constructor syntax.

school510587 commented 1 month ago

Hi @cary-rowen,

OK, I have modified the code according to its opinion: the full path with constructor syntax.

Please try whether you can reproduce the previous RuntimeError with the latest NVDA.

If yes, could you try earlier NVDA, e.g. 2021.1 and 2022.1, to find the first version that produces the RuntimeError?

cary-rowen commented 1 month ago

I will test it out later and provide further feedback.

cary-rowen commented 1 month ago

Hi @school510587

I used the latest master branch for testing and still received the following error. I used 2024.4rc1 and 2021.3.5 and it seemed that the errors I encountered were no different.

IO - speech.speech.speak (19:58:08.444) - MainThread (3492):
Speaking [LangChangeCommand ('zh_CN'), '日志片段开始点已标记,再按一次复制到剪贴板']
IO - inputCore.InputManager.executeGesture (19:58:09.033) - winInputHook (12128):
Input: kb(desktop):enter
DEBUG - autoSettingsUtils.autoSettings.AutoSettings._registerConfigSaveAction (19:58:09.043) - MainThread (3492):
registering pre_configSave action: <class 'brailleDisplayDrivers.MetecBD.BrailleDisplayDriver'>
ERROR - braille.BrailleHandler.setDisplayByName (19:58:12.194) - MainThread (3492):
Error initializing display driver 'MetecBD'
Traceback (most recent call last):
  File "braille.pyc", line 2304, in setDisplayByName
  File "braille.pyc", line 2371, in _setDisplay
  File "braille.pyc", line 2341, in _switchDisplay
  File "extensionPoints\util.pyc", line 216, in callWithSupportedKwargs
  File "C:\Users\Lenovo\AppData\Roaming\nvda\addons\MetecBD\brailleDisplayDrivers\MetecBD.py", line 177, in __init__
    raise RuntimeError("No MetecBD found")
RuntimeError: No MetecBD found
IO - speech.speech.speak (19:58:12.246) - MainThread (3492):
Speaking [LangChangeCommand ('zh_CN'), '点显器错误', '对话框', '无法加载 MetecBD 显示。', CancellableSpeech (still valid)]
IO - speech.speech.speak (19:58:12.247) - MainThread (3492):
Speaking [LangChangeCommand ('zh_CN'), '确认', '按钮', CancellableSpeech (still valid)]
IO - inputCore.InputManager.executeGesture (19:58:13.623) - winInputHook (12128):
Input: kb(desktop):enter
IO - speech.speech.speak (19:58:13.660) - MainThread (3492):
Speaking [LangChangeCommand ('zh_CN'), '选择盲文点显器', '对话框', CancellableSpeech (still valid)]
IO - speech.speech.speak (19:58:13.661) - MainThread (3492):
Speaking [LangChangeCommand ('zh_CN'), '点显器(D):', '组合框', 'METEC USP Devices', '已折叠', 'Alt+', CharacterModeCommand(True), 'd', CharacterModeCommand(False), CancellableSpeech (still valid)]
IO - inputCore.InputManager.executeGesture (19:58:14.399) - winInputHook (12128):
Input: kb(desktop):NVDA+shift+control+f1
school510587 commented 1 month ago

Hi @cary-rowen,

Could you get the string from 3 NVDA versions: 2020.3, 2020.4, and 2021.1? Using the latest master uploaded at 11:30pm, there should be one more information in the report. For example, self._BrdDeviceNr.value = 0, self._BrdDeviceTyp.value = 1.

Thanks.

cary-rowen commented 1 month ago

Hi below is the complete log I captured according to your instructions:

2021.1.txt 2020.3.txt 2020.4.txt

school510587 commented 1 month ago

Hi @cary-rowen,

I find RuntimeError: No MetecBD found in all of the 3 versions, and the reason is the same, failure of MetecBD.BrdInitDevice. Has the driver ever successfully executed on this computer before? If yes, what is the last NVDA version then? Otherwise, i doubt that the actual driver program does not work on Windows successfully.

cary-rowen commented 1 month ago

Hi @school510587

I guess the driver never executed successfully on this machine. I don't know if this has anything to do with Windows 11. I'd love to find a machine that actually does the metec driver to get more information.

Since we don't have the source code of MetecBD.dll, it may be difficult for us to debug further in this case.

school510587 commented 1 month ago

Hi @cary-rowen,

Is it possible to install and run CKBS (晴光) successfully on your machine? If the driver works, CKBS will have normal braille functions. An alternative is to borrow a notebook with CKBS installed on Windows 11 from TKU.

Considering only the purpose to update the add-on, a computer with the latest NVDA and working Metec driver is enough, regardless of the OS.