Hi
I am using the EMX10-SM-128 module.
My question is that COM2, COM3, COM4 did not worked in emulator, but COM1. Virtual serial Port Emulator (VSPE) runs at my PC. I am listening the ports with Realterm data terminal. The codes testing the COM ports in emulator is given below. COM1 has been emulated, but when I changed COM1 to others i.e. COM3, they did not. I have deployed the code to the module with the “COM3”, it worked.
is it emulator problem? or is there any other modification?
using System;
using System.Text;
using System.IO.Ports;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
namespace MFConsoleApplication4
{
public class Program
{
public static void Main()
{
int k = HardwareProvider.HwProvider.GetSerialPortsCount();
// Debug.Print(k.ToString());
byte[] rx_Bytes = new byte[50];
byte[] tx_Bytes = new byte[50];
string read_Data1, send_Data1;
SerialPort UART_port = new SerialPort("COM3", 19200);
UART_port.Parity = Parity.None;
UART_port.StopBits = StopBits.One;
UART_port.ReadTimeout = 100;
UART_port.WriteTimeout = 100;
UART_port.Open();
while (true)
{
try
{
int read_Count = UART_port.BytesToRead;
if (read_Count > 0)
{
UART_port.Read(rx_Bytes, 0, read_Count);
char[] chars = new char[read_Count];
chars = Encoding.UTF8.GetChars(rx_Bytes);
System.String rxS = new System.String(chars);
read_Data1 = rxS.ToString();
}
else
{
read_Data1 = null;
}
send_Data1 = read_Data1 + "-> received" + "\r\n";
Thread.Sleep(50);
tx_Bytes = System.Text.Encoding.UTF8.GetBytes(send_Data1);
UART_port.Write(tx_Bytes, 0, send_Data1.Length);
UART_port.Flush();
Thread.Sleep(50);
}
catch (Exception ex)
{
Debug.Print(ex.ToString());
}
}
}
}
}