Click here to Skip to main content
15,916,030 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,
I develop Serial Port programming for Thermal Printer(EPSON). Program is simple. i send the command to thermal Printer that directly connect to my computer. and let it print. Although firt and second time can print, third time the printer cannot print. i tried many time but still cannot for third time. so i plug out cable and plug in again the printer print the third time result.

i don't know what happen.

pls, help :omg:



My Code is here :

Serial BaudRate is 9600
DiscardNull False
DtrEnable False
Handshake None
Parity None
Parity Replace 63
ReadBufferSide 4096
RtnEnable False
StopBits One
WriteBufferSize 2048

VB
Private Sub frmCheckWriteAndRead_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        SerialPort1.PortName = "COM5"
        SerialPort1.Open()
    End Sub



VB
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
       Dim sendData As String
       Dim strResult As String
       'Escape character required by ESCPOS code
       Dim ESC As String = Chr(27)
       'File Separator character required by ESCPOS code
       Dim FS As String = Chr(28)
       'Group Separator character required by ESCPOS code
       Dim GS As String = Chr(29)
       'Line feed character required by ESCPOS code
       Dim LF As String = Chr(10)
       'sendData = Chr(2) & "S23" & Chr(3)
       sendData = ESC & "@" & FS & "." & ESC & "!" & Chr(8 + 1) & LF
       sendData = sendData & Chr(2) & "S23" & Chr(3)
       sendData = sendData & "dsfasdfasdfasdfasdfasdfasdfasdf" & LF
       sendData = sendData & "sdfasdfasdfasdfasdfasdfasdfasdfa" & LF
       sendData = sendData & "sdfasdfasdfasdfasdfasdfasdfasdf" & LF
       sendData = sendData & LF & LF & GS & "V" & Chr(0) & GS & "r" & Chr(1)
       SerialPort1.WriteLine(sendData)
       strResult = SerialPort1.ReadExisting()
       Me.Text = strResult
   End Sub
Posted
Updated 5-Jul-10 16:29pm
v3

I'd say that your code is broken. Not sure what else you'd like to hear. Sounds like your code doesn't do what it should, and somehow breaks the connection until it's reset by your disconnecting the printer.

There's no way anyone can give you a real solution to your broken code, without seeing the code.
 
Share this answer
 
I don't see port initialisation in your code.

For you serial port parameters:
- The word size is missing the value is usually 7 or 8 bits.
- and this is not traditional parameter.
Quote:
Parity Replace 63

If the printer gives you an answer for your message, you have to wait for the answer, serial communication is slow.

You should replace your printer with a computer with terminal emulation in order to see what your printer is receiving.
Back in the time of DOS, I was using a special software named "Breakout" with a special cable enabling to spy the bi-directional communication, including signals.

Look at printer manual to ensure you are using the right com parameters.
 
Share this answer
 
Comments
Richard MacCutchan 6-Sep-15 11:24am    
This question is more than 5 years old.
Patrice T 6-Sep-15 11:38am    
oops, I didn't check the date.
Looks like it is possible to put a question back on top of list without changing it. QA bug.
Richard MacCutchan 6-Sep-15 12:00pm    
No, it was because some spammer started posting in any question related to serial ports.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900