NangiDev / GDSerCommPlugin

A Godot plugin to read Arduino serial input
MIT License
79 stars 13 forks source link

Can't open dynamic library: C:/Users/Mark/Documents/GDSerCommPlugin-master/addons/GDSerCommDock/bin/GDSercomm.dll, error: Error 126: The specified module could not be found. #8

Closed marpate1 closed 8 months ago

marpate1 commented 4 years ago

On Windows 10, I get the following., from a fresh download of the code from GitHub.

Godot Engine v3.2.2.stable.official (c) 2007-2020 Juan Linietsky, Ariel Manzur & Godot Contributors. --- GDScript language server started --- Can't open dynamic library: C:/Users/Mark/Documents/GDSerCommPlugin-master/addons/GDSerCommDock/bin/GDSercomm.dll, error: Error 126: The specified module could not be found.

. modules/gdnative/gdnative.cpp:483 - No valid library handle, can't get symbol from GDNative object modules/gdnative/nativescript/nativescript.cpp:1506 - No nativescript_init in "res://addons/GDSerCommDock/bin/GDSercomm.dll" found Switch Scene Tab res://addons/GDSerCommDock/MenuLogic.gd:5 - Attempt to call function 'new' in base 'NativeScript' on a null instance.

NangiDev commented 4 years ago

Hi, thanks for using my plugin! Can you verify that the GDSercomm.dll exists in the path on your computer? The file is located correctly in the repo

You could try build the .dll yourself with the instructions inside the README.md

NangiDev commented 4 years ago

There might be some older c++ libraries that is missing in windows 10. I think this might be an issue outside my control. I also found that GDSercomm, that my project is depending on, might be written in old GDNative code. So the init method that the new GDNative is looking for does not exist.

I have been looking into rewriting GDSercomm into my own repository due to the lack of activity in GDSercomm. Same with Sercomm which is a dependency for GDSercomm. It is old, but works. It would be nice to have a more maintained, maybe more modern code base, to rely on.

This takes a lot of time to fix though.

marpate1 commented 4 years ago

Hi, thanks for using my plugin! Can you verify that the GDSercomm.dll exists in the path on your computer? The file is located correctly in the repo

You could try build the .dll yourself with the instructions inside the README.md

Thanks for your prompt reply .... I wasn't expecting this 👍

Yes GDSercomm.dll was in the correct path, although I extracted the project from the ZIP again today and it executes, so I am confused.

I was previously using GDSercomm which works in one of my apps at 9600 baud, but in another app which communicates with a USB dongle with UART, it doesn't work at 115200 baud. Everything seems fine, but no response.

It works under Linux though.

marpate1 commented 4 years ago

There might be some older c++ libraries that is missing in windows 10. I think this might be an issue outside my control. I also found that GDSercomm, that my project is depending on, might be written in old GDNative code. So the init method that the new GDNative is looking for does not exist.

I have been looking into rewriting GDSercomm into my own repository due to the lack of activity in GDSercomm. Same with Sercomm which is a dependency for GDSercomm. It is old, but works. It would be nice to have a more maintained, maybe more modern code base, to rely on.

This takes a lot of time to fix though.

GDSercomm is working, as I say, in one project with Godot 3.2.2. I see the same issue with the plugin so would seem that there is something wrong with libsercomm I guess.

NangiDev commented 4 years ago

Hi, thanks for using my plugin! Can you verify that the GDSercomm.dll exists in the path on your computer? The file is located correctly in the repo You could try build the .dll yourself with the instructions inside the README.md

Thanks for your prompt reply .... I wasn't expecting this +1

Yes GDSercomm.dll was in the correct path, although I extracted the project from the ZIP again today and it executes, so I am confused.

I was previously using GDSercomm which works in one of my apps at 9600 baud, but in another app which communicates with a USB dongle with UART, it doesn't work at 115200 baud. Everything seems fine, but no response.

It works under Linux though.

No problem I see why you wouldnt expect that. Sercomm and GDSercomm are both discontinued repositories and mine isn't that active. I have had many thoughts on how to fix this though. I am not used to c/c++ enough to fix this fast. Could 115200 baud rate be unsupported by sercomm due to newer standard or something similar?

EDIT: https://docs.microsoft.com/en-us/windows/win32/api/winbase/ns-winbase-dcb This seems to be the library used in sercomm. Baudrate seems to be supperted. but this is an win32 lib.

Hmm interesting. I can not get it to work right now. I'm having different issues. I am not very experienced with baudrates and stuff either. Are you not getting any responses from the USB Dongle?

