473,395 Members | 1,931 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

problem with left or right shift

hello everyone,
i have problem with left shift...can you solve this....


i want to write a simple function which will give output is 32 bit frame:

if input type == 0 - then output will shift left frame id by 18 bits and 31st bit as 0

eg for input configred frame id 0x7ff(111,1111,1111),
FrameID= 0x1ffc0000(0001,1111,1111,1100,0000,0000,0000,0000 )

if input type == 1 then - output will set 31st bit in FrameID

eg for input configred frame id 0x7ff(111,1111,1111),
FrameID= 0x800007ff(1000,0000,0000,0000,0000,0111,1111,1111 )
Jun 12 '07 #1
3 2166
miller
1,089 Expert 1GB
Greetings,

I do not really understand your issue. It would probably help if you included the perl code that you've already tried. Including the assignment creating the variable you're wanting to modify.

- Miller
Jun 12 '07 #2
Hello Miller,
here i am putting code.....

Expand|Select|Wrap|Line Numbers
  1. # Loop for all frames of nwi as TX slot, TX mux(if any), RX slot, RX mux.
  2. # This is to fill the remaining fields of the Can_Frame_Details hash.
  3. foreach $frm_name (@tx_frm_list, @rx_frm_list, @undec_frm_list) {
  4.     # Populating the ddCANID key.
  5.     $SptIm::Can_Frame_Details{$frm_name}{ddCANID} = $SptNetParser::Network_File_Contents_Hash{FrameNIDetails}{$ni_name}{$frm_name}{FrameId};
  6.  
  7.     # Populating the IdType key.
  8.     if ($SptNetParser::Network_File_Contents_Hash{NetInterfaceDef}{$ni_name}{Protocol} eq "CAN29") {
  9.         $SptIm::Can_Frame_Details{$frm_name}{IdType} = 1;
  10.  
  11.         # Set the Is_Extended_Can_Type to one, if CAN29 exists in NET file
  12.         $SptDbCfg::Is_Extended_Can_Type = 1;
  13.         #my problem is here if $SptIm::Can_Frame_Details{$frm_name}{IdType} = 1 #then will shift left frame id by 18 bits #and 31st bit as 0
  14.         #eg for configred frame id 0x7ff(111,1111,1111), ddCANID= #0x1ffc0000(0001,1111,1111,1100,0000,0000,0000,0000)
  15.     } else {
  16.         $SptIm::Can_Frame_Details{$frm_name}{IdType} = 0;
  17.         #if $SptIm::Can_Frame_Details{$frm_name}{IdType} = 0 then will set 31st bit #in ddCANID
  18.         #eg for configred frame id 0x7ff(111,1111,1111), ddCANID= #0x800007ff(1000,0000,0000,0000,0000,0111,1111,1111)
  19.     }
  20.  
  21.     # Populating the Position key.
  22.     $frm_ndx++;
  23.     $SptIm::Can_Frame_Details{$frm_name}{Position} = $frm_ndx;
  24. } # End of subroutine create_can_frame_details_oem
  25.  
Thank's & Regard's
Lokee
Jun 13 '07 #3
hello all,
i have solved this problem...


problem was:

#----------------------------------------------------------------------------------#
# /* Algorithm for Calculating the ddCANID */ #
#Problem: ddCANID will be calculate in two way based on protocol type #
# if (protocol equal CAN11) then #
# set IdType = 0; #
# ddCANID will be shift 18 bit left | 31st bit will be set as a 0; #
# /* eg ddCANID = 0x7ff then output will be ddCANID = 0x1ffc0000 #
# if (protocol equal CAN29) then #
# set IdType = 0; #
# ddCANID 31st bit will be set as a 1; #
# /* eg ddCANID = 0x7ff then output will be ddCANID = 0x800007ff #
#----------------------------------------------------------------------------------#
answer:

CALCULATING THE ddCANID

foreach $frm_name (@tx_frm_list, @rx_frm_list, @undec_frm_list)
{
#Populating the ddCANID key.
$SptIm::Can_Frame_Details{$frm_name}{ddCANID} =
$SptNetParser::Network_File_Contents_Hash{FrameNID etails}{$ni_name}
{$frm_name}{FrameId};

# Populating the IdType key.
if ($SptNetParser::Network_File_Contents_Hash{NetInte rfaceDef}{$ni_name}
{Protocol} eq "CAN29")
{
$SptIm::Can_Frame_Details{$frm_name}{IdType} = 1;
$SptIm::Can_Frame_Details{$frm_name}{ddCANID} | = 1 << 31;

# Set the Is_Extended_Can_Type to one, if CAN29 exists in NET file
$SptDbCfg::Is_Extended_Can_Type = 1;
}

if ($SptNetParser::Network_File_Contents_Hash{NetInte rfaceDef}{$ni_name}
{Protocol} eq "CAN11")
{
$SptIm::Can_Frame_Details{$frm_name}{IdType} = 0;
$SptDbCfg::Is_Standard_Can_Type = 0;
$SptIm::Can_Frame_Details{$frm_name}{ddCANID} << = 18 | 0 << 31;
}
}

thank's & regard's
lokee
Jun 15 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Matt | last post by:
I am new to CSS. My task is to add a table and frequently used link on the right hand side. Here's the html code and css, I really appreciate if u can copy and paste and take a look. It looks fine...
4
by: VivN | last post by:
I want to use an expression as the control source for a text box in a report (Access 2000). Whilst I have sucessfully used these simple ones =TimeToSingle(TotalHours(,))...
50
by: sabarish | last post by:
Hi to all. find out the biggest among two numbers without using any conditional statements and any relational operators.
17
by: Peter Bromley | last post by:
The following code snippet does not seem to work correcly unsigned __int64 result = 0xFFFFFFFFFFFFFFFF; result = result << 64; Debugger.WriteLine(System::String::Format(S"{0:X16}",...
2
by: Saber S | last post by:
When I press Alt+Shift in a text control, the cursor turns Right-To-Left. I want it without pressing Alt+Shift, I want to when I click a text control the cursor automatically turn to Right-To-Left.
11
by: Kenneth Lantrip | last post by:
Anyone got any ideas as to how this process could be improved for speed? this is what I have... Dim j, q As Integer Dim x(16), y(16) As Byte x.CopyTo(y, 0) ' shift left circular 24 bits
10
by: chanma | last post by:
code1:var x=0xf0000000; alert(x); output:4026531840 code2:var b=0xf<<28; alert(b); output:-268435456
2
by: pelletier.thomas | last post by:
Hello everybody. I'm trying to code a very little OS. But I have a problem with the keyboard input: It show thechar + "~" :s Can you help me ? The source is there :...
6
by: Madhur | last post by:
I am having the following problem of bit shifting. My program runs on a little endian machine. Consider that if I have the following data represented in big endian... 0x12345678 the little...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.