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.

Daniel Minnaar

Member Since 01 Oct 2011
Offline Last Active Apr 01 2014 08:38 AM
-----

Posts I've Made

In Topic: Netduino send ICMP Ping ?

01 April 2014 - 08:40 AM

To get back to this issue, I've tested Colin's 3 source files he posted above on the Netduino Plus 2, and it works. However, when the network is not available, an exception gets thrown instead of a false being returned.

 

Successful pings return a true though, so this is definitely a solution.


In Topic: RFID Reader/Write (13.56khz - Mifare) on Netduino

09 May 2013 - 10:40 AM

The code was for PC with the module attached to kind of a USB to serial converter so it might actually be of pretty limited use to you. Also, I just made a few simple tests, basically only detecting tags coming into the field but I'll try and dig it out for you.

This is the one I was using:
http://www.sonmicro....id=57&Itemid=70

Which module are you using?

So you haven't used it on a Netduino yet?

 

I'm going for this one: http://www.elechouse...roducts_id=2156

 

Hopefully I can figure out these damn hex commands...


In Topic: RFID Reader/Write (13.56khz - Mifare) on Netduino

09 May 2013 - 04:50 AM

 

I've played around some with the SM130 Mifare module from SonMicro and didn't have any problems. Maybe that's not the one you got though.

 

In general hexadecimal formatting is merely used as a notation on paper and in programming languages. If you write 0x80 in C# (and C/C++) the actual value will be 128 decimal as it would if you wrote 128 in the first place.

 

In C# you can use hexadecimal notation freely so you should not need any conversion - unless of course the hexadecimal notation is in a string, then you need to convert it.

 

For single bytes, this can be done quite easily back and forth using (in analogy with the above example) 128.ToString("X2") and byte.Parse("0x80", NumberStyles.AllowHexSpecifier) functions respectively.

 

I don't know of a smart way to convert whole strings, but you could of course always traverse the array and assemble a string as you go using the mentioned functions.

 

This methods below are supposed to translate byte arrays into strings with 8 bit space separated hexadecimal numbers and vice versa. This is from the top of my head so you may need to alter it a bit if it does not compile as is:

public class HexConversion{   private static string _hex = "0123456789ABCDEF";   public static string toHex(byte[] 
B) { string s = ""; for(int i = 0; i < b.length; i++, s += " ") s += _hex[b[i] >> 4] + _hex[b[i] & 0xf]; return s; } public static byte[] fromHex(string s) { string[] a = s.Split(' '); byte[] b = new byte[a.Length]; for(int i = 0; i < b.length; i++) b[i] = byte.Parse(a[i], NumberStyles.AllowHexSpecifier); return b; } }

It could be you need to add the "0x" prefix in both the functions above. You would then use these functions like so:

// convert a regular string to a hex stringstring hex = HexConversion.toHex(Encoding.ASCII.GetBytes("Hello world"));// convert a hex string into a byte arraybyte[] bytes = HexConversion.fromHex(hex);// convert a byte array to a hex stringhex = HexConversion.toHex(new byte[]{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15});

 

Hanzibal, is there a chance you could share the reading and writing code for the SM130 module? I think I might go with this if I have some proven code to go with... thanks!


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.