Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CRC-16 PTI voice pick code 2

Status
Not open for further replies.
Sep 17, 2001
672
0
0
US
I am having trouble getting the CRC-16 value I know I should get for a PTI voice pick code. I tried this:

?SYS(2007,"1085051000201146587443HG234",-1,0)
which returns: 59341 (0x9F9E)
the value I want is: 26359 (0x66F7)


This is the string value I am passing: "1085051000201146587443HG234"

I went to this site to get the data pasted below:

From the site above I get the value I seek but I want to do this in native FoxPro. It seems that the SYS(2007) is using CCITT.

"1085051000201146587443HG234"
1 byte checksum 137
CRC-16 0x66F7 *** This is the value I want
CRC-16 (Modbus) 0x8F90
CRC-16 (Sick) 0xB458
CRC-CCITT (XModem) 0x9F9E ** This is the value that FoxPro SYS(2007) gives me
CRC-CCITT (0xFFFF) 0xE7CD
CRC-CCITT (0x1D0F) 0x74F8
CRC-CCITT (Kermit) 0x6A3E
CRC-DNP 0x9288
CRC-32 0xC022DBE4

Here is the info gathered some info from:

Help Formulating a Voice Pick Code

How do i accomplish the following? i found the "Directions", but they are way above me.

i need to calculate a 4 Digit code from a string of numbers and characters.

--------------- Directions from online -----------------------

Compute PlainText.

a. PlainText is the 14 digit GTIN appended by the Lot Code and the Date (where present).


b. Do not include the application identifier prefixes or parentheses.

c. There are no spaces between the GTIN, Lot and Date fields.

d. Date if present is represented as YYMMDD with zero packing and no '/' characters.

Compute ANSI CRC-16 Hash of the PlainText ASCII bytes using the standard ANSI CRC-16 hash with the polynomial of X16 + X15 + X2 + 1

Compute the VoiceCode by from the Hash by taking the 4 least significant digits in decimal form (Hash mod 10000)

---------------------- Example: --------------------

GTIN = (01) 10850510002011


Lot = (10) 46587443HG234
PlainText = 1085051000201146587443HG234
VoiceCode = 6359
Large Digits = 59
Small Digits = 63


Regards,

Rob
 
Yes, the results fit the CRC-CCITT values:

? Transform( Val(Sys(2007,"1085051000201146587443HG234",0x0000,0)),"@0") && -> E7CD
? Transform( Val(Sys(2007,"1085051000201146587443HG234",0xffff,0)),"@0") && -> E7CD
? Transform( Val(Sys(2007,"1085051000201146587443HG234",0x1d0f,0)),"@0") && -> 74F8

Bye, Olaf.

 
Wow, you saved me! Bless you for this! I was up for many hour scratching my head on this one. I was about to have to turn to some other language like C. Thank you so very much. Now I can complete my native FoxPro PTI label program. I will be posting this to VXFP and other places so everyone can have FREE PTI labels. I can't tell you how many times my fellow tek-tip friends have helped me. This includes you so star for you!

Regards,

Rob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top