iso8583 icon indicating copy to clipboard operation
iso8583 copied to clipboard

Unable to Read Field Values From Ascii ISO Message

Open veektorh opened this issue 2 years ago • 5 comments

I am trying to decode ISO message received from an ISO message simulator which uses Ascii format, But im unable to get it to work.

I can read the MTI successfully, but i get an empty string while trying to read any available field.

I have tried converting the bytes array buf to ascii and i can see the MTI in text and the original data elements, i cant see the bitmap properly most likely because its in binary. But i cant get the field values directly after unpacking the message.

I need help trying to read the field values using this library. Kindly Assist

Here's a snippet of my code below

``

           header := network.NewBinary2BytesHeader()
	_, err := header.ReadFrom(conn)

	buf := make([]byte, header.Length())
	_, err = conn.Read(buf)

	checkError(err)
	
	message := iso8583.NewMessage(iso8583.Spec87)
	message.Unpack(buf)

	mti, err := message.GetMTI()
	f7, err := message.GetString(7)
	f11, err := message.GetString(11)
	f123, err := message.GetString(123)
	checkError(err)

	fmt.Printf("MTI %s \n", mti)
	fmt.Printf("f7 : %s", f7)
	fmt.Printf("f11 : %s", f11)
	fmt.Printf("f123 : %s", f123)
}

veektorh avatar Jun 28 '22 18:06 veektorh

@veektorh thanks for submitting the issue.

Can you show what it's in the buf? If it's ASCII you can fmt.Println(string(buf)) Also, what is the length of the message (header.Lenght())?

alovak avatar Jul 08 '22 18:07 alovak

header.length = 63 buf = [48 56 48 48 162 56 0 0 0 128 0 0 4 0 0 0 0 0 0 0 48 48 48 48 48 48 48 55 48 56 49 57 52 50 53 48 48 48 54 52 48 54 50 50 48 55 48 56 48 55 48 56 50 48 51 57 48 48 53 57 48 48 48]

veektorh avatar Jul 08 '22 18:07 veektorh

Can you please also check for the error from message.Unpack(buf)?

alovak avatar Jul 08 '22 20:07 alovak

Error from Unpack : failed to unpack bitmap: failed to decode content for 1 bitmap: encoding/hex: invalid byte: U+00A2 '¢'

veektorh avatar Jul 09 '22 05:07 veektorh

@veektorh, were you able to solve your issue? Do you still need any help? Can I close the ticket?

alovak avatar Oct 11 '22 08:10 alovak

Isn't the issue that he is getting a cent sign 00A2 or ¢ in the message? That data element is supposed to have a number. @veektorh is it possible to get a copy of the raw message as an upload? Feel free to change the PAN. What type of system are you connecting to that possibly is sending the cent character?

wadearnold avatar Nov 03 '22 22:11 wadearnold

We discussed the issue with the @veektorh privately and it's not relevant anymore. Closing it.

alovak avatar Jun 29 '23 18:06 alovak