繁体   English   中英

Windows CE 6.0通过USB串行电缆发送数据

[英]Windows CE 6.0 send data via USB-Serial Cable

我正在开发WinCE应用程序(.Net 3.5),该应用程序允许通过TCPIP,串行端口和USB连接到终端。

目前仍在尝试整合USB功能。 我进行了一些研究,发现USB连接可以通过C#中的SerialPort类完成。

我试图将USB串行电缆连接到WinCE,然后出现一个新的COMPort(COM5)。 但是,当我通过该端口发送数据时,它总是返回Write Timeout错误。

下面是我通过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;
        }
    }
}

是否可以通过此设置发送数据? WinCE USB> USB串行(RS232)> DB9引脚。

提前致谢。

我发现了问题。 看来我使用了错误的电缆。 我的WinCE Tablet装有FTDI驱动程序,而我的电缆则基于Prolific USB芯片组。 我已经购买了FTDI USB芯片组电缆,并且能够从中接收数据。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM