Does anyone know if there is already a common extensions library for net mf? I have found myself creating equivillents to string.IsNullOrEmpty, and string.Replace and wrapper for converting byte[] to a string etc. I’m sure alot of others are doing the same thing!
If there isn’t it would me nice to make one (im happy to start it).
Cool. Well i’ll take a look at Fezzer once its up from maintenance and create a project.
Hopefully it supports contributions / teams for projects like codeplex…?
EDIT: Looks like it doesn’t. I’ll start one at codeplex as the project so it can be open source and contributed to, and upload release files / zip to Fezzer.
I’d also suggest that it (Fezzer) was not meant to replace something like codeplex. The focus might be wider than this now, but it started as a way to share good code snippets and the like, to help not reinvent the wheel, and to not lose the details that get talked about in threads here. That means it’s more sharing than collaboration - but since it’s still beta (and the guys at GHI are so dynamic) you’ll probably see that it blends those lines as it evolves.
excellent idea, heres something I use all the time
namespace System
{
// SPOT doesnt have this class so well make one
// maybe later it will be included
class BitConverter
{
public static string ToString( byte[] data, int offset, int count )
{
const string hex = "0123456789ABCDEF";
// convert bytes to a hex string???
char[] chars = new char[count * 3 - 1];
int index = 0;
//foreach (byte b in data)
for ( int n = 0; n < count; n++ )
{
byte b = data[offset + n];
chars[index++] = hex[b / 16];
chars[index++] = hex[b % 16];
if ( index < chars.Length )
chars[index++] = '-';
}
return new string( chars );
}
public static string ToString( byte[] data )
{
return ToString( data, 0, data.Length );
}
public static UInt16 ToUInt16( byte[] data, int offset )
{
return (UInt16)Microsoft.SPOT.Hardware.Utility.ExtractValueFromArray( data, offset, 2 );
}
public static UInt32 ToUInt32( byte[] data, int offset )
{
return (UInt32)Microsoft.SPOT.Hardware.Utility.ExtractValueFromArray( data, offset, 4 );
}
}
}
Thanks. I’ve setup a code project site. Just getting the details and some initial information / code up there and i’ll put it up here so people can add suggested extensions. I’ll post back with a link in a couple of days.
Note: above NTP code only works on Cobra, not on W5100-enabled ethernet boards.
[quote]The method Connect() Receive() Send() work for TCP and UDP in FEZ Cobra ( Microsoft’s sockets). They work only with TCP sockets now with Wiznet sockets. Use ReceiveFrom() and SendTo() for UDP.
[/quote]
Here is a sneak peak of the functionality that will be available as of go-live in a couple of days. Coded most of it already, just fine tuning and completing unit tests of them.
StringBuilder
string.Replace
StringUtility.Format (e.g. StringUtility.Format("{0:F}",7) will return “7.00”)
StringUtility.IsNullOrEmpty
Parse.TryParseInt (Long/Short etc)
Will be released under general MIT license. Will look at adding additional functionality as suggested here, just need to make sure there are no license issues etc with using it.
“.NET Micro Framework - Common Extensions” is designed to provide additional functionality to the core .NET Micro framework to fill common usage gaps between NetMf and it’s bigger .NET framework cousins.
The functionality provided within this project includes:
StringBuilder, String.Replace, StringUtility.Format, StringUtility.IsNullOrEmpty and more!