首页 新闻 会员 周边

通过PC串口向EPSON TM-U220型号打印机发送命令

0
悬赏园豆:20 [已关闭问题] 关闭于 2008-07-03 22:07
<P>各位:我想通过PC串口向EPSON TM-U220型号打印机发送命令,例如检查打印换行,但不知如何实现,哪位大侠知道还望给予指点,做好给个例子。十二分感谢!&nbsp;&nbsp; <BR></P> <P>一下是打印并换行的命令解释:</P> <P>[Name] Print and line feed<BR>[Format] ASCII LF<BR>Hex 0A<BR>Decimal 10<BR>[Range] None<BR>[Default] None<BR>[Printers not featuring this command] None<BR>[Description] Prints the data in the print buffer and feeds one line, based on the current line spacing.<BR>[Notes] ■ The amount of paper fed per line is based on the value set using the line spacing command (ESC 2 or<BR>ESC 3).<BR>■ After printing, the print position moves to the beginning of the line. When a left margin is set in standard<BR>mode, the position of the left margin is the beginning of the line.<BR>■ When this command is processed in page mode, only the print position moves, and the printer does not<BR>perform actual printing.</P>
问题补充: 我的邮箱zybhan@163.com 有实例的麻烦发email给我。谢谢了
ZYB的主页 ZYB | 初学一级 | 园豆:0
提问于:2008-06-27 16:15
< >
分享
所有回答(1)
0
向串口写数最基本的代码如下 private bool _isStringMode=true; SerialPort _comPort= new SerialPort(); private bool WriteToSerialPort(string strToSend) { try { _comPort.BaudRate = 19200; _comPort.PortName = "COM1"; OpenSerialPort(); if (_isStringMode == false) { //二进制模式 byte[] buf = new byte[strToSend.Length]; for (int i = 0; i < strToSend.Length; i++) { buf[i] = (byte)strToSend[i]; } _comPort.Write(buf, 0, strToSend.Length); return true; } else { //文本模式 _comPort.Write(strToSend); return true; } CloseSerialPort(); } catch (Exception ex) { throw new Exception("写入串口异常", ex); } } /// <summary> /// 关闭串口 /// </summary> private void CloseSerialPort() { if (_comPort != null) { if (_comPort.IsOpen == true) { _comPort.Close(); } } } /// <summary> /// 打开串口 /// </summary> private void OpenSerialPort() { if (_comPort != null) { if (_comPort.IsOpen == false) { _comPort.Open(); } } }
花生1 | 园豆:872 (小虾三级) | 2008-06-27 23:49
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册