PDA

View Full Version : READU_32 doesn't work



phillipsqh
12-09-2009, 04:02 PM
I'm trying to read 32 bit data on a 64 bit machine.
If I try to read in a byte string with readu_32 as intarr it only reads two bytes but if I make it lonarr it reads in 8. The readu_32 doesn't do anything!!!

rwagner
12-11-2009, 12:25 PM
Hi Phillip,
Please run the following code on both 32 and 64 bit machines. Supply the keyword rw='write' on the 32 bit machine, and rw='read' on 64. It will print out the versions of PV-WAVE you're running. Several bug fixes were included in the latest releases of PV-WAVE.
-Ryan






pro create32, rw=rw
if rw eq 'write' then begin
print, !Version
openw, u, 'test32', /Get_Lun
writeu, u, lindgen(10)
free_lun, u
endif else begin
print, !Version
openr, u, 'test32', /Get_Lun
a = lonarr(10)
;Endian = 1 for linux, 0 for most unix's
readu_32, u, endian=1, a
free_lun, u
print, a

openr, u, 'test32', /Get_Lun
readu_32, u, endian=0, a
free_lun, u
print, a
endelse
end

phillipsqh
12-11-2009, 01:23 PM
I do not have access to a 32 bit machine running wave, but it doesn't really matter where the data came from, suffice it to say I have 32 bit data written out that I can't read back in easily!
The linux version is
x86_64 linux64 9.01 linux
If I take a byte string and feed it into the readu_32 command I can only get it to read 2 bytes or 8 bytes but never 4 bytes!
I can hack it with fix(var(0:3),0) and get my info but this is really a pain when have very large structures.

rwagner
12-11-2009, 03:42 PM
On 32...


WAVE> openw, u, 'test32', /get
WAVE> writeu, u, bindgen(12)
WAVE> free_lun, u


On 64



WAVE> openr, u, 'test32', /get
WAVE> a = lonarr(3)
WAVE> readu_32, u, a, endian=0
WAVE> free_lun, u
WAVE> print, a
216736831578832896 506097522863767552 795458214148702208
WAVE> openr, u, 'test32', /get
WAVE> a = lonarr(3)
WAVE> readu_32, u, a, endian=1
WAVE> free_lun, u
WAVE> print, a
50462976 117835012 185207048
WAVE> openr, u, 'test32', /get
WAVE> a = lonarr(4)
WAVE> readu_32, u, a, endian=1
% READU: End of file encountered. Unit: 100
File: test32
% Error occurred at READU_32 <readu_32.pro( 54)> (READU).
% Called from $MAIN$ .





The above code demonstrates reading a 32-bit architecture's byte stream into 4 byte chunks with readu_32 and was run on successfully on a linux-64 system. You'll have to send a code sample and data file to support@vni.com for further assistance.

phillipsqh
12-14-2009, 01:43 PM
Using the same test example...

openr, u, 'test32', /get
my_struct={ ,a:0,b:0,c:0}
readu_32,u,my_struct, endian=0
print,my_struct
{ 256 770 1284}


openr, u, 'test32', /get
my_struct={ ,a:0l,b:0l,c:0l}
readu_32,u,my_struct, endian=0
READU: End of file encountered.

donb
12-15-2009, 12:51 PM
That's correct. From the PV-WAVE documentation for the READ procedures, in the NOTE at the top of the description:

READU_32 cannot read structures from a binary file. To read a structure, you must read them elementwise.

Don B.

donb
12-16-2009, 08:17 AM
A follow-on to my previous post in this thread...

For those looking in the PV-WAVE documentation to find the NOTE??? It's not there :(

The reason is, the PV-WAVE development team has been working very hard on the next release. A good part of that work naturally involves updates to the documentation. While reading this particular forum thread I was as the same time doing some documentation review for the next release.

My apologies for any confusion this may have caused!

Regardless, the answer for this thread remains the same: READU_32 is not designed to read STRUCTURE data types.