OpenHantek / OpenHantek6022

OpenHantek6022 is a DSO software for Hantek USB digital signal oscilloscopes 6022BE / BL. Development OS is Debian Linux, but the program also works on FreeBSD, MacOS, RaspberryPi and Windows. No support for non-Linux related issues unless a volunteer steps in!
GNU General Public License v3.0
867 stars 152 forks source link

Windows 10 cyrillic username problem #175

Closed rkurbatov closed 3 years ago

rkurbatov commented 3 years ago

Describe the bug The program cannot upload firmware to the device if the user home folder in Windows 10 contains cyrillic symbols.

To Reproduce I tried several drivers without success. As I'm using the Far Manager (good old Linux habit) I saw the warning message in console, it could not open some file in C:\Users\some-strange-symbols\Temp\OpenHantek.someId folder.

When I managed to rename my user folder so it did not contain cyrillic letters the problem disappeared.

Not sure if you can fix it easily for Windows but it least it could help and save some time for other people with non latin letters usernames.

Ho-Ro commented 3 years ago

Strange - OH uses a normal Qt function to create a temporary file from the firmware resource in QDir::tempPath() (on Windows this is usually the path in the TEMP or TMP environment variable): temp_firmware_path = std::unique_ptr< QTemporaryFile >( QTemporaryFile::createNativeFile( firmwareRes ) ); and converts this file name to const char *path = temp_firmware_path->fileName().toUtf8().constData() that is transferred to fopen(). You could try to change %TEMP% or %TMP% to something else where you have write access, e.g. c:\temp.

@spam-receiver: Did you encounter this kind of problem

cryptozoy commented 3 years ago

I confirm the bug. If the Windows 10 username is in Cyrillic, then the oscilloscope is not visible. The program offers to start demo mode. But when firmware was loaded in Latin name user account, then there is no need to load firmware and program starts normally. I often faced such problems with various programs, so, just in case, I become to use the username in Latin, both in Windows and Linux.

Ho-Ro commented 3 years ago

Hello, friends of Cyrillic symbols, please check this test build. If it does not help, you could try to set %TEMP% and %TMP% to e.g. C:\Windows\Temp instead of the default C:\Users\xxx\AppData\Local\Temp.

Vascom commented 3 years ago

Linux users need not worry?

Ho-Ro commented 3 years ago

No, because OH uses different locations for the temp file on Windows and Linux. OpenHantek6022 takes the Qt standard function QTemporaryFile::createNativeFile() to access the firmware from the program resources via a temporary file in QDir::tempPath():

EDIT: The issue was (probably) caused by the conversion from QString fileName -> const char *path, for Linux this is done by fileName.toUtf8().data(), because UTF8 is standard for all localisations. Under Windows the situation is different, they use multiple "code pages", so I had to replace toUtf8() by toLocal8Bit(), that fits also for Linux because UTF8 is the local 8bit encoding :)

@Vascom: I did a quick check on my Debian with a disconnected/connected scope:

cd; mkdir Михаи́л_Васи́льевич_Ломоно́сов
TMPDIR=/home/horo/Михаи́л_Васи́льевич_Ломоно́сов ./OpenHantek

Works fine, same for

cd; mkdir Ἀρχιμήδης_ὁ_Συρακούσιος
TMPDIR=/home/horo/Ἀρχιμήδης_ὁ_Συρακούσιος ./OpenHantek

HTH

cryptozoy commented 3 years ago

OpenHantek-Win-x64-Release-b539.zip works normally.

Ho-Ro commented 3 years ago

... works normally.

"normally" - hopefully in the sense of "as expected" and not in the sense of "as before". :) Thank you for your support, I will wait for @rkurbatov's "OK" before closing this issue.

Ho-Ro commented 3 years ago

It is available in unstable for testing. If I do not receive failure reports I will close this issue after Easter.

rkurbatov commented 3 years ago

Wow, that was really quick.

Sorry, I'm using Linux normally, but attached this box to my old spare Windows desktop (just in case, you know). It works normally now. I checked on Administrator account (that is Администратор on my machine) - old version searches for device, b539 just runs normally. Thanks!

Ho-Ro commented 3 years ago

Roman, thx for reporting this sleeping issue. This project lives from user feedback.