Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use USB scan #4

Open
JakeWoki opened this issue Aug 6, 2020 · 6 comments
Open

How to use USB scan #4

JakeWoki opened this issue Aug 6, 2020 · 6 comments

Comments

@JakeWoki
Copy link

JakeWoki commented Aug 6, 2020

No description provided.

@Mghanem91
Copy link

Hey, @JakeWoki did you find a way to use USB for scanning?

@JakeWoki
Copy link
Author

JakeWoki commented Mar 7, 2022

        val usbManager = getApplication<Application>().getSystemService(Context.USB_SERVICE) as UsbManager?
        if (usbManager == null) {
            _readIdCardEvent.value = Event(Results.Error(TypeCastException(getString(R.string.id_card_err))))
        } else {
            val deviceList: HashMap<String, UsbDevice> = usbManager.deviceList
            for ((_, value) in deviceList) {
                if (value.vendorId == 1024 && value.productId == 50005) {
                    val var10 = value.getInterface(0)
                    _endpointWrite = var10.getEndpoint(0)
                    _endpointRead = var10.getEndpoint(1)
                    Intrinsics.checkExpressionValueIsNotNull(_endpointRead, "endpointRead")
                    _connection = usbManager.openDevice(value)
                    _connection?.claimInterface(var10, true)
                    return
                }
            }
            _readIdCardEvent.value = Event(Results.Error(TypeCastException(getString(R.string.id_card_err))))
        }

You can try this. It's been too long, and I forgot

@ghadeerAqraa
Copy link

@JakeWoki
Hi
How to discover the scanner using USB connected
as I understand the twain direct is working with network and to start the session we need the scanner ip
can you help ?
your help is more than appreciated

@JakeWoki
Copy link
Author

JakeWoki commented Mar 9, 2022

Porting Linux to Android, and it's very difficult.Or use WIFI or use SDK.

WIFI use reference

        val xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
                "<scan:ScanSettings xmlns:scan=\"http://schemas.hp.com/imaging/escl/2011/05/03\" xmlns:pwg=\"http://www.pwg.org/schemas/2010/12/sm\">\n" +
                "<pwg:Version>2.6</pwg:Version>\n" +
                "<pwg:ScanRegions>\n" +
                "<pwg:ScanRegion>\n" +
                "<pwg:Height>3507</pwg:Height>\n" +
                "<pwg:ContentRegionUnits>escl:ThreeHundredthsOfInches</pwg:ContentRegionUnits>\n" +
                "<pwg:Width>2480</pwg:Width>\n" +
                "<pwg:XOffset>0</pwg:XOffset>\n" +
                "<pwg:YOffset>0</pwg:YOffset>\n" +
                "</pwg:ScanRegion>\n" +
                "</pwg:ScanRegions>\n" +
                "<scan:DocumentFormatExt>image/jpeg</scan:DocumentFormatExt>\n" +
                "<pwg:ContentType>Photo</pwg:ContentType>\n" +
                "<pwg:InputSource>Platen</pwg:InputSource>\n" +
                "<scan:XResolution>200</scan:XResolution>\n" +
               "<scan:YResolution>200</scan:YResolution>\n" +
                "<scan:ColorMode>RGB24</scan:ColorMode>\n" +
                "</scan:ScanSettings>"

request boby

@ghadeerAqraa
Copy link

@JakeWoki
thanks for the quick response
what do you mean with use SDK ?

@JakeWoki
Copy link
Author

JakeWoki commented Mar 9, 2022

Some machine manufacturers provide SDK services.eg epson

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants