Windows CE 6.0 send data via USB-Serial Cable

2k views Asked by At

I am developing a WinCE application (.Net 3.5) which allow connection to terminal via TCPIP, Serial Port and USB.

Currently still trying to intergrate USB feature. I have done some research and found that USB connection can be done via SerialPort class in C#.

I tried to connect an USB-Serial cable to WinCE and a new COMPort (COM5) appear. But when i send data through that port, it always return Write Timeout error.

Below is my code when connecting through SerialPort:

private void SetSerialPort()
{
    try
    {
        string[] a = SerialPort.GetPortNames();
        string port = "COM4";
        if (config.port.Length > 0)
        {
            port = config.port;
        }
        this.sp.PortName = port;
        this.sp.BaudRate = 9600;
        this.sp.DataBits = 8;
        this.sp.Parity = Parity.None;
        this.sp.StopBits = StopBits.One;
        this.StartSerialPort();
    }
    catch (Exception ex)
    {

    }
    finally
    {
        this.Refresh();
    }
}
public void StartSerialPort()
{
    try
    {
        this.sp.Open();
        this.sp.Handshake = Handshake.None;
        this.sp.ReceivedBytesThreshold = 1;
        this.sp.DiscardInBuffer();
        this.sp.DiscardOutBuffer();
        this.sp.DataReceived += new SerialDataReceivedEventHandler(DataReceivedHandler);
    }
    catch (Exception ex)
    {
        throw ex;
    }
    finally
    {
        if (this.sp.IsOpen)
        {
            this.sp.RtsEnable = true;
            this.sp.DtrEnable = true;
            this.sp.WriteTimeout = 5000;
        }
    }
}

Is it possible to send data through this setup? WinCE USB > USB-Serial (RS232) > DB9 pin.

Thanks in advanced.

1

There are 1 answers

0
user2419151 On BEST ANSWER

I have found the problem. It seem that i am using the wrong cable. My WinCE Tablet is installed with FTDI driver while my cable is based on Prolific USB chipset. I have buy a FTDI USB chipset cable and i am able to receive data from it.