Open dcbo opened 4 months ago
Hi,
the message bug is corrected now, fixed in 2.1.1-alfa, thanks for reporting!
BTW: correct formatting is "field '%s' is missing" % name
or "field '%s' is missing" % (name,)
not "field '%s' is missing" % (name)
.
You don't need pyinstaller for debug, that's just for release for other people.
You don't use pyinstallers build/
directory, you use dist/
directory instead. build/
contains just pieces, dist/
contains assembled binaries.
You don't need NSIS either, that's for generating installer for other people.
You don't use mc3000usb.py directly to launch the GUI. You shall use "gui.py" to launch the GUI. The mc3000usb.py run action is used for testing of mc3000usb.py communication alone not for testing the app itself.
So python gui.py profiles
is the thing to start the profiles app form python directly.
Don't forget to install python dependencies from requirements.txt
.
If you get Loading... forever then app crashed in background, check internal browser console and also the console output of python - there should be some error message explaining what crashed. There is also info.log
file located in C:\Users\YOUR_USERNAME\AppData\Local\mc3000ble\log
directory, that's handy if you don't have access to python console. Debugging is best done via python directly, don't try to use pyinstaller binary before python alone works that just complicates things.
that was quick.
Now I am a bit further, as i get the error:
Unexpected error occurred: field 'id' is missing
But the Field id
is part of the json file, so I don't know how to fix the error.
I am not able to save and reload a json file.
Regarding the running from source problem After
pip install -r requirements.txt
python gui.py profiles
# or
python gui.py
An empty Gui Window (normal or profiles size) is firered up but I get the following Error-Message and the only move is to close the gui.
2024-02-16 12:53:56,468 - INFO - starting
* Serving Flask app 'gui'
* Debug mode: off
[pywebview] WebView2 initialization failed with exception:
Unable to load DLL 'WebView2Loader.dll' or one of its dependencies: Das angegebene Modul wurde nicht gefunden (0x800700
7E)
bei Microsoft.Web.WebView2.Core.CoreWebView2Environment.LoadWebView2LoaderDll()
bei Microsoft.Web.WebView2.Core.CoreWebView2Environment.<CreateAsync>d__3.MoveNext()
--- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde ---
bei System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
bei Microsoft.Web.WebView2.WinForms.WebView2.<InitCoreWebView2Async>d__24.MoveNext()
2024-02-16 12:53:56,979 - ERROR - pywebview: WebView2 initialization failed with exception:
Unable to load DLL 'WebView2Loader.dll' or one of its dependencies: Das angegebene Modul wurde nicht gefunden (0x800700
7E)
bei Microsoft.Web.WebView2.Core.CoreWebView2Environment.LoadWebView2LoaderDll()
bei Microsoft.Web.WebView2.Core.CoreWebView2Environment.<CreateAsync>d__3.MoveNext()
--- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde ---
bei System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
bei Microsoft.Web.WebView2.WinForms.WebView2.<InitCoreWebView2Async>d__24.MoveNext()
I see the JSON import is plain broken now, my bad, there was typo in in
versus not in
... Fixed in 2.1.2-alfa., Well it's alpha for a reason I guess. I was testing import many times but then changed export and then didn't test import again.
I was able to download a WebView2Loader.dll
Now I am able to start from source,
But Load current profiles from charger
gives me the Error:
Charger not found, make sure you charger is connected via USB
and no further Message in the Console.
Even if i start python gui.py profiles
with administrative rights.
But now I am able to load a previously generated JSON file. I get this Error on the console:
2024-02-16 13:02:10,804 - INFO - starting
* Serving Flask app 'gui'
* Debug mode: off
2024-02-16 13:02:29,661 - ERROR - field 'id' is missing
Traceback (most recent call last):
File "C:\Users\vandusen\Desktop\mc3000\skyrc-mc3000-2.1.1-alfa\profiles.py", line 150, in handle_import
profile.from_json(file.read())
File "C:\Users\vandusen\Desktop\mc3000\skyrc-mc3000-2.1.1-alfa\mc3000usb.py", line 165, in from_json
raise JsonException("field '%s' is missing" % name)
mc3000usb.JsonException: field 'id' is missing
Here is the JSON file which i was trying to load:
{
"slot_number": 0,
"busy_tag": 0,
"battery_type": 0,
"operation_mode": 1,
"capacity": 3600,
"charge_current": 1700,
"discharge_current": 680,
"discharge_cut_voltage": 2500,
"charge_end_voltage": 4200,
"charge_end_current": 50,
"discharge_reduce_current": 50,
"number_cycle": 1,
"charge_resting_time": 10,
"cycle_mode": 0,
"peak_sense_voltage": 3,
"trickle_current": 0,
"restart_voltage": 4100,
"cut_temperature": 45,
"cut_time": 0,
"temperature_unit": 0,
"trickle_time": 0,
"discharge_resting_time": 10,
"id": "5136599d-6902-4c91-960c-3fc933d1ea64",
"name": "Makita"
}
Charger not found, make sure you charger is connected via USB
means charger was not found via VID 0x0000 PID 0x0001, admin rights aren't required and will not help anything.
Do you see your charger in the Device manager in Windows? What Hardware ID has your charger in the Device manager in Windows? You can see Hardware ID in details of given device in Device manager, there is dropdown where Hardware ID is available.
Save
it is gone.I don't find the Device in the Device manager. If i disconnect/connect the List is rebuilt in the Device manager, but I am not able to find the Charger. In which branch do I have to look?
I found it under Human Interface Devices:
HID\VID_0000&PID_0001\6&BC24EF&0&0000
HID\VID_0000&PID_0001&REV_0200
HID_DEVICE_UP:0001_U:0000
BTW: Bluetooth works.
Import is fixed at last, tested and it works completely finally.
Hardware ID is ok, VID 0000 PID 0001 and you still see charger not found?
yes
Have to leave, will anwer l8er.
Try to use the executable release version, not sure if python doesn't miss some dependencies.
I tested release version on clean Windows and it worked so I guess there is some dll missing and that's why USB doesn't work, not sure why usb library doesn't throw error but it's possible that no backend reports as no device found. Go to install directory of release version and copy _internal/libusb-1.0.dll
to your path or current working directory and then even python should work I assume.
Thank you for testing!
There is no libusb-1.0.dll in any directory.
Are you sure? If you install mc3000ble-install.exe
then you should get it. By default install location is C:\Program Files\mc3000ble\_internal
where libusb-1.0.dll
is. I tried latest installer and I see it so you should too. If indeed it isn't there then the only option left is that something did delete it after install...
Did you try binary version from installer if USB works there?
Yes, I have looked on the source-dir. But still not working if I copy the libusb.
I see. I tried to verify what happen if you don't have libusb at all and this is what I'm getting Unexpected error occurred: No backend available
. So if you get Charger not found, make sure you charger is connected via USB
then libusb is present but for some reason doesn't see USB devices.
Can you try some test script to show how pyusb/libusb does work on your system?
Dependencies:
pip install pyusb libusb-package
The script:
print("libusb naked:")
try:
import usb
counter = 0
for dev in usb.core.find(find_all=True):
counter += 1
print(dev._get_full_descriptor_str())
print("found %s device(s)" % counter)
except Exception as e:
print(e)
print("libusb package:")
try:
import libusb_package
counter = 0
for dev in libusb_package.find(find_all=True):
counter += 1
print(dev._get_full_descriptor_str())
print("found %s device(s)" % counter)
except Exception as e:
print(e)
This should print all libusb compatible USB devices including MC3000 (DEVICE ID 0000:0001
) two times, first time with libusb from your system and second with embedded libusb from pip.
Without any actual error message it's just guessing game. I suspect this could be also because your MC3000 doesn't have driver? Did you use your MC3000 over USB before? This could explain why libusb doesn't see it since it detects only libusb devices not all USB devices. Anyway if your could run the test script and it finds some libusb devices but not MC3000 then you would know that libusb is working just fine and the problem is likely in the driver of MC3000. You could use the official MC3000_Monitor_V1.05 Windows app from SkyRC to verify that the driver is correct - https://www.skyrc.com/MC3000_Charger?from=nav-img#tab-download.
You could try to obtain current libusb-1.0.dll
version from their project page https://github.com/libusb/libusb/releases/. Installer has 1.0.24, the newest is 1.0.27, not sure if that can make difference but you can try.
My System:
When loading a previously saved JSON-File I get this Error:
Unexpected error occurred: field '%s' is missing when loading
I looked in the sourcemc3000usb.py
and found that row 165raise JsonException("field '%s' is missing")
should be changed toraise JsonException("field '%s' is missing" % (name))
But I am not able to compile or run the code.Try to run with:
python mc3000usb.py
gives;Try to compile with:
pyinstaller --noconfirm pyinstaller.spec
I'll findmc3000ble.exe
inbuild\pyinstaller\
but I cannot start itmc3000ble.exe profiles
givesTry to build with:
makensis.exe installer.nsi
did't work because of missingmakensis
I downloaded a graphical tool from nisis.sourceforge.net and usedCompile NSI scripts
this gives me an installer:dist\mc3000ble-install.exe
and the Exe:dist\mc3000ble\mc3000ble.exe
but when i install this or if I start the exe I get e never EndingLoading ...
Animation, either onmc3000ble.exe
ormc3000ble.exe profiles