There might be some older c++ libraries that is missing in windows 10. I think this might be an issue outside my control. I also found that GDSercomm, that my project is depending on, might be written in old GDNative code. So the init method that the new GDNative is looking for does not exist. I have been looking into rewriting GDSercomm into my own repository due to the lack of activity in GDSercomm. Same with Sercomm which is a dependency for GDSercomm. It is old, but works. It would be nice to have a more maintained, maybe more modern code base, to rely on. This takes a lot of time to fix though.

GDSercomm is working, as I say, in one project with Godot 3.2.2. I see the same issue with the plugin so would seem that there is something wrong with libsercomm I guess.

Do you think it might be related to the building of the libsercomm binary? I had to do a lot of hacking and investigation to get the binaries to build initially. Both cmake and Scons has made big changes to their products.

I did a fork of sercomm and GDSercomm with the ambition to gain more control and update the repositories with newer code. The idea was that maybe I could make the binary build process more streamlined.

I was also looking for more up to date serial communication libraries. One idea was to look into the Arduino IDE code, which is open source, to see what library they used. Maybe even some how integrate the Arduino IDE into Godot as a plugin?

Any thoughts?

marpate1 commented 4 years ago

Hi, thanks for using my plugin! Can you verify that the GDSercomm.dll exists in the path on your computer? The file is located correctly in the repo You could try build the .dll yourself with the instructions inside the README.md

Thanks for your prompt reply .... I wasn't expecting this +1 Yes GDSercomm.dll was in the correct path, although I extracted the project from the ZIP again today and it executes, so I am confused. I was previously using GDSercomm which works in one of my apps at 9600 baud, but in another app which communicates with a USB dongle with UART, it doesn't work at 115200 baud. Everything seems fine, but no response. It works under Linux though.

No problem I see why you wouldnt expect that. Sercomm and GDSercomm are both discontinued repositories and mine isn't that active. I have had many thoughts on how to fix this though. I am not used to c/c++ enough to fix this fast. Could 115200 baud rate be unsupported by sercomm due to newer standard or something similar?

Hmm interesting. I can not get it to work right now. I'm having different issues. I am not very experienced with baudrates and stuff either. Are you not getting any responses from the USB Dongle?

That's right. Under Windows, I get no response from the dongle. With Linux it is fine. I can use TeraTerm on Windows and get a response so it is definitely Godot related somehow.

There might be some older c++ libraries that is missing in windows 10. I think this might be an issue outside my control. I also found that GDSercomm, that my project is depending on, might be written in old GDNative code. So the init method that the new GDNative is looking for does not exist. I have been looking into rewriting GDSercomm into my own repository due to the lack of activity in GDSercomm. Same with Sercomm which is a dependency for GDSercomm. It is old, but works. It would be nice to have a more maintained, maybe more modern code base, to rely on. This takes a lot of time to fix though.

GDSercomm is working, as I say, in one project with Godot 3.2.2. I see the same issue with the plugin so would seem that there is something wrong with libsercomm I guess.

Do you think it might be related to the building of the libsercomm binary? I had to do a lot of hacking and investigation to get the binaries to build initially. Both cmake and Scons has made big changes to their products.

I did a fork of sercomm and GDSercomm with the ambition to gain more control and update the repositories with newer code. The idea was that maybe I could make the binary build process more streamlined.

I was also looking for more up to date serial communication libraries. One idea was to look into the Arduino IDE code, which is open source, to see what library they used. Maybe even some how integrate the Arduino IDE into Godot as a plugin?

Any thoughts?

I would think that it is something to do with sercomm, but agree that the Arduino IDE would be a sensible move. I'm not sure that I'll be much help in this, but will try where I can.

I'll start Googling now :)

NangiDev commented 4 years ago

I wonder if it could be related to the overhead of having GDNative wrapper in between Godot and sercomm. Higher baudrate is faster, am I right? Have you tried running an release of your Godot app? Do you get responses then? (Edit: I think this could be possible because windows is slower, than linux, in this regard. Which could explain why it works on linux and not windows)

I did look into the Arduino IDE once and know that they are using a pretty old, but reliable, Java library that communicates with native C through JNI (Java Native Interface). This could maybe be one way to go. If Arduino is using it then it is probably future proof :)

Integrating the Arduino IDE into Godot might be hard, maybe impossible, but if possible it would be very handy :)

marpate1 commented 4 years ago

I wonder if it could be related to the overhead of having GDNative wrapper in between Godot and sercomm. Higher baudrate is faster, am I right?

