Trying to convert a C++ library to C#

Guys,

although i don’t have any FEZ board yet, I’m trying to get my hands dirty and provide this community with a nice library, or should i say device driver. (it for a range of digital devices)

My C# experience is a bit rusty (not to mention my c++ experience is even worse) and i could use some help here.

I’m having trouble converting the following to C#:


typedef uint8_t MyAddress[8];

which is them used like this:


void myClass::begin(void)
{
  MyAddress myAddress;
  ....
}

Can anyone point me into the right direction ?

Thanks,
EriSan500

you want a

byte[] myAddress = new byte[8];

this is an array of 8 bit integers (bytes are 8 bit) which can hold 8 items (the number in the square brackets). There is no way, or need to make a typedef in C#, just use the byte array as above.

byte[] myAddress = new byte[8];

thanks guys,

what about the second code part of my question?


void myClass::begin(void)
{
  MyAddress myAddress;
  ....
}

thanks in advance

public static void begin()

Chris:

Why static? Member variable is within a class.

Have you tried any of the code translators out there?
[url]http://code2code.net/Default.aspx[/url]

yes, but it gives me a “sorry, parser error” :smiley:

Anyway, I’m trying to create a library to make it easier to query onewire sensors including DS18S20, DS18B20, DS1822, DS2438 so if anyone is interested in collaborating, I’ll be glad to hear from you.

I am assuming you know we have OneWire support and you want to make some wrappers to simplify the usage of certain sensors?

Exactly Gus.

I’m looking at doing something along the lines of:



FEZ_Components.DallasSensors mysensors = new FEZ_Components.DallasSensors(FEZ_Pin.Digital.Di9);

Sensor temps = mysensors.getAllTemperatures();
foreach (sensor s in temps) {
  debug.print("Model: {0} Address: {1} has {2} °C", s.model, s.address, s.temp);
}


Same will be done for humidity, light, voltage, current.

they all will return an object with the sensor addresses and values.

Too bad i don’t have a FEZ board yet (can’t afford it right now, need a new job badly first)

FEZ Panda is under $20! You can’t afford that :frowning:

I have 4 kids going to school, no job, bills keep coming in…I’ve had better times :-[

If you have blogs about electronics, projects videos…etc. that shows how you can be very valuable to the FEZ community then I maybe able to convince the guys of sending you a free FEZ Panda.

No guarantee but we can try :slight_smile:

What country are you in?

Gus, i’m from Belgium.

Can you contact me by email to discuss this further?
My email: eric dot vdb at gmail dot com

Thanks