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