簡體   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