Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

Bitconverter class causing crash/irresponsiveness.


  • Please log in to reply
3 replies to this topic

#1 _Elias_

_Elias_

    New Member

  • Members
  • Pip
  • 6 posts
  • LocationCalgary, AB

Posted 23 June 2014 - 09:01 PM

I don't know if this is a bug, or I am using the Bitconverter class incorrectly. I basically wanted to get the mac address of my unit and then convert it into a string like so:

byte[] macBytes = Microsoft.SPOT.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces()[0].PhysicalAddress;

string macAddress = BitConverter.ToString(macBytes); //application crashes here

My Netduino Plus 2 becomes unresponsive and I cannot upload new programs to it even after a power reset. The only way to regain control of it is to reflash the firmware. I am using firmware v4.3.1 . Can anybody else try this and see if they get the same results?

 

Thanks



#2 Spiked

Spiked

    Advanced Member

  • Members
  • PipPipPip
  • 129 posts

Posted 01 July 2014 - 02:42 PM

Verified.  Same issue using bitconverter.tostring(). Have to reflash.
 
my quick workaround is;
 

const string hexChars = "0123456789ABCDEF";
static string BugWorkAroundToString(byte[] buf)
{
   string s = "0x";
            
   foreach (byte b in buf)
   {
       s += hexChars[b >> 4];
       s += hexChars[b & 0x0F];
   }
   return s;
}


#3 baxter

baxter

    Advanced Member

  • Members
  • PipPipPip
  • 415 posts

Posted 02 July 2014 - 12:48 AM

You can also use,

byte B = 0xac;
String S = B.ToString("X2");
Debug.Print(S); //--> AC


#4 _Elias_

_Elias_

    New Member

  • Members
  • Pip
  • 6 posts
  • LocationCalgary, AB

Posted 02 July 2014 - 01:53 AM

Thanks guys! I just wanted to make sure it wasn't a hardware issue or defect with my Netduino.






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.