Not sure if this will help but this is the code so far from the CLI printer module
I know for a fact the Printer code works perfectly as I can run the same code in another application that talks directly to the printer
' Gambas module file
Public PoSConnection As ServerSocket
Public SerialPort1 As SerialPort
Public SettingsFileLocation As String = Application.Path &/ "PrinterSettings.conf"
'Printer Only Fucntions
Public PrinterNewLine As String = Chr$(10) & Chr$(13)
' Printer Fucntions Declares
Public PrinterInitialize As String = Chr(&H1B) & "@"
Public CancelFontMode As String = Chr(&H1B) & "!" & Chr(0)
Public NormalFont As String = Chr(&H1B) & "!" & Chr(1)
Public BoldFont As String = Chr(&H1B) & "!" & Chr$(9)
Public DoubleWidthFont As String = Chr(&H1B) & "!" & Chr$(33)
Public DoubleHeightFont As String = Chr(&H1B) & "!" & Chr$(17)
Public DoubleWidthHeightFont As String = Chr(&H1B) & "!" & Chr(49)
Public LeftAlignText As String = Chr(&H1B) & "a" & Chr(48)
Public CentreAlignText As String = Chr(&H1B) & "a" & Chr(49)
Public RightAlignText As String = Chr(&H1B) & "a" & Chr(50)
'Public PrintStoreLogo1 As String = Chr$(&H1B) & "a" & Chr$(48)
'Public PrintStoreLogo2 As String = Chr$(&H1B) & "a" & Chr$(48)
'Public PrintStoreLogo3 As String = Chr$(&H1B) & "a" & Chr$(48)
'Public PrintStoreLogo4 As String = Chr$(&H1B) & "a" & Chr$(48)
Public OpenCashDrawer As String = Chr$(&H1B) & Chr$(&H70) & Chr$(&H0) & Chr$(60) & Chr$(120)
Public CutPaperFull As String = Chr$(&H1D) & "V" & Chr(0)
Public CutPaperPartial As String = Chr$(&H1D) & "V" & Chr(1)
' Printer Serial Settings
Public LinesToFeed As Integer = 0
Public UsePlanPoundSymbol As String
Public PrintTestSlip As String
Public PrintGraphicalLogo As String
Public PrinterPortName As String
Public PrinterBandRate As Integer
Public PrinterFlowControl As String
Public PrinterDataBits As String
Public PrinterStopBits As String
Public PrinterParity As String
Public Sub Main()
Print "Loading Epson Printer Module..."
Print " Loading " & SettingsFileLocation & " file"
LoadPrinterSettings
Print " Data Loaded from Settings file"
Print " Number of Lines to Feed before cutting paper : " & LinesToFeed
Select Case UsePlanPoundSymbol
Case "yes", "Yes"
Print " Print The Plain Pound Symbol"
Case "no", "No"
Print " Print The Pound Symbol by using chr$(156)"
End Select
Select Case PrintTestSlip
Case "yes", "Yes"
Print " One Module has loaded Print a test page"
Case "no", "No"
Print " No test page set to print once module has loaded"
End Select
Select Case PrintGraphicalLogo
Case "yes", "Yes"
Print " Print The First stored logo as the Store logo"
Case "no", "No"
Print " No Graphical Logo set to print"
End Select
Print " Printer Port set to : " & PrinterPortName
Print " Printer Band rate set to : " & PrinterBandRate
Print " Printer Flowcontrol set to : " & PrinterFlowControl
Print " Printer Data Bits set to : " & PrinterDataBits
Print " Printer Stop Bits set to : " & PrinterStopBits
Print " Printer Parity Set to : " & PrinterParity
Print " Opening Commication to the Printer please wait..."
ConnectToPrinter("Open")
Wait 1 ' Seep for 2 seconds
If PrintTestSlip = "Yes" Then
Print "Sending Test Print to the Printer"
SendTestPrint
End If
'Open Port ready for the PoS to connect to the module
StartConnection
ConnectToPrinter("Close")
End
Private Sub LoadPrinterSettings()
Dim SettingsLocalFile As Settings
SettingsLocalFile = New Settings(SettingsFileLocation)
'This will Load the PoSSettings.conf file
'******* PoS Settings Section *******
LinesToFeed = SettingsLocalFile["Printer Settings/LinesToFeed"]
UsePlanPoundSymbol = SettingsLocalFile["Printer Settings/UsePlanPoundSymbol"]
PrintTestSlip = SettingsLocalFile["Printer Settings/PrintTestSlip"]
PrintGraphicalLogo = SettingsLocalFile["Printer Settings/PrintGraphicalLogo"]
PrinterPortName = SettingsLocalFile["Printer Settings/PortName"]
PrinterBandRate = SettingsLocalFile["Printer Settings/BandRate"]
PrinterFlowControl = SettingsLocalFile["Printer Settings/FlowControl"]
PrinterDataBits = SettingsLocalFile["Printer Settings/DataBits"]
PrinterStopBits = SettingsLocalFile["Printer Settings/StopBits"]
PrinterParity = SettingsLocalFile["Printer Settings/Parity"]
End
Private Sub ConnectToPrinter(ConnectionType As String)
SerialPort1 = New SerialPort
With SerialPort1
.Close
.PortName = PrinterPortName
.Speed = PrinterBandRate
Select Case PrinterFlowControl
Case "Hardware"
.FlowControl = SerialPort1.Hardware
Case "Software"
.FlowControl = SerialPort1.Software
Case "None"
.FlowControl = SerialPort1.None
End Select
.DataBits = PrinterDataBits
.StopBits = PrinterStopBits
Select Case PrinterParity
Case "None"
.Parity = SerialPort1.None
Case "Odd"
.Parity = SerialPort1.Odd
Case "Even"
.Parity = SerialPort1.Even
End Select
Select Case ConnectionType
Case "Open"
.Open
Case "Close"
.Close
End Select
End With
End
Private Sub SendTestPrint()
Write #SerialPort1, PrinterInitialize
Write #SerialPort1, CentreAlignText & DoubleWidthHeightFont & "THIS IS A TEST PRINT" & CancelFontMode & PrinterNewLine
Write #SerialPort1, CentreAlignText & DoubleWidthFont & "Printed from Linux" & CancelFontMode & PrinterNewLine
Write #SerialPort1, LeftAlignText & DoubleWidthHeightFont & BoldFont & "On : " & Format(Now, "dd/mm/yyyy") & CancelFontMode & PrinterNewLine
Write #SerialPort1, LeftAlignText & DoubleWidthHeightFont & BoldFont & "AT : " & Format(Now, "hh:nn:ss") & CancelFontMode & PrinterNewLine
Write #SerialPort1, LeftAlignText & NormalFont & PrinterNewLine
Write #SerialPort1, LeftAlignText & NormalFont & "Epson ESC/PoS Control module for algPoS Point of sale" & PrinterNewLine
Write #SerialPort1, LeftAlignText & NormalFont & "Software" & PrinterNewLine
Write #SerialPort1, LeftAlignText & NormalFont & PrinterNewLine
Write #SerialPort1, LeftAlignText & NormalFont & "Version : " & Application.Version & PrinterNewLine
Write #SerialPort1, LeftAlignText & NormalFont & "App Name : " & Application.Name & PrinterNewLine
Feed_CutPaper(LinesToFeed)
SerialPort1.Send
End
Private Sub Feed_CutPaper(Numberoflines As Integer)
Dim i As Integer = 0
For i = 1 To Numberoflines
Write #SerialPort1, PrinterNewLine
Next
Write #SerialPort1, CutPaperFull
End
Private Sub StartConnection()
PoSConnection = New ServerSocket
With PoSConnection
.Port = 9001
.Type = Net.Internet
.Listen(1)
End With
If PoSConnection.Status = Net.Active Then
Print " Module ready for Communcation using port 9001/9101"
End If
PoSConnection_Connection("127.0.0.1")
End
Private Sub PoSConnection_Connection(strHostIP As String)
Dim ThisSocket As Socket
Do
If PoSConnection.Status = Net.Pending Then
ThisSocket = PoSConnection.Accept()
ThisSocket.Blocking = False
If ThisSocket.Status = Net.Connected Then
Print " Connection Establed with PoS Application"
Exit
Else
End If
End If
Loop
Socket_read
End
Private Sub Socket_read()
Dim StrMsg As String
If Last.Status <> Net.Connected Then Return
Read #Last, StrMsg, Lof(Last)
Print "Recevied data : " & StrMsg
PrintData(StrMsg)
End
Private Sub PrintData(PrintData As String)
'This will format the data from the PoS terminal and print it
End
This is the code I am currenly using to send the data to the Printer add on module
Private Sub SendToModule(DataToSend As String)
ClientConnection = New Socket
With ClientConnection
.Host = "127.0.0.1"
.Port = 9001
'.Connect
End With
ClientConnection.Connect
PrintErrorMessages(ClientConnection.Status)
If ClientConnection.Status <> Net.Inactive Then
If ClientConnection.Status = Net.Connected Then
Write #ClientConnection, DataToSend, Len(DataToSend)
Print "Sending to server : " & DataToSend
Else
Close #ClientConnection
Print "Sorry Time out please try again"
Endif
Else
Print "Error"
Endif
End