| 分類:[.NET 全般]
宜しくお願い致します C# windows フォームアプリケーション.NET Framework
前回の続きになってしまうのですが 下記で文字を送れるようになりました
Encoding shiftJISEncoding = Encoding.GetEncoding("shift_jis"); byte[] shiftJISBytes = shiftJISEncoding.GetBytes(kanji); string abc = BitConverter.ToString(shiftJISBytes).Replace("-", ""); abc = abc + new string('0', 10 * 4 - abc.Length);
sendMessage = "WRS DM100.H 10 " + abc + '\r' _ = SendAndRecieve(sendMessage);
private byte[] SendAndRecieve(string sendMessage) { netstream = tcpclient.GetStream(); Encoding enc = Encoding.ASCII; byte[] sendBytes = enc.GetBytes(sendMessage); netstream.Write(sendBytes, 0, sendBytes.Length);
System.IO.MemoryStream ms = new System.IO.MemoryStream(); byte[] resBytes = new byte[50]; int resSize;
do { resSize = netstream.Read(resBytes, 0, resBytes.Length); ms.Write(resBytes, 0, resSize); } while (netstream.DataAvailable || resBytes[resSize - 1] != '\n');
return resBytes; }
次にDMの数字を読込みたいのですが string sendMessage = "RD DM4000.U" + '\r'; byte[] byteReciveMessage = SendAndRecieve(sendMessage);
この後はどう書けば読み込めるでしょうか わからないので宜しくお願い致します ちなみにDM4000には数字の12345(10進数16bit)がはいっています |