我正在嘗試使用 C# 的 streamReader 和 streamWriter 類從 IND560 捕獲凈重。似乎建立了連接,但無論我發送什么命令,我都會收到回復:83 命令無法識別。我在 IND560 中的 Communications>Template>output for template1 下看到了命令 (wt0111)。代碼如下,如果有人有任何建議可以幫助我繼續前進,將不勝感激!static void writeToStream(string cmd) { if (tcpClient.Connected) { Console.WriteLine("Sending CMD: {0}\\n", cmd); // tried with appending a \r, \n, and \r\n same result: 83 command not found clientStreamWriter.Write(cmd + '\n'); clientStreamWriter.Flush(); } }這是顯示響應 83 的程序的示例輸出:
1 回答

寶慕林4294392
TA貢獻2021條經驗 獲得超8個贊
您需要為此目的使用讀取命令(根據此處的鏈接)
Format: read SDV#1 SDV#2
Example 1: read wt0101 wt0103
Response 1: 00R003~ 17.08~lb~
所以,在你的情況下
read wt0101
read wt0111
在您的情況下,您需要在字段 ID (wt0101) 之前添加“讀取”。
if (tcpClient.Connected)
{
Console.WriteLine("Sending CMD: {0}\\n", cmd);
clientStreamWriter.Write($"read {cmd}" + '\n');
clientStreamWriter.Flush();
}
我建議為您的用戶提供一個選項來輸入“讀取”、“寫入”、“幫助”的命令以及字段名稱,以防您打算支持更多命令。
- 1 回答
- 0 關注
- 181 瀏覽
添加回答
舉報
0/150
提交
取消