I'm not sure as GDSercomm is working under linux. I used a USB analyser (USBlyzer) to compare the commands sent over USB for both your plugin and TeraTerm, both windows, and there is nothing noticeably different, so I really don't understand it. Yes, higher baudrate is faster .... think bits per second.

Have you tried running an release of your Godot app? Do you get responses then?

Yeah, I have tried that also. I don't get anything. The linux version runs from within Godot also.

I did look into the Arduino IDE once and know that they are using a pretty old, but reliable, Java library that communicates with native C through JNI (Java Native Interface). This could maybe be one way to go. If Arduino is using it then it is probably future proof :)

Integrating the Arduino IDE into Godot might be hard, maybe impossible, but if possible it would be very handy :)

It would be very handy, certainly. I've seen quite a few requests for it :)

NangiDev commented 4 years ago

...and there is nothing noticeably different, so I really don't understand it.

Hmm interesting. So what does that tell us? I wonder if there might be a bug in GDSercommPlugin, or GDSercomm that translates 115200 in the GUI to the wrong baudrate in backend Do you still get any errors in the Godot console?

It would be very handy, certainly. I've seen quite a few requests for it :)

Do you know if anyone is working on something similar? :) That would be interesting to me, because I created this repository due to lack of information at the time.

NangiDev commented 4 years ago

If the problem lies in GDSercommPlugin I think it should be around here

MenuLogic.gd Line 62

And if its in GDSercomm I think it should be in this method

sercomm_open

marpate1 commented 4 years ago

...and there is nothing noticeably different, so I really don't understand it.

Hmm interesting. So what does that tell us? I wonder if there might be a bug in GDSercommPlugin, or GDSercomm that translates 115200 in the GUI to the wrong baudrate in backend

This seems to be fine. The Parity, however isn't, so maybe that is it.

I see Godot send out the interface parameters to the device:

image

I have set the code for Even parity, but none is set.

Do you still get any errors in the Godot console?

Nothing :(

It would be very handy, certainly. I've seen quite a few requests for it :)

Do you know if anyone is working on something similar? :) That would be interesting to me, because I created this repository due to lack of information at the time.

I will let you know if I find anything. People tended to use GDSercomm.

NangiDev commented 4 years ago

This seems to be fine. The Parity, however isn't, so maybe that is it.

I see Godot send out the interface parameters to the device:

I have set the code for Even parity, but none is set.

So could this be the problem? https://github.com/NangiDev/GDSerCommPlugin/blob/e90751cfd7877265e72daff7d93854c65f59cd45/addons/GDSerCommDock/Com.gd#L19

No values is set on the enums. They all mean the same thing?

marpate1 commented 4 years ago

This seems to be fine. The Parity, however isn't, so maybe that is it. I see Godot send out the interface parameters to the device: I have set the code for Even parity, but none is set.

So could this be the problem? https://github.com/NangiDev/GDSerCommPlugin/blob/e90751cfd7877265e72daff7d93854c65f59cd45/addons/GDSerCommDock/Com.gd#L19

No values is set on the enums. They all mean the same thing?

I did wonder that .... so, I set it in code:

PORT.open(port,int(baudButton.get_item_text(ID)),1000,com.bytesz.SER_BYTESZ_8, 2, com.stopbyte.SER_STOPB_ONE)

NangiDev commented 4 years ago

PORT.open(port,int(baudButton.get_item_text(ID)),1000,com.bytesz.SER_BYTESZ_8, 2, com.stopbyte.SER_STOPB_ONE)

Doing that might actually set it to default NONE because I think it does some kind of mapping. In Sercomm it says that if SER_PAR_EVEN then send EVENPARITY to DCB that is the windows library used in sercomm.

https://github.com/ingeniamc/sercomm/blob/dd1f999884ec4202c6b42d623efdc5eabf1753fe/sercomm/win/comms.c#L160

Did you try sending in SER_PAR_EVEN instead of 2?

Edit: In https://docs.microsoft.com/en-us/windows/win32/api/winbase/ns-winbase-dcb#members you can see the table for parity used in DCB

marpate1 commented 4 years ago

PORT.open(port,int(baudButton.get_item_text(ID)),1000,com.bytesz.SER_BYTESZ_8, 2, com.stopbyte.SER_STOPB_ONE)

Doing that might actually set it to default NONE because I think it does some kind of mapping. In Sercomm it says that if SER_PAR_EVEN then send EVENPARITY to DCB that is the windows library used in sercomm.

