Hi
I figured out after some test statements that nothing was working because the FB was never found, I've tried using the new FusionBrain_WinUSB.dll and the old FusionUSB.dll but neither seem to work. I have the FBv4 and I'm running XP. I have tried connecting two different brains one at a time and neither seems to get picked up by my software even though windows picks them up fine.
here is my FusionBrain_WinUSB.dll code
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FusionBrain_WinUSB;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
//holds list of devices found
List <string> ver3 = null, ver4 = null;
bool deviceFound = FusionBrain_WinUSB.MainUSBClass.FindAllDevices(ref ver3,ref ver4);
Console.WriteLine("Device Found : " + deviceFound);
bool myDevice = FusionBrain_WinUSB.MainUSBClass.FindMyDevice(0, 4);
Console.WriteLine("Device Found : " + myDevice);
}
}
}
and here is my FusionUSB.dll code
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using System.Timers;
namespace ConsoleApplication1
{
class Program
{
public const int analogueInput = 32;
public const int endOfAnalogueInput = 57;
public const int digitalInput = 0;
public const int endOfDigitalInput = 31;
public static class FusionUSB
{
[DllImport("FusionUSB.dll")]
public static extern bool FUSB_Initialize(ref UInt32 pFusionUSB, String deviceID, UInt32 instanceNumber);
[DllImport("FusionUSB.dll")]
public static extern bool FUSB_Receive(UInt32 pFusionUSB, byte[] buffer);
[DllImport("FusionUSB.dll")]
public static extern bool FUSB_Send(UInt32 pFusionUSB, byte[] buffer);
[DllImport("FusionUSB.dll")]
public static extern UInt32 FUSB_Free(ref UInt32 pFusionUSB);
[DllImport("FusionUSB.dll")]
public static extern bool FUSB_printf(UInt32 pFusionUSB);
[DllImport("FusionUSB.dll")]
public static extern UInt32 FUSB_GetWinUSBerror(UInt32 pFusionUSB);
[DllImport("FusionUSB.dll")]
public static extern UInt32 FUSB_GetFUSBstatus(UInt32 pFusionUSB);
[DllImport("FusionUSB.dll")]
public static extern String FUSB_GetDeviceInstanceID(UInt32 pFusionUSB);
}
static void Main(string[] args)
{
UInt32 instanceNumber = 0;
const UInt32 NULL = 0;
UInt32 pFusionUSB = NULL;
byte[] ReadBuffer = new byte[64];
byte[] WriteBuffer = new byte[64];
// from mdx source code
//string deviceID = @"USB\VID_04D8&PID_000C\";
//full path from my devices
//string deviceID = @"USB\VID_04D8&PID_000E\5&327F1E4E&0&1";
//root of vid & pid path from my devices
string deviceID = @"USB\VID_04D8&PID_000E\";
try
{
bool connected = FusionUSB.FUSB_Initialize(ref pFusionUSB, deviceID, instanceNumber);
Console.WriteLine("Connected :" + connected );
if (connected)
{
// do stuff (removed to shorten the code)
}
else
{
Console.WriteLine("Fusion Debug");
FusionUSB.FUSB_printf(pFusionUSB);
}
uint released = FusionUSB.FUSB_Free(ref pFusionUSB);
Console.WriteLine("Release code :" + released );
}
catch (DllNotFoundException)
{
Console.WriteLine("FusionUSB.dll Not Found");
}
}
static void clock_Elapsed(object sender, ElapsedEventArgs e)
{
throw new NotImplementedException();
}
}
}
For my FusionUSB.dll program I get the same error codes for all 3 device Ids. Sorry for the long post and thanks again for your help.
Bookmarks