The MP3car.com Store  

Welcome to the MP3Car.com forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. Registering will also remove advertisements. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.

Go Back   MP3Car.com > Mp3Car Technical > General Hardware Discussion > Fusion Brain > Documentation and Tutorials

Reply
 
Thread Tools Display Modes
Old 05-01-2008, 05:00 PM   #1
Fusion Brain Creator
2k1Toaster's CarPC Specs
 
2k1Toaster's Avatar
 
Join Date: Mar 2006
Location: Colorado, but Canadian!
Vehicle: 2001 Honda Civic EX Coupe
Posts: 7,042
My Photos: (1)
Interfacing custom software with the Fusion Brain

The Fusion Brain interfaces with the computer using USB. To get the datastream to start flowing, you must initialize the device first, then you can send and receive data packets, and when you are done with the device you must free it.

The data packets are 64 bytes in length, and information on the encoding of the byte stream can be found here: http://www.mp3car.com/vbulletin/docu...-protocol.html
2k1Toaster is offline   Reply With Quote
Sponsored Links
Old 05-01-2008, 05:05 PM   #2
Fusion Brain Creator
2k1Toaster's CarPC Specs
 
2k1Toaster's Avatar
 
Join Date: Mar 2006
Location: Colorado, but Canadian!
Vehicle: 2001 Honda Civic EX Coupe
Posts: 7,042
My Photos: (1)
C# -- DLL Interface

1.) Call FUSB_Initialize() --. pFusionUSB is the Uint32 pointer to the USB handle. It is 0 when not initialized. deviceID is the full string of the PID/VID including the hardware ID. instanceNumber should be 0. If it returns true, it was initialized successfully.

2.) Call FUSB_Send() and FUSB_Receive(). FUSB_Send takes an array of 64 bytes. FUSB_Receive returns an array of bytes 64 long.

3.) Once you are all done, call FUSB_Free() and pass in the pointer you used to initialize to free it. If it returns 0, then it was freed successfully.


Code:
public static class FusionUSB { [System.Runtime.InteropServices.DllImport("FusionUSB.dll")] public static extern bool FUSB_Initialize(ref UInt32 pFusionUSB, String deviceID, UInt32 instanceNumber); [System.Runtime.InteropServices.DllImport("FusionUSB.dll")] public static extern bool FUSB_Receive(UInt32 pFusionUSB, byte[] buffer); [System.Runtime.InteropServices.DllImport("FusionUSB.dll")] public static extern bool FUSB_Send(UInt32 pFusionUSB, byte[] buffer); [System.Runtime.InteropServices.DllImport("FusionUSB.dll")] public static extern UInt32 FUSB_Free(ref UInt32 pFusionUSB); [System.Runtime.InteropServices.DllImport("FusionUSB.dll")] public static extern bool FUSB_printf(UInt32 pFusionUSB); [System.Runtime.InteropServices.DllImport("FusionUSB.dll")] public static extern UInt32 FUSB_GetWinUSBerror(UInt32 pFusionUSB); [System.Runtime.InteropServices.DllImport("FusionUSB.dll")] public static extern UInt32 FUSB_GetFUSBstatus(UInt32 pFusionUSB); [System.Runtime.InteropServices.DllImport("FusionUSB.dll")] public static extern String FUSB_GetDeviceInstanceID(UInt32 pFusionUSB); }

2k1Toaster is offline   Reply With Quote
Old 05-01-2008, 05:12 PM   #3
Fusion Brain Creator
2k1Toaster's CarPC Specs
 
2k1Toaster's Avatar
 
Join Date: Mar 2006
Location: Colorado, but Canadian!
Vehicle: 2001 Honda Civic EX Coupe
Posts: 7,042
My Photos: (1)
VB -- DLL Interface Thanks to mx270a

I converted the code you posted to VB. For future reference for anyone else, here is what that looks like:

Code:
Public Class UCSettingsIO <System.Runtime.InteropServices.DllImport("FusionUSB.dll")> _ Public Shared Function FUSB_Initialize(ByRef pFusionUSB As UInt32, ByVal deviceID As String, ByVal instanceNumber As UInt32) As Boolean End Function <System.Runtime.InteropServices.DllImport("FusionUSB.dll")> _ Public Shared Function FUSB_Receive(ByVal pFusionUSB As UInt32, ByVal buffer As Byte()) As Boolean End Function <System.Runtime.InteropServices.DllImport("FusionUSB.dll")> _ Public Shared Function FUSB_Send(ByVal pFusionUSB As UInt32, ByVal buffer As Byte()) As Boolean End Function <System.Runtime.InteropServices.DllImport("FusionUSB.dll")> _ Public Shared Function FUSB_Free(ByRef pFusionUSB As UInt32) As UInt32 End Function <System.Runtime.InteropServices.DllImport("FusionUSB.dll")> _ Public Shared Function FUSB_printf(ByVal pFusionUSB As UInt32) As Boolean End Function <System.Runtime.InteropServices.DllImport("FusionUSB.dll")> _ Public Shared Function FUSB_GetWinUSBerror(ByVal pFusionUSB As UInt32) As UInt32 End Function <System.Runtime.InteropServices.DllImport("FusionUSB.dll")> _ Public Shared Function FUSB_GetFUSBstatus(ByVal pFusionUSB As UInt32) As UInt32 End Function <System.Runtime.InteropServices.DllImport("FusionUSB.dll")> _ Public Shared Function FUSB_GetDeviceInstanceID(ByVal pFusionUSB As UInt32) As String End Function Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim thefbinstid As String = FUSB_GetDeviceInstanceID(0) MsgBox(thefbinstid) End Sub End Class

2k1Toaster is offline   Reply With Quote
Sponsored Links
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Does Fusion Brain allow Hibernation rgarjr Fusion Brain 5 04-10-2008 12:30 AM
Fusion Brain Casing zzzBrett Fusion Brain 1 10-15-2007 11:46 PM
software for custom guages, etc. Nephus Engine Management, OBD-II, Engine Diagnostics, etc. 87 07-12-2005 04:55 PM
My numpad controlled custom MP3Car software - need your opinions PorscheMP3 Software & Software Development 7 04-11-2002 10:30 AM


All times are GMT -5. The time now is 08:30 AM.


Sponsored Links
The MP3car.com Store

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.1.0
Copyright © 1999 - 2008 Mp3Car.com Inc.
Ad Management by RedTyger
Message Board Statistics