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

Parallax RFID Read/Write Module


  • Please log in to reply
No replies to this topic

#1 mijnendatum

mijnendatum

    New Member

  • Members
  • Pip
  • 1 posts

Posted 26 January 2012 - 09:15 PM

Hi all,

I just received my Netduino Plus today and I have already started working on my project.
For this project I am using the Parallax RFID Read/Write Module, Serial (#28440) (http://www.parallax....dWrite-v1.0.pdf) and a Serial LCD module I got from SparkFun.

I already managed to get the LCD display working but I can't seem to get the RFID to read the tags.
I am currently using the following code:

        static SerialLCD lcd = new SerialLCD();
        static SerialPort rfid = new SerialPort(SerialPorts.COM2, 9600, Parity.None, 8, StopBits.One);

        public static void Main()
        {
            lcd.ClearDisplay();
            rfid.DataReceived += new SerialDataReceivedEventHandler(rfid_DataReceived);
            
            while (true)
            {
                byte[] command = new byte[] { (byte)'!', (byte)'R', (byte)'W', 0x01, 0x32 };
                rfid.Write(command, 0, command.Length);

                Thread.Sleep(5000);
            }
        }

        static void rfid_DataReceived(object sender, SerialDataReceivedEventArgs e)
        {
            byte[] msg = new byte[5];
            ((SerialPort)sender).Read(msg, 0, msg.Length);

            if (msg[0] == 0x01)
            {
                lcd.ClearDisplay();
                lcd.Write(msg[1]);
                lcd.Write(msg[2]);
                lcd.Write(msg[3]);
                lcd.Write(msg[4]);
            }
            else if (msg[0] == 0x02)
            {
                lcd.ClearDisplay();
                lcd.Write("Did not find a listen window");
            }
            else if (msg[0] == 0x03)
            {
                lcd.ClearDisplay();
                lcd.Write("Could be invalid command");
            }
            else if (msg[0] == 0x04)
            {
                lcd.ClearDisplay();
                lcd.Write("Sending old password");
            }
            else if (msg[0] == 0x05)
            {
                lcd.ClearDisplay();
                lcd.Write("Sending new password");
            }
            else if (msg[0] == 0x06)
            {
                lcd.ClearDisplay();
                lcd.Write("No Listen Window after new passw");
            }
            else if (msg[0] == 0x07)
            {
                lcd.ClearDisplay();
                lcd.Write("Parity error reading data");
            }
        }

I never seem to get a returning message that starts with the 0x01 byte...

Could anyone see whether I am making some big or small mistake here?




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.