1、首先要在visiset工具下,设置好地址端口号,组网模式master slave参数;
2、打开工具hercules,选择TCP Client选项,设置参数好连接并通讯,发送打开、关闭 按钮指令,一般是1和2;
代码demo:
定义:
//datalogic
Socket datalogicClient = null;
SocketError errorCode;
IPEndPoint _remoteEndPoint = null;
初始化:
IPAddress IP = IPAddress.Parse("172.24.24.1");
_remoteEndPoint = new IPEndPoint(IP, 51236);
datalogicClient = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
datalogicClient.ReceiveTimeout = 800;
启动连接:
try
{
datalogicClient.Connect(_remoteEndPoint);
}
catch(Exception ex)
{ }
打开扫码器:
byte[] bs = Encoding.Unicode.GetBytes("1");
datalogicClient.Send(bs, bs.Length, SocketFlags.None);
关闭扫码器:
byte[] bs = Encoding.Unicode.GetBytes("2");
datalogicClient.Send(bs, bs.Length, SocketFlags.None);
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)