moov-io / iso8583

A golang implementation to marshal and unmarshal iso8583 message.
https://moov.io
Apache License 2.0
306 stars 100 forks source link

Unable to Read Field Values From Ascii ISO Message #181

Closed veektorh closed 1 year ago

veektorh commented 2 years ago

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)
}
alovak commented 2 years ago

@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())?

veektorh commented 2 years ago

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]

alovak commented 2 years ago

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

veektorh commented 2 years ago

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

alovak commented 1 year ago

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

wadearnold commented 1 year ago

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?

alovak commented 1 year ago

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