Hi Guys
I am connecting my serial rs232 device to the netduino plus 2, D0 and D1 and GND. The device is a card reader. All it does is just returns the tag code from the card that's presented to it. Basically when I present a card. It is returning the following output :
1
1
1
1
1
1
1
It supposed to return the tag code for example #234765732476824
The code is very small so I cant seem to find out where I am going wrong, Thanks in advance guys
using System; using System.Net; using System.Net.Sockets; using System.Threading; using Microsoft.SPOT; using Microsoft.SPOT.Hardware; using SecretLabs.NETMF.Hardware; using SecretLabs.NETMF.Hardware.Netduino; using System.IO.Ports; using System.Text; namespace SerialPortTest { public class Program { static SerialPort serial; public static void Main() { serial = new SerialPort(SerialPorts.COM1, 9600, Parity.None, 8, StopBits.One); //serial.Handshake = Handshake.None; serial.ReadTimeout = 500; serial.Open(); serial.DataReceived += new SerialDataReceivedEventHandler(serial_DataReceived); Thread.Sleep(Timeout.Infinite); } static void serial_DataReceived(object sender, SerialDataReceivedEventArgs e) { String response = ""; byte[] bytes = new byte[1]; while (serial.BytesToRead > 0) { response += serial.Read(bytes, 0, bytes.Length); } Debug.Print(response); } } }