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

Scanner wedge mode #437

Merged
merged 11 commits into from Oct 25, 2023
Merged

Scanner wedge mode #437

merged 11 commits into from Oct 25, 2023

Conversation

SchrodingersGat
Copy link
Member

@SchrodingersGat SchrodingersGat commented Oct 23, 2023

Implements "wedge scanning" functionality for barcode scanning, as an alternative to the internal camera. Allows use with external barcode readers, or with dedicated scanning devices (typically android)

Closes #364

Implements the code_scan_listener library

Note: I don't currently have access to a test device to check if this works correctly - if anyone can test, that would be greatly appreciated so we can push out a release ASAP

@horbix28
Copy link

Unfortunately i have no idea how to compile the source code into an apk.
Maybe you can help me, i would have a scanner to test it.

- Required some tweaks to other code
@lfg-seth
Copy link

So it took some figuring out on my end. I had to put the scanner into "Keyboard Mode" and set the Terminator to the Enter Key. It was that last part I had missed and was driving me crazy as it didn't seem to work at all.

I can see in debug logs that its working but I only had the demo server to test at the moment. I tried to scan a part label but kept getting "No match found".

I/flutter ( 5735): Building WedgeBarcodeController widget D/MediaPlayer( 5735): finalize() native_finalize called D/MediaPlayer( 5735): finalize() native_finalize finished I/flutter ( 5735): Scanning state: true I/flutter ( 5735): onBarcodeScanned triggered with barcode: ["PART"; 940 ] I/flutter ( 5735): DEBUG: scanned: ["PART"; 940 ] I/flutter ( 5735): pauseScan called I/flutter ( 5735): DEBUG: Scanned barcode data: '["PART"; 940 ]' I/flutter ( 5735): Building WedgeBarcodeController widget I/flutter ( 5735): DEBUG: Barcode scan response{plugin: None, barcode_data: ["PART"; 940 ], barcode_hash: aa19fa7fb3cf2d4f46b45caf817dcfa5, error: No match found for barcode data} I/flutter ( 5735): DEBUG: showSnackIcon: 'No match for barcode' I/flutter ( 5735): DEBUG: Playing audio file: 'sounds/barcode_error.mp3'

It clearly is scanning the barcode correctly. And im connected to the demo server on the device and on my pc where I generated the part label. So shouldn't it be able to find the part? idk. It's late and I may just be missing something silly at this point. If im missing something and should try another way to test it, please let me know.

@lfg-seth
Copy link

So I tried doing "assign barcode" on some random part and I scanned the same barcode ["PART"; 940 ], that worked. Then I went back to the main screen, clicked on the scanner at the bottom, scanned the same barcode, and it took me to the random part. So I guess this is working??? But what then is the intended behavior of the barcodes? Do I need to create barcodes for everything and assign the barcodes? Can I not just use the barcodes generated by Inventree? I am a bit confused here.

@horbix28
Copy link

Should be working with normal barcodes (or QR Codes) generated by InvenTree as well.
At least the camera version works so :)

@SchrodingersGat
Copy link
Member Author

@lfg-seth I'm amazed that it works so well right out of the gate :)

For the "native InvenTree barcodes", it looks like the scanner is changing the raw barcode data:

You are getting:

["PART"; 940 ]

But it should read:

{"part": 940}
  • {} replaced with []
  • : replaced with ;
  • part changed to PART

Until this is fixed, the InvenTree server will not recognize the data!

Are there any settings in your scanner to address this?

@lfg-seth
Copy link

Interesting. So when I scan the barcode in a text box or in the scanners test scan app, it shows up as {"part": 940}. Could it be something with the debug? or something with the library? I'm not 100 percent certain but I do not think it's an issue with the scanner.

@lfg-seth
Copy link

Not even sure if this is the right library....But it almost sounds like this might be going on shaxxx/flutter_barcode_listener#34

@SchrodingersGat
Copy link
Member Author

Not even sure if this is the right library....But it almost sounds like this might be going on shaxxx/flutter_barcode_listener#34

It looks like that is the right track - all the "errors" in the data equate to alternate keyboard keys due to incorrect "SHIFT" usage

@SchrodingersGat
Copy link
Member Author

Frustratingly, we cannot even test this behaviour automatically - due to a similar limitation in the flutter unit testing framework:

flutter/flutter#96021

- https://github.com/fuadreza/flutter_barcode_listener
- Fork of https://github.com/shaxxx/flutter_barcode_listener
- Properly handles key "case" issues (shift, essentially)
- Verified that it works correctly for multiple character types
@SchrodingersGat
Copy link
Member Author

Ok, some progess!

To get this to work, I had to use this fork which correctly handles all these characters. It is not available on pub.dev so had to pin the git commit, but it does work!

Tested that the following string scans correctly: Scanned barcode data: '[]{}:;1234567890!@#$%^&*()<>??"''

(As I did not have a barcode scanner on hand, managed to hack one together with an esp32 as a fun learning exercise!)

@SchrodingersGat
Copy link
Member Author

@lfg-seth when you get a chance, please check with the latest updates

@lfg-seth
Copy link

I/flutter ( 1500): DEBUG: scanned: {"part": 940} I/flutter ( 1500): DEBUG: Scanned barcode data: '{"part": 940}' I/e.inventree_ap( 1500): Background concurrent copying GC freed 29594(1494KB) AllocSpace objects, 0(0B) LOS objects, 49% free, 2060KB/4120KB, paused 649us total 147.144ms I/flutter ( 1500): DEBUG: Barcode scan response{part: {pk: 940, api_url: /api/part/940/, web_url: /part/940/}, url: /part/940/, plugin: InvenTreeBarcode, barcode_data: {"part": 940}, barcode_hash: 2c7e3e276b13c6cb6d019df809e869a3, success: Match found for barcode data} I/flutter ( 1500): DEBUG: Playing audio file: 'sounds/barcode_scan.mp3'

Success! It seems to be working now @SchrodingersGat. Thanks for the support here!

@matmair
Copy link
Member

matmair commented Oct 24, 2023

I think this would warrant a short blog and social media post.

@horbix28
Copy link

Hello together, glad to hear It's working now.
Is there a plan for a next app update/release?
I am already looking forward to finally being able to use that feature too.

Thanks a lot for the quick Implementation. Great work :)

@SchrodingersGat
Copy link
Member Author

@lfg-seth happy that it is working! And thank you for the sponsorship, greatly appreciated :)

@horbix28 I will release the new app version tonight, so should be available within 48 hours

@SchrodingersGat SchrodingersGat merged commit c641cea into master Oct 25, 2023
2 checks passed
@SchrodingersGat SchrodingersGat deleted the scanner-wedge-mode branch October 25, 2023 11:40
@SchrodingersGat
Copy link
Member Author

App release is now out, lmk how it works for you guys

@42CrMo4
Copy link

42CrMo4 commented Oct 29, 2023

@SchrodingersGat this feature works fine for me with an android 10 Tablet and a datalogic usb scanner with an otg cable. Thank you, very appreciated 👍
One question is it theoretically possible to have the wedge input in the main menu without having to choose scanner mode first?

@SchrodingersGat
Copy link
Member Author

@42CrMo4 glad to hear that it is working well :)

The home page features should be possible. Please open a new issue so if doesn't get lost

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
barcode enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement "wedge" mode for barcode scanning
5 participants