Spanish problema impresora ticket pos conexion red

resti

Member
Licensed User
** Hola estoy haciendo una prueba de impresion a una impresora de ticket pos conectada a red. Funciona bien el problema es que cuando pasa un poco de tiempo deja de imprimir. No se que hacer. Gracias. **


#Region Project Attributes
#ApplicationLabel: B4A Example
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: landscape
#CanInstallToExternalStorage: False
#End Region

#Region Activity Attributes
#FullScreen: False
#IncludeTitle: False
#End Region

Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.

End Sub



Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.

Dim IPIMPRESORA1 As String' IP

Dim IMPRESORA1 As Socket 'Network library

Dim PRINT As AsyncStreams 'RandomAccessFile library

Dim ESPOS As String' CODIGO PARA IMPRIMIR

Private Button1 As Button
End Sub

Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:

Activity.LoadLayout("L1")

IPIMPRESORA1="192.168.0.87"

IMPRESORA1.Initialize("IMPRESORA1")
IMPRESORA1.Connect(IPIMPRESORA1, 9100, 0) 'Printer IP address, 9100=Port number (please look up port number)

End Sub

Sub IMPRESORA1_Connected (Successful As Boolean)

If Successful Then
PRINT.Initialize(IMPRESORA1.InputStream, IMPRESORA1.OutputStream, "PRINT")
Log("conex 1")
End If

End Sub


Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub


Sub Button1_Click

ESPOS = Chr(27) & "@"' INICIAR IMPRESORA
PRINT.Write(ESPOS.GetBytes("UTF8"))


ESPOS = "HOLA MUNDO" & CRLF
PRINT.Write(ESPOS.GetBytes("UTF8"))

ESPOS = Chr(27) & Chr(109)' CORTE PARCIAL
PRINT.Write(ESPOS.GetBytes("UTF8"))

End Sub


*********************************************************************

#Region Service Attributes
#StartAtBoot: False
#ExcludeFromLibrary: True
#End Region

Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.



End Sub

Sub Service_Create
'This is the program entry point.
'This is a good place to load resources that are not specific to a single activity.



End Sub


Sub Service_Start (StartingIntent As Intent)



End Sub

Sub Service_TaskRemoved
'This event will be raised when the user removes the app from the recent apps list.
End Sub

'Return true to allow the OS default exceptions handler to handle the uncaught exception.
Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
Return True
End Sub

Sub Service_Destroy


End Sub
 

Don Oso

Active Member
Licensed User
Longtime User
Recuerda que en Android las apps se van a suspension cuando la pantalla del movil o tablet se bloquea, tienes que administrar
es comportamiento en activity_resume y activity_pause , este ultimo se gatilla cuando la pantalla del movil se apaga o cuando usas otra app, resume cuando vuelves a usar tu aplicacion, por lo tanto en Resume deberias reconectar o revisar el estado de la conexion.

Para preguntar por codigo usa el boton de Insert y selecciona Code arriba del dialogo de creacion del post


Este codigo es el que debes controlar en Pause y Resume, Reconecta a tu impresora en Resume.

B4X:
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:

Activity.LoadLayout("L1")

IPIMPRESORA1="192.168.0.87"

IMPRESORA1.Initialize("IMPRESORA1")
IMPRESORA1.Connect(IPIMPRESORA1, 9100, 0) 'Printer IP address, 9100=Port number (please look up port number)

End Sub

Sub IMPRESORA1_Connected (Successful As Boolean)

If Successful Then
PRINT.Initialize(IMPRESORA1.InputStream, IMPRESORA1.OutputStream, "PRINT")
Log("conex 1")
End If

End Sub
 

benji

Active Member
Licensed User
Longtime User
yo uso impresora conectada por Bluetooth, y lo que hago para que no se desconecte, es un servicio que cada x cantidad de tiempo, imprime una linea en blanco, con eso la mantienes siempre activa
 
Top