ewhitebloom / iso8583py

Automatically exported from code.google.com/p/iso8583py
GNU General Public License v3.0
0 stars 0 forks source link

Binary data on field 52 #5

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Hello, this is not an actual issue, I'm sorry, but didn't find another
place to ask:

I'm planning to use iso8583py in a django project as a middleware between
the mobile clients(who send http requests) and a JPOS who make the actual
connections with the Switch.

For that I need to send to the JPOS server a message with a binary field
52, where the 6 digits NIP goes, for that I do something like: 
msg.setBit(52,123456)
msg.redefineBit(52, '52', msg.getLargeBitName(52), 'B', 6,"n" )

So far so good, in the JPOS server I got:

<field id="52" value="0000000000123456" type="binary"/>

The problem is: that value is not the binary representation of the NIP, in
java I would do:

msg.set(52, "123456".getBytes());

I have searched the web but I haven't found anything like that for python,
what do you use?

Ah, BTW, I wrote something like the ISOMUX of JPOS, I made it based on
Queue.Queue() and it have a really nice performance, when I test it a  bit
more I will send it to you, in case it helps.

good luck

Original issue reported on code.google.com by cae...@gmail.com on 23 Feb 2010 at 7:35

GoogleCodeExporter commented 8 years ago
I found the solution:
import binascii
bin_nip = binascii.b2a_hex(nip)

Original comment by cae...@gmail.com on 23 Feb 2010 at 8:51

GoogleCodeExporter commented 8 years ago
So I recommend like this in redefineBit():

if bitType == "B":
   self.setBit(bit,binascii.b2a_hex(self.getBit(bit)))

I guess that "B" means binary

Original comment by cae...@gmail.com on 23 Feb 2010 at 9:04

GoogleCodeExporter commented 8 years ago
And of course, here:
def __setBitTypeB(self, bit, value):
         value = "%s" % binascii.b2a_hex(value)

Original comment by cae...@gmail.com on 23 Feb 2010 at 10:59

GoogleCodeExporter commented 8 years ago
Hi,
This happened because ISO8583py work with ASCII data, not Binary.
We'll improve the library and deal with Binary Data, like you can see in TODO 
file.
Thanks,

Original comment by igo...@gmail.com on 11 May 2010 at 5:17