https://github.com/ingeniamc/sercomm/blob/dd1f999884ec4202c6b42d623efdc5eabf1753fe/sercomm/win/comms.c#L160

Did you try sending in SER_PAR_EVEN instead of 2?

Yes, it made no difference :(

NangiDev commented 4 years ago

I am having issues to even getting it to work on my computer. So I am having a hard time debugging.

I am stuck at #1 right now. Do you know how to fix it?

marpate1 commented 4 years ago

I am having issues to even getting it to work on my computer. So I am having a hard time debugging.

I am stuck at #1 right now. Do you know how to fix it?

I don't I'm afraid. I'd unzipped the download a number of times and it wouldn't work and then it just started, so I don't quite understand why.

NangiDev commented 4 years ago

I got it working now :)

I dont have an UART device though. According to the documentation at least libsercomm should support UART.

And you said you can see traffic, both in and out, with Usb analyzer. And it works on Linux inside Godot editor.

So it should be something with GDSercomm or GDSercommPlugin. Most likely GDSercomm because thats where Linux and Windows does not share same library.

I wonder if there is anything with how GDSercomm is built.

Did you build the lib manually? There is a step in the build process where you specify platform

scons p=platform

Have you tried with that or with

scons p=windows

?

marpate1 commented 4 years ago

I was also looking for more up to date serial communication libraries. One idea was to look into the Arduino IDE code, which is open source, to see what library they used. Maybe even some how integrate the Arduino IDE into Godot as a plugin?

I'm wondering if the Kotlin native bindings for Godot 3,2 would simplify Serial comms as this is something supported by Kotlin. I will have a look tomorrow.

https://godot-kotl.in/en/latest/

marpate1 commented 4 years ago

I got it working now Fantastic :) I think that the UART is transparent to this and that any USB serial should be fine, but maybe I'm over simplifying.

I wonder if there is anything with how GDSercomm is built.

Did you build the lib manually? There is a step in the build process where you specify platform

Great news.

Actually I didn't build GDSercomm, I just used what is available. I will try tomorrow - maybe building that and libsercomm manually.

marpate1 commented 4 years ago

Not sure if this library is any use, but it is updated regularly. I will see if I create the GDNative wrapper for this.

https://github.com/itas109/CSerialPort

NangiDev commented 4 years ago

So no luck with building GDSercomm with my instructions?

Yes a better maintained lib would be nice :) let me know how it goes!

Siuys commented 3 years ago

Hello! I encounter the same error: Can't open dynamic library: C:/Users/Mark/Documents/GDSerCommPlugin-master/addons/GDSerCommDock/bin/GDSercomm.dll, error: Error 126: The specified module could not be found.

The project was working on my laptop but every time I tried to switch to an other PC this error occure.

I rebuild .dll but no change. Then I install Visual Studio on the other computer and it works! It's probably the missing c++ libraries.

Hope it can help!

NangiDev commented 3 years ago

Thanks for the information!

I'm thinking I need to figure out how to build the dll's with static libraries.

Misanor commented 3 years ago

Hello! Same error here. On the development machine it works but in some other PCs it throws the usual error ERROR: Can't open dynamic library: bin/win32/GDSercomm.dll, error: Error 126: The specified module could not be found. but the app continuess to run (even if the serial port does not work)

On some Pcs it works correctly. If I export the exe without debug the app crashes.

I tried to install Visual C++ redistributable 2015-2019 on the target machine but nothing changed.

PCs where the software is working are develper's machines so they have Visual Studio and a lot of tools already installed.

Misanor commented 3 years ago

The problem raises only with the 32 bit version. The 64bit version works everywhere (except on 32bit machines, of course).

When I export from Godot with the 64bit flag GDSercomm.dll and sercomm.dll are copied automatically in the export folder root, this is not happening when selecteing 32 bit export.

anthonymesa commented 2 years ago

Hey, I just wanted to chime in here and say that I too am running into this issue, though it only is an issue once I have exported the project.

What is curious is the fact that GDSercomm.dll is exported to the file with the resulting executable and I already have Visual Studio set up for C++ and C desktop development so there should be no issues there.

The last thing I haven't tried is compiling it myself, but I will be trying that shortly.

NangiDev commented 10 months ago

It's really hard testing all different hardware. As this is an old issue and I haven't been working on it for a long time, I don't remember really how it all works. Besides I am not a expert on this type of programming.

Is this still an issue? Maybe you can take a look at the new version for Godot 4.1+. Hopefully it is more stable and easier to get working on more hardware