python-barcode icon indicating copy to clipboard operation
python-barcode copied to clipboard

Basic support for MSI / Plessey

Open petaflot opened this issue 3 years ago • 8 comments

also allows encoding of strings and bytestrings (allows encoding any symbol) by converting them to int ; in this case, string representation is shown in human-readable string

petaflot avatar Dec 10 '22 13:12 petaflot

#190

petaflot avatar Dec 10 '22 13:12 petaflot

Codecov Report

Base: 80.63% // Head: 79.36% // Decreases project coverage by -1.26% :warning:

Coverage data is based on head (ba6ce09) compared to base (f3a7046). Patch coverage: 39.28% of modified lines in pull request are covered.

:exclamation: Current head ba6ce09 differs from pull request most recent head 943acae. Consider uploading reports for the commit 943acae to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #191      +/-   ##
==========================================
- Coverage   80.63%   79.36%   -1.27%     
==========================================
  Files          17       17              
  Lines         888      916      +28     
==========================================
+ Hits          716      727      +11     
- Misses        172      189      +17     
Impacted Files Coverage Δ
barcode/codex.py 77.18% <37.03%> (-6.06%) :arrow_down:
barcode/__init__.py 96.00% <100.00%> (+0.08%) :arrow_up:

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.

codecov[bot] avatar Dec 10 '22 14:12 codecov[bot]

it's not standard at all (hence the new defaults). it's a workaround because no 1D barcode that I know of can encode arbitrary bytes (at most a variant of extended ASCII)

the MSI barcode will encode just an int (hence the new default values for "byteorder" and "encoding" : the user must force this workaround, otherwise an exception will be raised at init. I specifically chose to use MSI for this purpose, because since it normally allows only integer encoding the risk of confusion is minimal (user has to explicitly force the conversion : the same approach with ie. Code128 would get very confusing)

does this seem like a reasonable approach? it's a quite inefficient method of encoding data (mostly because of BCD being inefficient in itself) but if the purpose is just to encode short strings it's acceptable. the code could be extended to split longer strings on multiple lines (sort-of like DataBar does) that could be read sequentially.

petaflot avatar Dec 10 '22 16:12 petaflot

also, from https://www.dynamsoft.com/blog/insights/the-comprehensive-guide-to-1d-and-2d-barcodes/ :

MSI Codes are used in inventory management to mark shelves and containers to identify storage locations.

Industry

    Inventory
    Warehousing

This basically means that MSI codes are used "internally" by organizations, so it is unlikely that any "consumer" will stumble on such a code (those codes are used in a specific context) ; this is - again - less chance for confusion

printing the decoded string under the barcode lessens even more the risk of confusion

FIY, for displaying bytestrings that cannot be decoded (I have a great deal of those), I wrote https://github.com/petaflot/bytes_as_braille ; I am likely to add a "label" argument to MSI.init() to let the user specify the label - I didn't want to make bytes_as_braille a dependency of python-barcode

petaflot avatar Dec 10 '22 16:12 petaflot

  • added type hints
  • removed option to encode strings (it's not standard and other barcode types can do it better)
  • default encoding to 'utf-8' again to limit risk of confusion
  • user-specifiable label

petaflot avatar Dec 10 '22 17:12 petaflot

The JsBarcode project includes multiple implementations of MSI:

  • MSI
  • MSI10
  • MSI1010
  • MSI11
  • MSI1110

rmkane avatar Apr 06 '23 19:04 rmkane

The JsBarcode project includes multiple implementations of MSI:

* MSI

* MSI10

* MSI1010

* MSI11

* MSI1110

isn't that javascript?

petaflot avatar Apr 10 '23 16:04 petaflot

The JsBarcode project includes multiple implementations of MSI:

* MSI

* MSI10

* MSI1010

* MSI11

* MSI1110

isn't that javascript?

It is, but porting the code over to Python would be an easy task. I was just citing it as an implementation of MSI.

rmkane avatar Apr 10 '23 16:04 rmkane