aungmyo / iso8583py

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

Value error while parsing a bitmap with \x20 #10

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Here is the 0820 message that I generated. Notice that I omitted the length and 
that the first 4 bytes are the MTI. (this string wear produced with pprint().

'0820\x82 
\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00\x10\x00\x00\x00021717045803156330108250
00344'

It's not interesting to note that the 6th-byte of the message or the 2nd-byte 
of the bitmap field resolved to a \x20 or a space.

when __getBitmapFromStr() attempted to parse the first byte in this code:

if (int(bitmap[0:2],16) & self._BIT_POSITION_1)  .....

I receive a value error because int() does not like the space in the string. 
For example try these:

int("\x82\x20")
int("\x82 ")

They are the same value and they both generate the error. I think you should 
consider using the struct.unpack() instead of int().

Original issue reported on code.google.com by rich...@bucker.net on 17 Feb 2012 at 11:03

GoogleCodeExporter commented 9 years ago
btw: don't panic but the message will not parse completely in ISO8583. The 
message spec is 8583-like but that's it.

Original comment by rich...@bucker.net on 17 Feb 2012 at 11:07

GoogleCodeExporter commented 9 years ago
Hi, Did you generate this ISO8583 whith the ISO8583py library? 

Or are trying to parse a 8583-like with the library?

Original comment by igo...@gmail.com on 18 Feb 2012 at 7:00

GoogleCodeExporter commented 9 years ago
Seems that this project expects the bitmap in binary coded hexidecimal?

The spec I'm coding to is strict binary. 

/r

Original comment by rich...@bucker.net on 18 Feb 2012 at 9:40

GoogleCodeExporter commented 9 years ago
Thank for the information.
This library expects 100% ASCII values, So you cannot parse this kind of 
ISO8583-like package without change the source code. 
Work with Binary Data (Bitmap and bits) are in the TODO list.
I'll close this issue because isn't a Bug, but a request for feature.
Best regards,

Original comment by igo...@gmail.com on 19 Feb 2012 at 10:02