Convert String to Hexadecimal for RFID S’abonner

0
Avatar
Andrew Burns

I am looking to convert a Database Field that is a String to Hexadecimal for an encoded RFID tag. I've been able to hardcode in a value for the RFID tag to allow for a few test prints, but now I am having trouble moving on to the next step of encoding fro ma database field.

The challenges I am currently facing are:

  • The string does not fit cleanly into the 24-bit encoded value
  • The hex string must terminate with a null character

 

When I hardcoded the value, I did the following:

  1. Started with the string "1PYKY459O".
  2. Converted the string to hex, which gave me "315059504b593435394f"
  3. Padded the right side with null characters until I hit the necessary 24 bits and got "315059504b593435394f0000"

My question is, how can I follow this same process? I assume I will have to use a VBScript transform on the field data. There does seem to be a built in hex converter, but it does not accept a string as a parameter.

I apologize if I have used any terms or concepts incorrectly. I have little to no experience with RFID and am trying my best to figure out a solution to this problem. Thank you for any assistance you can provide.

1 commentaires

1
Avatar
Pete Thane
Actions pour les commentaires Permalien

Hi Andrew,

Your hex string in line 2 is incorrect as you have an extra 50 (P) in the string after the first Y (59).

You need to convert the string to Ascii and then to hex and then set the filed add the Truncation > minimum 24 pad with 0 to the right.

Depending on where the data is coming from you may need to use and Event Controlled Script but for my code below i added a field that I call TheBaseData and entered the 1PYKY459O to that.

My VB is

Value = Format.NamedSubStrings("TheBaseData").Value

Value1 = Len(Value)

For i = 1 To Value1
Value2 = Value2 & Hex(CStr(Asc(Mid(Value, i, 1))))
Next

Value = Value2

I hope this helps

 

Vous devez vous connecter pour laisser un commentaire.