1

I have used the code below to read rfid tag values.

try
{
    if (serialPort1.IsOpen) serialPort1.Close();
    serialPort1.PortName = "COM25";

    serialPort1.BaudRate = 9600;
    serialPort1.DataBits = 8;
    serialPort1.ReceivedBytesThreshold = 5;
    serialPort1.Handshake = Handshake.None;

    serialPort1.Open();
    lblStatus.Text = "Serial Port: Connected";
}
catch (Exception ex)
{
    lblStatus.Text = "Serial Port: Unable to Connect";
}

The above code is working for windows application but when i use the same code in windows mobile emulator it is saying unable to connect serial port. Can someone please help me out?

K Mehta
  • 10,323
  • 4
  • 46
  • 76
vishaljot
  • 13
  • 4
  • Have you tried looking at the actual message text on the exception being thrown? That may give you some insight as to the root cause. I suspect it may have something to do with the assumption that you've got a serial port available on the mobile device named "COM25." – Jesse Squire Apr 03 '12 at 17:35
  • It is not able to connect to the serial port when i am running the code in emulator. The same code is working perfectly when i am running it in a windows form. – vishaljot Apr 03 '12 at 17:52

1 Answers1

0

You need to do some specific configuration with the emulator to enable ports. See here for a good, starter article.

Googling how to configure windows mobile emulator serial port for will also yield some things to look at.

Paul Sasik
  • 79,492
  • 20
  • 149
  • 189