Android Question printer thermal 58mm excelvan usb, not print.

fifiddu70

Well-Known Member
Licensed User
Hello, i have printer termal excelvan usb 58mm i need use this printer for my projects, i use this code for example but i have this problem, when i press
btn_general_check_Click in log i see the device but the connected not in rela time but abouth 40 seconds and when press for print not print in real time, i use this code:
B4X:
#Region  Project Attributes
    #ApplicationLabel: USB Serial Example
    #VersionCode: 1
    #VersionName:
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: false
    #BridgeLogger:True
#End Region

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

Sub Process_Globals
    ' Demo has been changed to support Ver_2.4 JeanLC
    Dim usb1 As UsbSerial   
    Dim usb2 As UsbSerial   
    Dim astreams1 As AsyncStreams
    Dim astreams2 As AsyncStreams
End Sub

Sub Globals

    Dim btnSend, btnOpen, btnClose As Button
    Private btnOpen2 As Button
    Private btnClose2 As Button
    Private btnSend2 As Button
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("1")
    btnClose.Enabled = False
    btnSend.Enabled = False
    
    btnClose2.Enabled = False
    btnSend2.Enabled = False
End Sub

Sub btnOpen_Click
    If usb1.UsbPresent(1) = usb1.USB_NONE Then    ' Ver_2.4
        Msgbox("No device USB NONE","")
        Return
    End If
    If (usb1.HasPermission(1)) Then    ' Ver_2.4
        Log(usb1.DeviceInfo(1))
        'This is very important - ( VendorId, ProductId )
        usb1.SetCustomDevice(usb1.DRIVER_SILABS, 0x416, 0x5011)

        Dim dev As Int
        dev = usb1.Open(9600, 1) 'STMicroeletronics
        If dev <> usb1.USB_NONE Then
            Log("Connected successfully! 1")
            btnOpen.Enabled = False
            btnClose.Enabled = True
            btnSend.Enabled = True
        
            Log("CONNECTED SUCCESSFULLY!!!")

            astreams1.Initialize(usb1.GetInputStream, usb1.GetOutputStream, "astreams1")

            'This is important
            usb1.SetParameters(9600, usb1.DATABITS_8,usb1.STOPBITS_1, usb1.PARITY_NONE)
            'Here if you want codce that call print
        Else
            Log("Error opening USB port 1")
        End If
    Else
        usb1.RequestPermission(1)  ' Ver_2.4
    End If

End Sub

Sub btnOpen2_Click
    If usb2.UsbPresent(2) = usb2.USB_NONE Then    ' Ver_2.4
        Log("Msgbox - no device")
        Msgbox("No USB device or accessory detected!", "Error")
        Log("Msgbox - returned")
        Return
    End If
    Log("Checking permission 2")
    If (usb2.HasPermission(2)) Then    ' Ver_2.4
        Msgbox(usb2.DeviceInfo(2), "Device Information 2")    ' Ver_2.4
        Dim dev As Int
        'dev = usb.Open(115200, 2)        ' Ver_2.4
        dev = usb2.Open(9600, 2)        ' Ver_2.4
        If dev <> usb2.USB_NONE Then
            Log("Connected successfully! 2")
            btnOpen2.Enabled = False
            btnClose2.Enabled = True
            btnSend2.Enabled = True           
            astreams2.Initialize(usb2.GetInputStream, usb2.GetOutputStream, "astreams2")
        Else
            Log("Error opening USB port 2")
        End If
    Else
        usb2.RequestPermission(2)  ' Ver_2.4
    End If
End Sub

Sub Astreams1_NewData (Buffer() As Byte)
    ' You must check for DeviceInfo or analyze Buffer data to know what is connected to the USB
    ' The order of the USB could change as you plug them and could change when changing the hub port they are connected to
    Log("NewData 1")
    Log(BytesToString(Buffer, 0, Buffer.Length, "UTF8"))
End Sub

Sub Astreams2_NewData (Buffer() As Byte)
    ' You must check for DeviceInfo or analyze Buffer data to know what is connected to the USB
    ' The order of the USB could change as you plug them and could change when changing the hub port they are connected to
    Log("NewData 2")
    Log(BytesToString(Buffer, 0, Buffer.Length, "UTF8"))
End Sub

Sub btnClose_Click
    astreams1.Close
    usb1.Close   
    btnOpen.Enabled = True
    btnClose.Enabled = False
    btnSend.Enabled = False
End Sub

Sub btnClose2_Click
    astreams2.Close
    usb2.Close
    btnOpen2.Enabled = True
    btnClose2.Enabled = False
    btnSend2.Enabled = False   
End Sub

Sub btnSend_Click
    astreams1.Write("abcde".GetBytes("UTF8"))
End Sub

Sub btnSend2_Click
    astreams2.Write("abcde".GetBytes("UTF8"))
End Sub

Sub btnExit_Click
    ExitApplication
End Sub

Sub AStreams1_Error
    Log("Error: " & LastException)
    astreams1.Close
End Sub
Sub Astreams1_Terminated
    Log("Terminated")
    astreams1.Close
End Sub

Sub AStreams2_Error
    Log("Error: " & LastException)
    astreams2.Close
End Sub
Sub Astreams2_Terminated
    Log("Terminated")
    astreams2.Close
End Sub


Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub
i have a excelvan 58mm printer termal usb
for printer immediately?
this is log:
Logger connesso a: WIKO U FEEL
--------- beginning of main
** Activity (main) Resume **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
Manufacturer : GD32 Microelectronics��������������������
Product : POS58 USB Printer����������������������������
Serial : Printer������������������������������������������������
DeviceName : /dev/bus/usb/001/004
DeviceClass : USB_CLASS_PER_INTERFACE (per-interface basis)
DeviceSubClass : 0
Device ID : 0x3EC
ProductId : 0x5011
VendorId : 0x416
B4aInterfaceNumber : 0
InterfaceClass : USB_CLASS_PRINTER (printer)
InterfaceSubClass : 1
InterfaceProtocol : 2
EndpointNumber : 1
EndpointDirection : In
EndpointType : USB_ENDPOINT_XFER_BULK (bulk)
EndpointAttribute : 2
EndpointInterval : 0
EndpointMaxPacketSize : 64
EndpointNumber : 1
EndpointDirection : out
EndpointType : USB_ENDPOINT_XFER_BULK (bulk)
EndpointAttribute : 2
EndpointInterval : 0
EndpointMaxPacketSize : 64
Connected successfully! 1
CONNECTED SUCCESSFULLY!!!
 
Top