Stack issues with Visual Basic 2015

34 views
Skip to first unread message

Seth Henry

unread,
Jan 25, 2016, 11:57:09 AM1/25/16
to FPGALink Users
First off, I have been using the FLCLI tool in a variety of ways successfully for a while now. The hardware is stable and the software stack seems to be working. However, all of these tools are batch-based and prototype one-offs.

I now find myself with some time to create a "real" application, and since I used to be trained in Visual Basic, I decided to try once more to get a VB app to connect with FPGA link. I started by taking the example Excel spreadsheet and converting all of the calls to standard Visual Basic calls. That seemed to work, but when I actually call the very first function, fl_Initialise, I get this:

PInvokeStackImbalance occurred
Message: Managed Debugging Assistant 'PInvokeStackImbalance' has detected a problem in 'C:\Projects\Visual Basic\TestApp\TestApp\bin\Debug\TestApp.vshost.exe'.
Additional information: A call to PInvoke function 'TestApp!TestApp.FPGALink::fl_Initialise' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature.

I called this using:

Option Explicit On

Public Module FPGALink

    Private Declare Function fl_Initialise Lib "c:\apps\flcli\libfpgalink.dll" Alias "_flInitialise@8" (ByVal debugLevel As Long, ByRef errorNum As Long) As Long

    Public Sub flInitialise(
        ByVal debugLevel As Long)
        Dim errorNum As Long
        If (fl_Initialise(debugLevel, errorNum)) Then
            MsgBox(errorNum, vbOKOnly, "FPGALink Error")
            Call fl_FreeError(errorNum)
            Call Err.Raise(513, "FPGALink::flInitialise()")
        End If
    End Sub

End Module

Note that I hard-coded a link to the same dll that FLCLI uses, and it is in the path as well.

I know the source code for all of these libraries should be in the makestuff folder I downloaded everything to, but I'm primarily an HDL developer, not a software developer. I'm not sure what I would be looking at even if I found it. As an aside, the same thing happens in Excel, but Excel isn't bright enough to actually tell me what happened, it just crashes the script silently.

Any help would be appreciated. At this point I just want to establish basic communication with the board from VB. If I can get a light to blink, I think I can take it from there.

Thanks!
-Seth

Chris McClelland

unread,
Jan 25, 2016, 1:07:12 PM1/25/16
to fpgalin...@googlegroups.com
I stopped maintaining the Excel/VBA example years ago because nobody was using it. The only relevant traffic on this group is from you, two years ago:

https://groups.google.com/forum/#!topic/fpgalink-users/kyhuN4PYH3k

...and IIRC that was where I spent many hours installing Excel and getting the example working again for you. Presumably it was working when you tried it back in 2014, so what changed in the meantime?

Chris



--
You received this message because you are subscribed to the "FPGALink Users" mailgroup (see https://github.com/makestuff/libfpgalink/wiki/FPGALink).
 
To post to this group, send email to fpgalin...@googlegroups.com
To unsubscribe from this group, send email to
fpgalink-user...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/fpgalink-users?hl=en
---
You received this message because you are subscribed to the Google Groups "FPGALink Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fpgalink-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Seth Henry

unread,
Jan 25, 2016, 1:25:26 PM1/25/16
to FPGALink Users
I never did get it work, I just found clever ways to wrap/script flcli to get the job done. Given that this is all prototyping hardware, the hack worked "well enough" to get the job done.

Now I have more time to spend on a proper solution.

-Seth

Chris McClelland

unread,
Jan 25, 2016, 2:26:03 PM1/25/16
to fpgalin...@googlegroups.com
> I never did get it work
>
The time to tell me that was two years ago, when I had a working Excel installation and the VBA syntax fresh in my mind.

I can certainly get back to that point again and make this work for you, but given the general lack of interest in the Excel/VBA binding it's rather unlikely anyone else will ever benefit from the work, so it would have to be done under a formal contract.

Apologies for my belligerence, but I hope you can see this from my point of view.

Chris
Reply all
Reply to author
Forward
0 new messages