FTDI Community

Please login or register.

Login with username, password and session length.
Advanced Search  

News:

Welcome to the FTDI Community!

Please read our Welcome Note

Technical Support enquires
please contact the team
@ FTDI Support


New Bridgetek Community is now open

Please note that we have created the Bridgetek Community to discuss all Bridgetek products e.g. EVE, MCU.

Please follow this link and create a new user account to get started.

Bridgetek Community

Author Topic: Unexpected invalid handle - conflict between two devices  (Read 281 times)

dania

  • Newbie
  • *
  • Posts: 7
    • View Profile
Unexpected invalid handle - conflict between two devices
« on: December 20, 2021, 11:36:23 AM »

Hello,

i have connected two devices to PC:
1. SIGMA 2 by ASIX (www.asix.cz), is "black box" for me
2. FT4232H with virtual COMs disabled, DE signal is enabled at Channel C and device name is changed to "Mila 5000". VID and PID are default. Channel A is used as I2C, Channel B is used as SPI and Channel C is used as RS485.

Operating System is Windows 10, Visual Studio 2022, FTD2XX_NET and LibMPSSE are used. Software is developed in C#.

Issue: Channel B have invalid handle (handle value is 0) after SPI_OpenChannel call. Return value of SPI_OpenChannel is FT_OK.
Note: If FT4232H is connected only (OMEGA 2 is disconnected), handle have correct value. When I connect OMEGA 2 only after openning FT4232H, bozh devices work properly.
 
Logged

dania

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Unexpected invalid handle - conflict between two devices
« Reply #1 on: December 20, 2021, 02:56:07 PM »

I still tried to open Channel B in the same way as Channel C via FTD2XX API, without LinMPSSE use. Channel B not opened. 
Logged

FTDI Community

  • Administrator
  • Hero Member
  • *****
  • Posts: 692
    • View Profile
Re: Unexpected invalid handle - conflict between two devices
« Reply #2 on: December 20, 2021, 03:50:39 PM »

hello,

Could you clarify if you are using the SIGMA 2 or the OMEGA 2, as you say both in the post. The SIGMA 2 is a full speed device, whilst the OMEGA 2 is a Hi speed device. the FT4232H is also a Hi speed device.

Is the only time the issue occurs when the SIGMA/OMEGA is connected before FT4232H is opened? And when it is just the FT4232H connected or it is opened before the other device is connected, everything works fine?

Here is some helpful documentation:

http://www.ftdichip.com/Support/Documents/AppNotes/AN_111_Programmers_Guide_for_High_Speed_FTCSPI_DLL.pdf

http://www.ftdichip.com/Support/Documents/AppNotes/AN_135_MPSSE_Basics.pdf

Best regards

FTDI Community
Logged

dania

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Unexpected invalid handle - conflict between two devices
« Reply #3 on: December 20, 2021, 04:13:51 PM »

Code: [Select]
[DllImport("libMPSSE.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern FTDI.FT_STATUS SPI_GetChannelInfo(uint index, ref FTDI.FT_DEVICE_INFO_NODE chanInfo);
dont work.

Code: [Select]
[StructLayout(LayoutKind.Sequential, Pack = 4)]
    public struct FT_DEVICE_LIST_INFO_NODE
    {
        public uint Flags;
        public uint Type;
        public uint ID;
        public uint LocID;
        [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
        public byte[] SerialNumber;
        [MarshalAs(UnmanagedType.ByValArray, SizeConst = 64)]
        public byte[] Description;
    }

[DllImport("libMPSSE.dll", CallingConvention = CallingConvention.Cdecl)]
        public static extern FTDI.FT_STATUS SPI_GetChannelInfo(uint index, ref FT_DEVICE_LIST_INFO_NODE chanInfo);
work correctly.

Have FTD2XX_NET package error?

Edit: Second Device is Sigma 2
« Last Edit: December 20, 2021, 04:21:07 PM by dania »
Logged

FTDI Community

  • Administrator
  • Hero Member
  • *****
  • Posts: 692
    • View Profile
Re: Unexpected invalid handle - conflict between two devices
« Reply #4 on: December 21, 2021, 12:12:02 PM »

Hi,

Channel B can only be opened using LibMPSSE when being used as SPI.

if both devices work fine if you open FT4232H first, then the device seems to be operating fine. Are FT4232H and SIGMA 2 connected in any way or are they just both connected to the PC?

one other thing that could be causing the issue is that FT4232H is a hi speed device and SIGMA 2 is a full speed device. But this should'nt really matter if the two devices are not connected to each other.

Best regards,

FTDI Community
Logged

dania

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Unexpected invalid handle - conflict between two devices
« Reply #5 on: December 21, 2021, 01:12:44 PM »

AN_178 User Guide For libMPSSE - SPI says:
Quote
Structure definition of FT_DEVICE_LIST_INFO_NODE is in the D2XX Programmer's Guide.
I expected that it would not be a problem to use FT_DEVICE_INFO_NODE defined in FTD2XX_NET in LibMPSSE functions call. Unfortunately, this turned out to be a problem. When I define the structure like this
Code: [Select]
[StructLayout(LayoutKind.Sequential, Pack = 4)]
    public struct FT_DEVICE_LIST_INFO_NODE
    {
        public uint Flags;
        public uint Type;
        public uint ID;
        public uint LocID;
        [MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
        public byte[] SerialNumber;
        [MarshalAs(UnmanagedType.ByValArray, SizeConst = 64)]
        public byte[] Description;
    }
everything works as it should. This solved the issue.

Both devices were connected only to the PC and were not otherwise connected.
Logged