06-10-2015 01:02 PM
Hi All,
I'm receiving values from a bluetooth device in the form of raw U16 values. I need to convert them to a 4byte float but am having problems figuring out how to manipulate the bits in the word. As example:
Raw data 14234, 14235
Real 0.866563618183
the raw data is created in the original python program by "self.x_raw = struct.unpack_from('>4096H', buf, offset)"
the resulting "float" from the original python program : " self.X = struct.unpack_from('>2048f', buf, offset)"
I haven't seen the actual "raw" data stream yet, the python program shields me from that.
basically these two lines create two files, the raw with 4096 values, the real with 2048. This imples to me that there is a two to one relationship between the two, I'm trying to determine, basically, how the python struct.unpack_from commands with the H (indicates a "short integer") and f formats (indicates a 4 byte real, i.e an I32) would be duplicated with LabVIEW. Sorry guys, this is probably not so hard, but I'm, as usual when I ask on here, a bit sleep deprived and under the gun project timewise.
Thanks!
06-10-2015 01:30 PM
4 bytes? That is actually a Single Precision (SGL). The real question is the endianess. Is the first word the MSW or LSW? You can play around with these using Join Number to create a U32 and then type cast to a SGL.
06-10-2015 01:53 PM
according to the python literature the > in the statement indicates Bigendian.
Really didn't quote this project well, got blindsided a bit, thinking of working at that Scottish restaurant McDougal's, McDonaugh's, something like that, too tired to remember right now.
P
06-10-2015 02:15 PM
Another comment here. What you put down for Raw Data, is that the actual data or the addresses you read from? The fact that they are sequencial makes me think those are addresses.
06-10-2015 02:34 PM
I'm pretty sure that it is the "raw" data, as formatted by the python command. THose two happen to be sequential, others aren't, the last two are zero, with the cooresponding entry in the "real" file being zero as well. I meant to say "SGL" as it is a 4 byte real. Tried a few combinations of splitting U16 reps of those two numbers, joining them and casting to SGL, so far without success. Working on issue of memory manager crashes now. Argh!
06-11-2015 07:40 AM
Try these.