RFID Reader (GHI GM-366) on FEZ Spider

Yes, but not only this problem.

Yeah absolutely. You may have to install the 4.2 SDK as well, but i don’t see a problem with it.

@ Gus -
What i meant, was that (as i did not have the latest SDK yet) the two code snippets in the tutorial would only work if the driver (GHIElectronics.RFID.dll) is present, and that is what i was looking for (and found !). So then the tutorial worked fine !!!. Thanks…

BUT !!! … The output is a string (in my case of 10 characters (actually 5 Bytes\ Hex codes) in a string.
Problem was that when you want to compare this string (ID) with the found strings (see my example) , it wouldnt work.
So I thought there must be something hidden in the string, but printing the string 3 times showed no spaces or other characters…
Then i checker ID.Length…This i 11 (and not the visible 10)
So i filtered the first 10 characters with a substring… TADA !!!

Thanks for all Tips and comments… As usual i got a little further… and up to the next module.

 void rfid_CardIDRecieved(RFID sender, string ID)
        {
            // Display the ID to the screen
            string T = ID.Substring(1, 10);
            string P = "New:" + T ;
            switch (T)
            {
                case "4D0055C674":
                    P = "Iris";
                    break;
                case "4D0055CC89":
                    P = "Jasper";
                    break;
                case "2188A4A0EB":
                    P = "Bert";
                    break;
            }
            LCD.Clear();
            LCD.PrintString("Welcome " + P);
                   }
    }

@ Steven -

I just upgraded to 4.2 (as i am actually more at home with VB, I was waiting for this anyway…)
AND i also got the FEZ Cerberus and CerbuinoBee, I needed the new interface too.

But to my great dissappointment … The Spider seemed to have escaped…!
is it going to return ???
or do i have to keep using 4.1 for that ?

Bert

The latest beta supports 4.2 for the OSH (cerberus, cerbuino hydra) but also supports 4.1 for Spider so its best of both worlds (but C sharp only with 4.1)
4.2 support for Spider is coming but not sure when, `GHI are working really hard to get this out.

Edit : WooooooHooooo. Just discovered that the driver for the GHI RFID module works perfectly with the ID-12 too. Just hooked it up on the bread board and connected it to pin 5 on an extender. Result :D. Also powering the chip from the extender means the reader only has a read distance of about 1cm whereas powering the chip from an external 5v source gives me about 8-9 cm read distance. I guess thats to do with the current draw over USB.

Is there any reason that the first character is being returned with the card ID? I found that you get the right result if you do ID.Trim((char)2) but I would prefer it to just give me the ID without any special characters.

Can you explain more please?

Sure thing. Similar to Berto, I am expecting a 10 character hexadecimal value returned as a string, but am instead getting back a 11 character string. The first character is a ‘’ (which you can’t see, but it’s there - it is 0x02)

I’m getting rid of it in my code by doing a Trim((char)2) where Berto is doing a Substring. What I’d like to see is just a 10 character value being returned.

This is the code I use for my ID-12, which seems like it is similar here.


protected static bool TryParseRFID(byte[] rawData, out string cardId)
        {
            if (rawData[0] == 0x02 && rawData[13] == 0x0D && rawData[14] == 0x0A && rawData[15] == 0x03)
            {
                char[] charData = new char[12];
                for (int i = 0; i < 12; i++)
                {
                    charData[i] = (char)rawData[i + 1];
                }

                if (VerifyChecksum(charData))
                {
                    cardId = string.Empty;
                    for (int i = 0; i < 10; i++)
                    {
                        cardId += charData[i];
                    }

                    return true;
                }
            }

            cardId = string.Empty;
            return false;
        }

        private static bool VerifyChecksum(char[] charData)
        {
            string strData = new string(charData);

            byte[] chk = new byte[6];
            chk[0] = (byte)Convert.ToInt32(strData.Substring(0, 2), 16);
            chk[1] = (byte)Convert.ToInt32(strData.Substring(2, 2), 16);
            chk[2] = (byte)Convert.ToInt32(strData.Substring(4, 2), 16);
            chk[3] = (byte)Convert.ToInt32(strData.Substring(6, 2), 16);
            chk[4] = (byte)Convert.ToInt32(strData.Substring(8, 2), 16);
            chk[5] = (byte)Convert.ToInt32(strData.Substring(10, 2), 16);

            return (chk[0] ^ chk[1] ^ chk[2] ^ chk[3] ^ chk[4]) == chk[5];
        }

the first char may be a Byte order mark or similar. i think i saw something on the netduino forum about the ID 12 that mentioned the same issue.

FYI if you use the GHI RFID module driver (Just drag it into the designer but use an extender instead) it works perfectly with the ID 12 :slight_smile: see my earlier post in this topic