Android Question Printer usb

Jorgelcr

Active Member
Licensed User
Longtime User
I have a POS IBERICA brand printer, MODEL P80WIFI USB
With the following code the printer detects me but does not open the connection port.
What I can do?


B4X:
Sub ImprimirUSB
    If usb.UsbPresent = usb.USB_NONE Then
        Log("Msgbox - no device")
        Msgbox("No USB device or accessory detected!", "Error")
        Log("Msgbox - returned")
        Return
    End If
    Log("Checking permission")
    If (usb.HasPermission) Then
        Msgbox(usb.DeviceInfo, "Device Information")
        Dim dev As Int
  
        Dim rFicheroParametros As TextReader
        rFicheroParametros.Initialize(File.OpenInput(File.DirAssets, "prnusb.cfg"))
        listaParamPRNUSB.Initialize
        listaParamPRNUSB = rFicheroParametros.ReadList
        rFicheroParametros.Close
      
        dev = usb.Open(9600) ' I have tried various values

        If dev <> usb.USB_DEVICE Then
            MsgboxAsync("Error conncect USB ", "ERROR")
            Return
        End If
      
      
      
        If dev <> usb.USB_NONE Then
            Log("Connected successfully!")
            'btnOpen.Enabled = False
            'btnClose.Enabled = True
            'btnSend.Enabled = True
            astreams.Initialize(usb.GetInputStream, usb.GetOutputStream, "astreams")
        Else
            Log("Error opening USB port")
        End If
    Else
        usb.RequestPermission
    End If
  
End Sub
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Code with Msgbox = broken code.

B4X:
       Dim rFicheroParametros As TextReader
        rFicheroParametros.Initialize(File.OpenInput(File.DirAssets, "prnusb.cfg"))
        listaParamPRNUSB.Initialize
        listaParamPRNUSB = rFicheroParametros.ReadList
        rFicheroParametros.Close
Better:
B4X:
Dim listaParamPRNUSB As List = File.ReadList(File.DirAssets, "prnusb.cfg")

What is the type of usb? Does the printer have a supported usb to serial converter?
 
Upvote 0
Top