Cool. Thanks Chris. I was trying to combine the map and the rcols before, and
getting nowhere of course. I forgot about using rcols to suck it in to a perl
array.
Thanks,
CLIFF SOBCHUK
Core RF Engineering
Phone 613-667-1974 ecn: 8109-71974
mobile 403-819-9233
yahoo: sobchuk
www.ericsson.com
"The author works for Telefonaktiebolaget L M Ericsson ("Ericsson"), who is
solely responsible for this email and its contents. All inquiries regarding
this email should be addressed to Ericsson. The web site for Ericsson is
www.ericsson.com."
This Communication is Confidential. We only send and receive email on the basis
of the terms set out at www.ericsson.com/email_disclaimer
-----Original Message-----
From: Chris Marshall [mailto:[email protected]]
Sent: Tuesday, February 07, 2012 11:14 AM
To: Clifford Sobchuk
Cc: David Mertens; [email protected]
Subject: Re: [Perldl] Read Hex values into piddles and conversion hex, binary,
decimal
I made a sample input file:
pdl> #cat infut.txt
Text = 0x01765e11
Text = 0x02765e11
Text = 0x03765e11
Text = 0x04765e11
Text = 0x05765e11
Text = 0x06765e11
Text = 0x07765e11
Text = 0x08765e11
Text = 0x09765e11
Text = 0x0a765e11
Text = 0x0b765e11
Text = 0x0c765e11
and then used rcols() to read in the data as perl values:
pdl> $hex = rcols 'infut.txt', 2, { perlcols=>[2] }
Reading data into piddles of type: [ ]
Read in 12 elements.
At that point, converted the hex strings to values with map and hex with
converting to a long pdl:
pdl> $hexpdl = pdl(long, map { hex } @$hex )
pdl> p $hexpdl
[24534545 41311761 58088977 74866193 91643409 108420625 125197841
141975057 158752273 175529489 192306705 209083921]
>From here you can just use binary &, ^, | to construct the mask results. The
>pdl() constructor with string input did not accept hex numbers and rcols did
>not either. It might make sense to extend both routines to automatically
>handle those cases...
--Chris
On Tue, Feb 7, 2012 at 11:47 AM, Clifford Sobchuk
<[email protected]> wrote:
> Hi David,
> The file has a list of values of the form:
>
> Text = 0x02765e11
>
> I want to be able to take the hex value and convert it into binary so
> that I can apply a bit mask representing specific attributes such as :
>
> bbbb bfff ffff ffff cccc cccc cccc ssss
>
> As you can see from the above I can't simply take the four bits as the 'b'
> attribute is 5 bits long so I need to read in all the values, convert
> to binary so that i can mask/map the required bit pattern to get my attribute.
>
> I am trying to place the code in to an existing PDL code portion so
> was hoping to be able to read the values from the file at the same
> time and perform the conversion in to the respective attributes using
> PDL. If not I will just perform it separately and convert them all to piddles
> at the end.
>
> B=bbbb b
> F= FFF FFFF FFFF
> C= CCCC CCCC CCCC
> S= SSSS
>
> Does that make sense?
>
> CLIFF SOBCHUK
> Core RF Engineering
> Phone 613-667-1974 ecn: 8109-71974
> mobile 403-819-9233
> yahoo: sobchuk
> www.ericsson.com
>
> "The author works for Telefonaktiebolaget L M Ericsson ("Ericsson"),
> who is solely responsible for this email and its contents. All
> inquiries regarding this email should be addressed to Ericsson. The
> web site for Ericsson is www.ericsson.com."
>
> This Communication is Confidential. We only send and receive email on
> the basis of the terms set out at www.ericsson.com/email_disclaimer
>
>
>
> ________________________________
> From: David Mertens [mailto:[email protected]]
> Sent: Tuesday, February 07, 2012 9:38 AM
> To: Clifford Sobchuk
> Cc: [email protected]
> Subject: Re: [Perldl] Read Hex values into piddles and conversion hex,
> binary, decimal
>
> I'm not quite sure what you mean. Do you have working pure-Perl code
> that does what you want?
>
> David
>
> On Tue, Feb 7, 2012 at 10:34 AM, Clifford Sobchuk
> <[email protected]> wrote:
>>
>>
>> Hi Folks,
>>
>> Is there a way to be able to read in hex values in to piddles so that
>> they can be bitmasked and then each bitmask portion converted to
>> decimal or is this a Perl only operation. I thought that there would
>> be a way with transform, but reading in the data will include
>> 0x[0-9a-f] which PDL typically didn't recognize as valid values.
>>
>> Thanks,
>>
>> CLIFF SOBCHUK
>> Ericsson
>> Core RF Engineering
>> Calgary, AB, Canada
>> Phone 613-667-1974 ECN 8109 x71974
>> Mobile 403-819-9233
>> [email protected]
>> yahoo: sobchuk
>> http://www.ericsson.com/
>>
>> "The author works for Telefonaktiebolaget L M Ericsson ("Ericsson"),
>> who is solely responsible for this email and its contents. All
>> inquiries regarding this email should be addressed to Ericsson. The
>> web site for Ericsson is www.ericsson.com."
>>
>> This Communication is Confidential. We only send and receive email on
>> the basis of the terms set out at www.ericsson.com/email_disclaimer
>>
>>
>>
>> _______________________________________________
>> Perldl mailing list
>> [email protected]
>> http://mailman.jach.hawaii.edu/mailman/listinfo/perldl
>>
>
>
>
> --
> "Debugging is twice as hard as writing the code in the first place.
> Therefore, if you write the code as cleverly as possible, you are,
> by definition, not smart enough to debug it." -- Brian Kernighan
>
>
> _______________________________________________
> Perldl mailing list
> [email protected]
> http://mailman.jach.hawaii.edu/mailman/listinfo/perldl
>
_______________________________________________
Perldl mailing list
[email protected]
http://mailman.jach.hawaii.edu/mailman/listinfo/perldl