jlcout / epctagcoder Goto Github PK
View Code? Open in Web Editor NEWJava library for RFID EPC encode / decode
Home Page: https://jlcout.github.io/epctagcoder
License: Apache License 2.0
Java library for RFID EPC encode / decode
Home Page: https://jlcout.github.io/epctagcoder
License: Apache License 2.0
The readme claims support for SGCN - Serialized Global Coupon Number
but these classes seem missing from the source (0.0.8) ?
Also, when recompiling the source, it seems missing the EPCParseException exception class.
I created the following locally. I don't know if there was more to it?
package org.epctagcoder.exception;
public class EPCParseException extends Exception {
String _message;
public EPCParseException(String message) {
_message = message;
}
public String Message() {
return _message;
}
}
Also, there were a few compile issues due to the lack of some "throws Exception" declarations at some parse/Builder declarations.
Hi,
Thanks for a great framework. It saves us a lot of time.
It works great, but it seems that there are certain formats that are not supported when parsing a chipcode.
At least some of the chips that I have to scan fail to be understood. I'm not sure if it is the chips that have been coded wrong by the manufacturer or because epctagcoder currently supports 1.9 and the Tag Data standard is at 1.13? Maybe something third?
For example following RFID codes
3000E2009A9040060AF000000372
3000E2009A9040060AF000003060
When using https://www.gs1.org/services/epc-encoderdecoder seems to work.
3000E2009A9040060AF000000372 -> EPC Tag URI = urn:epc:tag:sgtin-96:0.242668184592.0.25953304576
But I am having problems when I use the following in my unit test
...
ParseSGTIN parseSGTIN = ParseSGTIN.Builder().withRFIDTag(chipCode).build();
if ("sgtin".equals(parseSGTIN.getSGTIN().getEpcScheme())) {
StringBuilder sb = new StringBuilder("urn:epc:tag:sgtin-");
sb.append(parseSGTIN.getSGTIN().getTagSize());
sb.append(":");
sb.append(parseSGTIN.getSGTIN().getExtensionDigit());
sb.append(".");
sb.append(parseSGTIN.getSGTIN().getCompanyPrefix());
sb.append(".");
sb.append(parseSGTIN.getSGTIN().getFilterValue());
sb.append(".");
sb.append(parseSGTIN.getSGTIN().getSerial());
return sb.toString();
}
...
The first issue is that the RFID code causes a NumberformatException as 242668184592 in too big for an Integer.
java.lang.NumberFormatException: For input string: "242668184592"
at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
NumberFormatException.java:65
at java.base/java.lang.Integer.parseInt(Integer.java:652)
If I change the code and remove Integer.parseInt() in line 176 and use the String version of Converter.decToBin the code can continue. But the problem is that the serial is then incorrect? I get
EPC Tag URI: urn:epc:tag:sgtin-96:0.242668184592.0.1700875768693618
It seems that the serial is different than https://www.gs1.org/services/epc-encoderdecoder?
Thanks again for this project.
There is no way to encode/decode TID and USER MEMORY!
Hi,
Congratulations for the library, it's very useful. Actually, I'm trying to implements the GIAI encoding but I haven't found nothing about this in this library but in the README appears.
Can you help me with this?
Thank you so much.
Regards.
Hi, this is a really useful library, many thanks! (Have you thought about getting it on Maven?)
Anyway, I'm having a problem where I've got a tag URI, and I want to build another one based on the information in the first one (replacing the first digit in the individual asset reference).
I've therefore got:
String aTagUri = "urn:epc:tag:giai-96:1.1234567.2987654321987";
ParseGIAI parserTagSeen = ParseGIAI.Builder().withEPCTagURI(aTagUri).build();
giaiSeen = parserTagSeen.getGIAI();
ParseGIAI parserTagMaster = ParseGIAI.Builder().withCompanyPrefix(giaiSeen.getCompanyPrefix()).withIndividualAssetReference("9"+giaiSeen.getIndividualAssetReference().substring(1)).withTagSize(GIAITagSize.valueOf(giaiSeen.getTagSize())).withFilterValue(GIAIFilterValue.valueOf(giaiSeen.getFilterValue())).build();
Note the withTagSize step requires an enumerated value, not a string.
However, I then get the error:
Failed to parse tag 'urn:epc:tag:giai-96:1.1234567.2987654321987':
java.lang.IllegalArgumentException: No enum constant org.epctagcoder.option.GIAI.GIAITagSize.96
at java.lang.Enum.valueOf(Enum.java:240) ~[?:?]
at org.epctagcoder.option.GIAI.GIAITagSize.valueOf(GIAITagSize.java:6) ~[epctagcoder-0.0.6-SNAPSHOT.jar:?]
at <my code location> [classes/:?]
I imagine this is because valueOf isn't implemented for the enumerated type? Can it be? Or is there another/better way of getting from a string to a GIAITagSize?
(An alternative method is to add a get/set to ParseGIAI for individualAssetReference - this makes it possible to build the new tag using withEPCTagURI and the original uri, then setIndividualAssetReference on that. But that seems to be a long-winded way of doing it...)
(edit) Or, I suppose, creating a GIAI#getGiaiTagSize method that returns a GIAITagSize?
When using org.epctagcoder.parse.GIAI.ParseGIAI.Builder()
to create a new instance, setting an invalid RFID tag in the method org.epctagcoder.parse.GIAI.ParseGIAI.ChoiceStep.withRFIDTag(String)
produces a NullPointerException
when finally calling org.epctagcoder.parse.GIAI.ParseGIAI.BuildStep.build()
method.
For example, the following snippet will fail:
ParseGIAI.Builder()
.withRFIDTag("anyNonComplaintValue").build()
.getGIAI()
Instead of null
, the org.epctagcoder.parse.GIAI.ParseGIAI.BuildStep.build()
method might throw a ParseException
(or any other dedicated exception) or even better, it could return a java.util.Optional
to be easier to check the result of the parsing.
Thank you for this awesome library!
Olá Coutinho, tudo bem?
Gostaria de verificar a possiblidade de um decoder do EPC, sem precisar saber o padrão da GS1, no qual foi realizado no encoder.
Exemplo: No serviço de ENCODER/DECODER da GS1, só de informar o código do EPC já é retornado o GS1 Key (padrão) e outros dados durante o decoder. https://www.gs1.org/services/epc-encoderdecoder
Gostaria de saber se o epctagcoder já possui essa funcionalidade genérica, sem a necessidade de saber qual parse devo instanciar.
Agradeço! Abraco!
I was trying out different EPCs and ran into an error. If the checkdigit=0, then code was throwing an error on out of bounds. After troubleshooting it I noticed it was happening on the calculation of the check digit and found it was caused by the value of item reference not having enough digits. The leading 0's from item reference were getting dropped. I noticed you had a function to fill those, so I tried it and it fixed issue.
After this line
String itemReferenceWithExtensionDec = Converter.binToDec(itemReferenceWithExtensionBin);
I added this
itemReferenceWithExtensionDec = Converter.strZero(itemReferenceWithExtensionDec, tableItem.getDigits());
Nervin
I ran into a tag urn:epc:id:sscc:4610052.9000000007
. I'm pretty sure the tag correct. But the following code fails:
ParseSSCC.Builder()
.withEPCPureIdentityURI("urn:epc:id:sscc:4610052.9000000007")
.withTagSize(SSCCTagSize.BITS_96)
.withFilterValue(SSCCFilterValue.RESERVED_5)
.build();
java.lang.IllegalArgumentException: EPC Pure Identity is invalid
at org.epctagcoder.parse.SSCC.ParseSSCC.parse(ParseSSCC.java:119)
at org.epctagcoder.parse.SSCC.ParseSSCC.<init>(ParseSSCC.java:47)
at org.epctagcoder.parse.SSCC.ParseSSCC.<init>(ParseSSCC.java:20)
at org.epctagcoder.parse.SSCC.ParseSSCC$Steps.build(ParseSSCC.java:266)
...
For example, the following entry:
(source: http://www.kentraub.net/tools/tagxlate/EPCEncoderDecoder.html)
But Im getting this result:
"epcScheme": "sscc"
"applicationIdentifier": "AI 00"
"tagSize": "96"
"filterValue": "6"
"partitionValue": "5"
"prefixLength": "7"
"companyPrefix": "9999999",
"extensionDigit": "7"
"serial": "000000058"
"checkDigit": "3"
"epcPureIdentityURI": "urn:epc:id:sscc:9999999.7000000058"
"epcTagURI": "urn:epc:tag:sscc-96:6.9999999.7000000058"
"epcRawURI": "urn:epc:raw:96.x31D66259FDA13B863A000000",
"binary": "001100011101011001100010010110011111110110100001001110111000011000111010000000000000000000000000",
"rfidTag": "31D66259FDA13B863A000000" }
Resumo
31D66259FDA13B863A000000 (it is the wrong result)
31D66259FC00000005000000 (its the right result)
Sorry for my English.
add a catch when an invalid EPC tag is sent such as not being 96 bits or 128 bits, currently a null pointer is thrown
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.