|
| TcpConnection (string descriptor) |
| 根据 descriptor 字符串初始化新类实例。 更多...
|
|
| TcpConnection (string IpAddress, int port) |
| Initialize new class instance
|
|
override void | Close () |
| Closes a connection.
|
|
override void | Open () |
| Opens a connection.
|
|
override byte[] | Read () |
| Read all bytes available.
|
|
virtual void | Read (BinaryWriter binDataIn) |
| Reads all bytes available into the stream passed in.
|
|
virtual void | WaitForData (int msTimeOut) |
| 等待数据可用 BytesAvailable 在当前线程。当前线程休眠直到接收到数据或超时。阻塞调用。 更多...
|
|
virtual void | Write (BinaryReader binReader) |
| 从输入流写入输出流 更多...
|
|
override void | Write (byte[] dataOut) |
| Writes all bytes from the array passed in.
|
|
virtual void | WriteAndWaitForResponse (BinaryWriter binDataIn, BinaryReader binDataOut, int responseStartTimeOut, int responseEndTimeOut, string completetionToken) |
| 将 binDataOut 流数据写入输出流,并将接收到的数据返回到 binDataIn 流中。返回的数据是接收到的任何数据或达到接收的完成标记。如果没有响应则在返回前等待超时。 更多...
|
|
virtual byte[] | WriteAndWaitForResponse (byte[] dataOut, int responseStartTimeOut, int responseEndTimeOut, string completetionToken) |
| 将字节数据写入输出流并返回接收到的数据。返回的数据是接收到的任何数据或达到接收的完成标记。在返回前等待响应超时。 更多...
|
|
实现TCP特定通信并扩展AComm类的类。
示例
using System;
using System.IO;
using System.Text;
namespace Snippets
{
class MyComm
{
public static void MainComm(string[] args)
{
string prtIp = "127.0.0.1";
SendPrintFile(prtIp);
SendPrintString(prtIp);
}
public static void SendPrintFile(string ipAddress)
{
string fileName = @"C:\testFiles\Hello.pgl";
try
{
PtrTcpComm.Open();
if (File.Exists(fileName))
{
using (BinaryReader binReader = new BinaryReader(File.Open(fileName, FileMode.Open)))
{
Console.WriteLine($"Sending \"{fileName}\" to printer");
PtrTcpComm.Write(binReader);
}
}
else
{
Console.WriteLine($"File \"{fileName}\" not found");
}
}
catch (Exception e)
{
Console.WriteLine($"Exception Msg: {e.Message}");
}
finally
{
PtrTcpComm.Close();
}
}
public static void SendPrintString(string ipAddress)
{
string dataToPrint =
@"~CREATE;C39;72
SCALE;DOT
PAGE;30;40
ALPHA
C10;1;33;0;0;@HELLO@
C16;54;37;0;0;@*World*@
STOP
BARCODE
C128C;XRD3:3:6:6:9:9:12:12;H6;10;32
@World@
STOP
END
~EXECUTE;C39
~NORMAL
";
try
{
PtrTcpComm.Open();
if (PtrTcpComm.Connected)
{
byte[] outBytes = Encoding.ASCII.GetBytes(dataToPrint);
PtrTcpComm.Write(outBytes);
}
else
{
Console.WriteLine($"Not connected to printer");
}
}
catch (Exception e)
{
Console.WriteLine($"Exception Msg: {e.Message}");
}
finally
{
PtrTcpComm.Close();
}
}
}
}
readonly int UniPRT.Sdk.Comm.TcpConnection.DEFAULT_STATUS_PORT = 3002 |
|
static |
Port for listening to status messages from printer.
Printer may be configured to send status messages to different ports based on the "Ret. Status Port" setting on the printer. If the "Ret. Status Port" is set to "E-NET Stat Port", the printer may send status messages to the "Status Port Number" setting which has a default of 3002.
e.g. Emulation (printer language such as PGL) diagnostic messages from printer.
e.g. Capturing ODV barcode data and grade with the following printer menu settings:
- "System/Printer Mgmt/Ret. Status Port" set to "E-NET Stat Port"
- "System/Printer Mgmt/Status Port Number" set to 3002
- "ODV2D/Control/Telemetry Data" set to "Full Report"
- "ODV2D/Control/Return Data" set to "Data+Grade" for listening to "barcode data + grade"