Re: C# and BladeRF
Posted: Thu Aug 11, 2016 7:28 am
Thanks again jump. My code was pretty close to yours, but as a test I made the following method that is nearly identical to yours and is still crashing out of the debugger with an access violation. Hopefully you or someone else will see something obvious. The rest of my code works well - I'm able to configure the bladeRF and capture signals to a file that is processed off-line.
Code: Select all
public static void serNumTest()
{
IntPtr _dev;
string sdrspec = "";
string serial = "";
var rv = NativeMethods.bladerf_open(out _dev, sdrspec);
if (rv != 0)
throw new ApplicationException(String.Format("Cannot open BladeRF device. Is the device locked somewhere?. {0}", NativeMethods.bladerf_strerror(rv)));
if ((rv = NativeMethods.bladerf_get_serial(_dev, out serial)) != 0)
throw new ApplicationException(String.Format("bladerf_get_serial() error. {0}", NativeMethods.bladerf_strerror(rv)));
// above instruction crashes with following output:
// A first chance exception of type 'System.AccessViolationException' occurred in mscorlib.dll
// 'cOOKie.vshost.exe' (CLR v4.0.30319: cOOKie.vshost.exe): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Configuration\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
// The program '[8572] cOOKie.vshost.exe' has exited with code -1073741819 (0xc0000005) 'Access violation'.
BrfNativeMethods.bladerf_close(_dev);
}