EBCDIC encoded messages

Jun 22, 2011 at 11:31 AM

First thanks for people wrote this simulator, helps me a lot as even we do have a HSM box to connect to, that HSM box didn't have a printer attached and I can not test ZMK generation and PIN mailer. 

I tested those using the simulator which worked out very nicely. 

I did met a problem, as our system is running on IBM so the encoding of the messages is EBCDIC, and I need to convert those into ASCII and back.  Took me a while to get it done asI know nothing about VB.NET.

Here is the changes I made in case some one interested, the changes are in bold.

In WorkerClient.VB:

send function:

Public Sub send(ByVal sendData As String)

     Dim Buffer(As Byte

     Dim ebcdicencoding As System.Text.Encoding = System.Text.Encoding.GetEncoding(37)         

     Buffer = ebcdicencoding.GetBytes("  " + sendData)

      'Fixed bug where this was behaving completely wrong.

      'Buffer = Utility.GetBytesFromString("  " + sendData)

       Buffer(0) = Convert.ToByte(sendData.Length \ 256)

Receiving Data - function MessageAssembler():

                    If recBytesOffset = len Then


                            'Set the encoding to the EBCDIC code page.


                            Dim ebcdicencoding As System.Text.Encoding = System.Text.Encoding.GetEncoding(37)

                            Dim asciiencoding As System.Text.Encoding = System.Text.Encoding.GetEncoding(0)


                            strAscii = ebcdicencoding.GetString(recBytes)

                            recBytes = asciiencoding.GetBytes(strAscii)

                            RaiseEvent MessageArrived(MerecBytesrecBytesOffset)



Jun 23, 2011 at 8:21 AM

I think that's generic enough to warrant inclusion in the simulator. Thanks for the code.

Oct 22, 2011 at 10:48 PM

Just letting you know that the EBCDIC option has been added at changeset 70688. You can download the latest dev build to get the installer.