I am learning how to use the OpenISO8583.Net code. I have derived a new ISO8583 class from the original one. One of the differences in my new class is that the Message Type field is going to be [Numeric, BCD]; so I wrote this as part of the class contructor (I do have a custom DefaultTemplate declared as part of the class):
DefaultTemplate.MsgTypeFormatter = Formatters.Bcd;
I created a new message with a message type of 0100 (MsgType._0100_AUTH_REQ). Without assigning any other bits.
FDISO8583 fdISO8583 = new FDISO8583();
fdISO8583.MessageType = FDISO8583.MsgType._0100_AUTH_REQ;
byte[] testMsg = fdISO8583.ToMsg();
My ending result byte array is: 01-00-00-00-00-00-00-00-00-00 which I think is correct. First 2 bytes for the message type with the BCD value and the bitmap is all zeroes.
Now the problem is when I test unpacking it. Using:
fdISO8583 = new FDISO8583();
int pos = fdISO8583.Unpack(testMsg, 0);
The resulting message type gets a value of zero.
I need help understanding if this is a problem on the way I defined the class or a bug in the ISO8583 code.
You have indeed found a bug. I logged it as Issue 13 and have fixed it. I have release version 0.5.2 on nuget and uploaded the bin file to the googlecode project.