USB Gecko C# example

Started by Nuke, June 09, 2009, 05:06:25 AM

Previous topic - Next topic

Nuke

Hi,

for those who code in C# here is a USB Gecko code example project i coded, this shows how to use the ftdi chip in C#

It was my first ever program written in C#, so go easy on me :)

love the language though and think its great for GUI stuff.

http://www.usbgecko.com/newrip.zip

project was made/compiled in visual studio 2005, but should import to any version higher

0xFFFFFFuuuuuuu

REDSOXROX

It worked fine in my Visual Studio C# 2008 Ed.
The program looks really nice :D
Does it work yet? My guess would be in the Gecko menu?

I started learning C# awhile ago, I also really like it for GUI, I haven't been able to program for awhile though :mad:
Red Sox vs. Yankees 4/4/2k10 Season Opener
Red Sox: 9 Yankees: 7 Final!

Link

I was thinking some time ago.. I did learn C# some time ago. WiiRd uses one communication library to communicate with the USB Gecko. This library does everything (usbgecko.pas) - I guess I could port this to C# if there is interest though!

Panda On Smack


Link

So well.. I finally had some time to recheck the code.. well, C# progress is fine.. I implemented the core functions and already one user function.. which is a complicated one: the dump!

right now its syntax would be:


public void Dump(UInt32 startdump,UInt32 enddump, Stream saveStream) { }

So a basic call would be Dump(0x80000000,0x80400000,fileToSaveTo);


The reason I went for dump is simple. It is a quite complicated, yet absolutely important function. It has the strongest communication part with the Wii console:

  • Reset buffers
  • Announce dump command (send 1 byte 04 to the USB Gecko)
  • Wait for the reply (should be 1 byte - and AA = Acknowledge)
  • Send the memory range to dump in Big Endian to the console: a valid message would be 80 00 00 00 80 40 00 00 = dump from 80000000 to 80400000)
  • wait for ackowledge
  • Now packages are split.. package size of each max package is 63488 bytes (3968 for upload). So the download has to be splitted into packages of maximally 63488 bytes
  • Get a package
  • Check its length - if invalid: retry the package (send BB = retry to console) - after 3 retries give up (send FF to abort dumping)
  • if invalid transfer status reply: give up (Send FF)
  • if length okay and no status error: ackowledge package: send AA
  • Next package or finish if all packages done

So well.. that's the truth behind the dump command for those who didn't know it.. and well..that command being a core command is working. If anyone wants to get a glance at the current communication library with the dump example. Sure!

Nuke

The biggest thing i'd like to see is the debugger improved, rewrote to C#.

How about i come up with some bounty source thing, so we can make this happen and i fund it?

I want to try pick up USB Gecko, and i think the only way i can do this, is either hire coders so i can focus on support or do it as a collaboration community thing and i fund it.

i'm open to suggestions.
0xFFFFFFuuuuuuu

Nuke

0xFFFFFFuuuuuuu

Panda On Smack


Nuke

btw Link if you finished that function, i'd be happy to put it on the new site as an example of using C# with USB Gecko.

0xFFFFFFuuuuuuu

Link

Sure, I'll get the code asap (when I am at home)

Nuke

0xFFFFFFuuuuuuu

Link

Contains dump function.. I hope I'll get around porting more functions but for now that's it!

http://l0nk.org/GeckoTest.7z