Android Question Connection to USB Thermal Printer

Abílio Magalhães

Member
Licensed User
Longtime User
Hello to all.

I'm trying to Print some text to a portable thermal USB printer in my project, but I can't even connect to the Printer.

I've made already the connection through NETwork, with the Socket connections and I've made it successfully , but not with USB connection.

I've installed the USB Serial library, even ran the example project available there.

I've added this Manifest Editor 'permissions' and checked the device_filter.xml file, (readonly).

B4X:
AddActivityText(main, <intent-filter>
        <action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" />
    </intent-filter>
    <meta-data android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED"
        android:resource="@xml/device_filter" />)


And the project that I've tried was this one in here -> http://www.b4x.com/android/forum/th...-arduinos-and-other-usb-serial-devices.24835/


In the line
B4X:
If usb.Open(9600) Then
I get an boolean error saying that cannot parse 0 as boolean, but if I remove the IF statements and left only the code is don't connect.


Then I've tried this code

B4X:
If usb.UsbPresent = usb.USB_NONE Then
        Log("NO CONNECTION")
        Return
    End If
   
    If (usb.HasPermission) Then
        Log("Device Information= " & usb.DeviceInfo )
    Else
        Log("FAIL")
    End If

And it connects but when I check the USB permission I got the FAIL Log.

Is there anything missing me ? Manifest permissions ? Code implementation??

Regards.
;)
 
Top