Problems with LED64 Advanced and phidget .net library > 1.1

Supporting Visual Studio on Windows
Post Reply
frazer
Phidgetsian
Posts: 6
Joined: Wed Oct 12, 2011 4:01 pm
Contact:

Problems with LED64 Advanced and phidget .net library > 1.1

Post by frazer »

Hi!

I've updated my Phidget drivers and library using the new NuGet package from 1.0 to the latest (1.4.20190605).

Now I can't call the setter of the DigitalOutput.DutyCycle without getting an EntryPointNotFoundException like this:
"Unable to find an entry point named 'Phidget_getLastError' in DLL 'phidget22'."
I've noted this in the changelog which I guess has to do with this error:
- Add getLastError API for exposing extra error information.
If I revert back to version 1.0, I keep getting an PhidgetException with the errorcode NotAttached (which is probably since I'm using the new Windows drivers).

This means I'm currently stuck here and can't run my application for now.

Any ideas?

Regards,
Daniel
fraser
Engineering
Posts: 324
Joined: Thu Nov 19, 2009 4:41 pm
Contact:

Re: Problems with LED64 Advanced and phidget .net library > 1.1

Post by fraser »

I tried to replicate this, but cannot.

Code: Select all

static void Main(string[] args)
        {
            DigitalOutput dout = new DigitalOutput();

            
          
            try
            {
                dout.Open(5000);

                Console.WriteLine("Setting duty");
                dout.DutyCycle = 0.5;
                Console.WriteLine("And Again");
                dout.DutyCycle = 0.0;

                dout.Close();

                while (true)
                { }
                
            }
            catch(Exception ex)
            {
                Console.WriteLine(ex);
                while (true)
                { }

            }
        }
Running the older library wouldn't cause an issue so the NotAttached is probably accurate and you need to make sure the device is correctly attaching, which might be why calling the set DutyCycle invoked a "getLastError" call. I'll try some other uses to see if I can replicate the issue you saw, can you share some code?
HuntJason
Phidgetsian
Posts: 14
Joined: Tue Mar 20, 2018 12:56 pm
Contact:

Re: Problems with LED64 Advanced and phidget .net library > 1.1

Post by HuntJason »

I believe the problem is occurring because you are closing the channel in your .Close() call. Do you get the same error when you omit that line?
frazer
Phidgetsian
Posts: 6
Joined: Wed Oct 12, 2011 4:01 pm
Contact:

Re: Problems with LED64 Advanced and phidget .net library > 1.1

Post by frazer »

Sorry for my late reply.

Here's a code example of how I'm doing it (using multiple DigitalOutputs):

Code: Select all

DigitalOutput[] phidgetsLeds = new DigitalOutput[64];

		static void Main()
		{
			InitializePhidgetsLed64();
			UpdateLeds();
			ClosePhidgetsLed64();
		}

		private void UpdateLeds()
		{
			SetLed(1, WarningPanel.IndicatorState.On);
			SetLed(2, WarningPanel.IndicatorState.Off);
			SetLed(3, WarningPanel.IndicatorState.On);
		}

		private void SetLed(byte channel, WarningPanel.IndicatorState state)
		{
			double multiplier = 1.0;

			if (indicatorsDim)
				multiplier = 0.6;

            double brightnessValue = 0.0;
			if (state == WarningPanel.IndicatorState.On || (state == WarningPanel.IndicatorState.Blinking && blinkLed))
				brightnessValue = 1.0;
			else if(state == WarningPanel.IndicatorState.Blinking && !blinkLed)
				brightnessValue = 0.2;

            if (phidgetsLeds[channel] != null)
            {
                phidgetsLeds[channel].DutyCycle = brightnessValue * multiplier;
            }
		}
		
		private bool InitializePhidgetsLed64()
        {
            try
            {
                for (int i = 0; i < 64; i++)
                {
                    phidgetsLeds[i] = new DigitalOutput
                    {
                        Channel = i,
                        IsLocal = true
                    };
                    phidgetsLeds[i].Open();
                }
                return true;
            }
            catch(PhidgetException pEx)
            {
                logger.Error(pEx, "Exception initializing Phidgets LED-64 Advanced");
                return false;
            }
            catch(DllNotFoundException dnfEx)
            {
                logger.Error(dnfEx, "Could not initialize Phidgets due to missing drivers");
                return false;
            }
        }

        private bool ClosePhidgetsLed64()
        {
            try
            {
                for (int i = 0; i < 64; i++)
                {
                    if(phidgetsLeds[i] != null)
                        phidgetsLeds[i].Close();
                }
                return true;
            }
            catch (PhidgetException pEx)
            {
                logger.Error(pEx, "Exception initializing Phidgets LED-64 Advanced");
                return false;
            }
        }
frazer
Phidgetsian
Posts: 6
Joined: Wed Oct 12, 2011 4:01 pm
Contact:

Re: Problems with LED64 Advanced and phidget .net library > 1.1

Post by frazer »

Anyhow, if the problem is that the device is not connected, I don't think it should throw an internal EntryPointNotFoundException. I would consider that a bug in the Phidgets library.
fraser
Engineering
Posts: 324
Joined: Thu Nov 19, 2009 4:41 pm
Contact:

Re: Problems with LED64 Advanced and phidget .net library > 1.1

Post by fraser »

Well an EntryPointNotFound exception points toward a mismatch in dll's. I myself am not super familiar with the relationship between what you load in NuGET packages, and what you have installed on your machine from the website. I'm trying a variety of combinations of versions from both the website and installed nuget version, but can't cause the exception you're seeing.
Sounds like you couldn't find this link for old libraries, this might be useful for you.
https://www.phidgets.com/downloads/

Our library dev is away, but there could be a library bug here I'm not seeing. We will see what we can do. For now, try installing older drivers and see if that helps
frazer
Phidgetsian
Posts: 6
Joined: Wed Oct 12, 2011 4:01 pm
Contact:

Re: Problems with LED64 Advanced and phidget .net library > 1.1

Post by frazer »

I've now fixed the immediate problem I had. The code was originally from a quite old version of the API, and I had made most migrations tasks when going to version 22. But I had missed that one call was synchronous before, and is asynchronous now. After fixing this, the attach issue is no longer present.

BUT: I think that there still is a bug if trying to set DutyCycle without having the device/channel attached. You should get a PhidgetException with the error code NotAttached (like in previous versions) and not an EntryPointNotFoundException. I have tried all NuGet package versions and they all have the same behavior.
fraser
Engineering
Posts: 324
Joined: Thu Nov 19, 2009 4:41 pm
Contact:

Re: Problems with LED64 Advanced and phidget .net library > 1.1

Post by fraser »

Glad to hear you resolved it. Yes we've run into the same Exception on other devices as well and are looking into getting it fixed asap
User avatar
Patrick
Lead Developer
Posts: 3399
Joined: Mon Jun 20, 2005 8:46 am
Location: Canada
Contact:

Re: Problems with LED64 Advanced and phidget .net library > 1.1

Post by Patrick »

Hi,

Are you running this in Visual Studio?

Try deleting the packages folder and the bin folder and then reinstall the latest nuget library. I'm wondering if somehow the C dlls were not updated when the .NET library was updated. The nuget package includes it's own build of the C library, so it should not be possible to have this sort of mismatch.

You could also make sure the date on the bin/Debug/dll/x64/phidget22.dll file matches the bin/Debug/Phidget22.NET.dll

Also, can you enable native code debugging and on error have a look at the modules debug pane and ensure that the phidget22.dll is loaded from the bin/Debug/dll/x64 folder and not from somewhere else on the system.

-Patrick
ecklerpa
Fresh meat
Posts: 1
Joined: Fri Jul 15, 2022 1:53 pm
Contact:

Unable to find an entry point named 'Phidget_getLastError' in DLL

Post by ecklerpa »

I was missing the corresponding phidget dll... so find the proper dll in the 'dll' folder that gets created with your project. It's either in the 'x86' or 'x64' folder depending on your solutions platform and throw the 'phidget22.dll' in with your 'Phidget22 .NET.dll' dll.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest