Sponsored links

Go Back   MP3Car.com > Mp3Car Technical > General Hardware Discussion > Fusion Brain > FB Software


Reply
 
Share Thread Tools Display Modes
Old 04-06-2009, 09:37 AM   #1
Newbie
 
Join Date: Oct 2008
Posts: 11
finnj6 is an unknown quantity at this point
Problems Initializing FB

Hi I'm writing a program with c# to interface with the FB as part of my final year project for university. I have written two programs one using FusionUSB.dll and the other using FusionBrain_WinUSB.dll

My code for the FusionBrain_WinUSB.dll drivers is:
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); for (int i = 0; i <= 5; i++) { bool myDevice = FusionBrain_WinUSB.MainUSBClass.FindMyDevice(i, 4); Console.WriteLine("Device Found " + i + " : " + myDevice); } } } }

and my code for FusionUSB.dll drivers is
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) { bool sent = FusionUSB.FUSB_Send(pFusionUSB, WriteBuffer); bool read = FusionUSB.FUSB_Receive(pFusionUSB, ReadBuffer); Console.WriteLine("Data Sent :" + sent); Console.WriteLine("Data Received :" + read); //read in analogue inputs if (read) { int a = Console.Read(); while (a != 0) { for (int i = analogueInput; i <= endOfAnalogueInput; i += 2) { Console.WriteLine("Sensor " + i + " : " + ReadBuffer[i] + "," + ReadBuffer[i + 1]); } a = Console.Read(); } } else { Console.WriteLine("No Input"); } } 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(); } } }

I can't figure out why neither of these work, I have been working using the MDX code as a guide, and have followed it closely and still nothing works. I am using windows xp with FBv4 and can see the FB in my devices.

Could someone please help?

Thanks
Jeff
finnj6 is offline   Reply With Quote
Advertisement
 
Advertisement
Sponsored links

Old 04-07-2009, 01:40 AM   #2
Fusion Brain Creator
 
2k1Toaster's Avatar
 
Join Date: Mar 2006
Location: Colorado, but Canadian!
Posts: 8,862
2k1Toaster has a brilliant future2k1Toaster has a brilliant future2k1Toaster has a brilliant future2k1Toaster has a brilliant future2k1Toaster has a brilliant future2k1Toaster has a brilliant future2k1Toaster has a brilliant future2k1Toaster has a brilliant future2k1Toaster has a brilliant future2k1Toaster has a brilliant future2k1Toaster has a brilliant future
If you use the Fusion_WinUSB.dll then you need to have the new drivers installed.

If you use the FusionUSB.dll, then you need to old drivers installed.

Both cannot be installed at the same time.
2k1Toaster is offline   Reply With Quote
Old 04-07-2009, 08:13 AM   #3
Newbie
 
Join Date: Oct 2008
Posts: 11
finnj6 is an unknown quantity at this point
Thanks that helped I uninstalled the drivers from the device manager, which were installed with the mdx installer. After that I just had the FusionBrain_WinUSB.dll as a reference to my project.

Last edited by finnj6; 04-07-2009 at 12:16 PM.
finnj6 is offline   Reply With Quote
Old 04-07-2009, 12:35 PM   #4
Newbie
 
Join Date: Oct 2008
Posts: 11
finnj6 is an unknown quantity at this point
Still Not Initializing

Hi I thought I had it working but my last post was a little premature unfortunatly.

I still have a problem with Initializing the FB this time when using

FusionBrain_WinUSB.MainUSBClass.FindAllDevices(ref ver3, ref ver4);

it always returns true even though

FusionBrain_WinUSB.MainUSBClass.FindMyDevice(i, 4)

where i is the index. I think

FusionBrain_WinUSB.MainUSBClass.FindMyDevice(i, 4)

is correct to return false because the count of the ver4 list is 0 after calling FindAllDevices
I'm starting to think it's my set up?
I'm using
XP
Visual Studio 2008 full

Added
FusionBrainWinUSB.dll as a reference to my project

Uninstalled
MDX
FusionBrainV4 drivers(installed from drivers download on FusionControllCenter)

If I get this working I'll put up a for dummies post

Here is my complete code incase I have made some huge error
Code:
using System; using System.Collections.Generic; using System.Linq; using System.Text; using FusionBrain_WinUSB; namespace AAL { class FusionBrain { public void connect() { //holds list of devices found List<string> ver3 = new List<string>(); List<string> ver4 = new List<string>(); byte[] buffer = new byte [64]; //returns true even if there is no Brain connected bool deviceFound = FusionBrain_WinUSB.MainUSBClass.FindAllDevices(ref ver3, ref ver4); Console.WriteLine("Device Found : " + deviceFound); //count always == 0 even with 2 Brains connected Console.WriteLine("Version 4 count: "+ ver4.Count() ); int index4 = 0; for (int i = 0; i < ver4.Count; i++) { //not connecting when Brain is connected bool myDevice = FusionBrain_WinUSB.MainUSBClass.FindMyDevice(i, 4); if( myDevice ) { index4 = i; Console.WriteLine("Conected at Index: " + index4); } } } } }


Last edited by finnj6; 04-07-2009 at 12:41 PM.
finnj6 is offline   Reply With Quote
Old 04-07-2009, 06:23 PM   #5
Fusion Brain Creator
 
2k1Toaster's Avatar
 
Join Date: Mar 2006
Location: Colorado, but Canadian!
Posts: 8,862
2k1Toaster has a brilliant future2k1Toaster has a brilliant future2k1Toaster has a brilliant future2k1Toaster has a brilliant future2k1Toaster has a brilliant future2k1Toaster has a brilliant future2k1Toaster has a brilliant future2k1Toaster has a brilliant future2k1Toaster has a brilliant future2k1Toaster has a brilliant future2k1Toaster has a brilliant future
Insert a breakpoint right after ...FindAllDevices(...);

See what those lists contain. do any instances appear at all? If not then the drivers aren't installed correctly or not properly plugged in or system initialized.

It should return true unless there was an error that got trapped by the exception handler. Finding 0 devices will still return true if all goes well.
2k1Toaster is offline   Reply With Quote
Old 04-10-2009, 07:42 AM   #6
Newbie
 
Join Date: Oct 2008
Posts: 11
finnj6 is an unknown quantity at this point
Thanks

This is working now I moved everything onto my vista laptop and installed the drivers and it's working now. I'll have to try and reinstall the drivers when I get back to my lab machine on Tuesday.

I'll let you know how it goes. But I think I owe you a guide for dummies.
finnj6 is offline   Reply With Quote
Advertisement
 
Advertisement
Sponsored links

Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Flash Problems.... Flash Problems... and MORE Flash Problems!!!!!!! JohnWPB Road Runner 33 03-28-2008 03:18 PM
any known problems running under bootcamp Ryan711 MacCar 11 09-13-2007 04:00 PM
Centrafuse Problems - GPS, Voice Recognition, Freezing kevlar Centrafuse 2 08-13-2007 04:18 PM
Harddrive problems (booting) Axxess General Hardware Discussion 1 05-15-2007 05:13 PM
Dell Inspiron 8200 & Lilliput TS problems? bkpsu LCD/Display 1 08-15-2004 02:55 PM



All times are GMT -5. The time now is 12:36 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.3.2
Copyright © 1999 - 2008 Mp3Car.com Inc.Ad Management by RedTyger
Message Board Statistics