I tried connecting it to my Fez Panda II on COM4.
Pin 1 on RDM630 to D31 on panda…
Pin 5 to 5V
Pin 4 to gnd
Main program:
RFID = new SerialPort("COM4", 9600, Parity.None, 8, StopBits.One);
RFID.Handshake = Handshake.None;
var listenRFID = new Thread(listenForRfid);
listenRFID.Start();
private static void listenForRfid()
{
RFID.Open();
RFID.DiscardInBuffer();
RFID.Flush();
if (RFID.IsOpen)
{
Debug.Print("RFID is open");
}
RFID.DataReceived += new SerialDataReceivedEventHandler(RFID_DataReceived);
Thread.Sleep(Timeout.Infinite);
}
public static void RFID_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
Debug.Print("data recieved");
byte[] ReadBuffer = new byte[RFID.BytesToRead];
RFID.Read(ReadBuffer, 0, ReadBuffer.Length);
RFID.DiscardInBuffer();
RFID.Flush();
string data = bytesToString(ReadBuffer);
Debug.Print(data);
}
Ive tested the code, by sending serial command to the D31 port from my bus pirate. and it recieves it just fine…
But if i hook the RDM630 and place my rfid tag on top, nothing happens… det SerialDataReceivedEventHandler never trigger…
Ive got 2 of them, so i tried the other one, same results… am i doing somthing wrong?
Effectively it not mandatory to use the RX on module side. I use a module like this one from ID Innovation. Worosk fine. You should try another COM Port, cause maybe the COM4 on your board need CTS as mandatory ? First Try a port where Flow control is not used…
An input configured without pullup or pulldown can “float” between ground and VCC, causing the peripheral to “see” data coming in that’s not really there.
Okay.
Ive connected it to COM1, and made a more simplefied version of the code… still nothing when i place my rfid tag on the antenna…
Current setup:
RDM630 -> Panda
Pin 1 -> D0 (COM1 In)
Pin 4 -> GND
Pin 5 -> 5V
Antenna connected.
public class Program
{
static SerialPort RFID;
public static void Main()
{
OutputPort led = new OutputPort((Cpu.Pin)FEZ_Pin.Digital.LED, true);
RFID = new SerialPort("COM1", 9600, Parity.None, 8, StopBits.One);
RFID.Handshake = Handshake.None;
//startSlave();
RFID.Open();
RFID.DiscardInBuffer();
RFID.Flush();
if (RFID.IsOpen)
{
Debug.Print("RFID is open");
}
RFID.DataReceived += new SerialDataReceivedEventHandler(RFID_DataReceived);
Thread.Sleep(Timeout.Infinite);
}
public static void RFID_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
Debug.Print("data recieved");
byte[] ReadBuffer = new byte[RFID.BytesToRead];
RFID.Read(ReadBuffer, 0, ReadBuffer.Length);
RFID.DiscardInBuffer();
RFID.Flush();
string data = bytesToString(ReadBuffer);
Debug.Print(data);
}
public static string bytesToString(byte[] bytes)
{
string s = "";
for (int i = 0; i < bytes.Length; ++i)
{
s += (char)bytes[i];
}
return s;
}
}
OK, if I was in this position, I’d try connecting this to a PC, to eliminate the unknown of my Fez-App. I’d connect it to a TTL-to-USB serial adapter and see if I can get it to talk via a simple terminal program.
But to me, the one thing that isn’t clear, is how to make the module switch from weigand to rs232 and back. Have you found anyone else’s project that uses this thing? I have the Seeed one, http://www.seeedstudio.com/depot/125khz-rfid-module-uart-p-171.html?cPath=144_153 and I can talk to it on the UART, and I think there’s actually a different module for weigand, ie it’s not “switchable”. Do you know forsure* that you have the UART model?
Hi,
here an example for a spider with rs232 module
using System;
using System.Text;
using System.Collections;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Presentation;
using Microsoft.SPOT.Presentation.Controls;
using Microsoft.SPOT.Presentation.Media;
using Microsoft.SPOT.Touch;
using Gadgeteer.Networking;
using GT = Gadgeteer;
using GTM = Gadgeteer.Modules;
using Gadgeteer.Modules.GHIElectronics;
namespace GadgeteerApp1
{
public partial class Program
{
// This method is run when the mainboard is powered up or reset.
void ProgramStarted()
{
Debug.Print("Program Started");
rs232.Initialize(9600, GT.Interfaces.Serial.SerialParity.None, GT.Interfaces.Serial.SerialStopBits.One, 8, GT.Interfaces.Serial.HardwareFlowControl.NotRequired);
rs232.serialPort.Open();
Thread ReadThread = new Thread(MyReadThread);
ReadThread.Start();
}
void MyReadThread()
{
while (true)
{
if (rs232.serialPort.BytesToRead > 0)
{
byte[] mybuffer = new byte[rs232.serialPort.BytesToRead];
rs232.serialPort.Read(mybuffer, 0, mybuffer.Length);
string str = "";
for (int i = 0; i < mybuffer.Length; i++)
{
str += (mybuffer[i].ToString() + "-");
}
Debug.Print("Number of received bytes =: " + mybuffer.Length + " " + "Data in dezimal: " + str);
}
else
{
Debug.Print("Nothing received");
Thread.Sleep(2000);
}
}
}
}
}