can_message_t StdTxMsg23 = {
.cs = 0U,
.id = TX_MSG_ID_23,
.data[0] = ExtRxMsg12.data[0],
.data[1] = ExtRxMsg12.data[1],
.data[2] = ExtRxMsg12.data[2],
.data[3] = ExtRxMsg12.data[3],
.data[4] = ExtRxMsg12.data[4],
.data[5] = ExtRxMsg12.data[5],
.data[6] = ExtRxMsg12.data[6],
.data[7] = ExtRxMsg12.data[7],
.length = 8U
};
But i would also like to monitor and manupulate at bit level in each of these bytes. So, can you please help me with syntax or something through which i can enable this manupulation.
Ex : CAN FRAME
ID: 0x301
Length: 8 Bytes
DATA : 0xFF 0x00 0x35 0x55 0x00 0xFF 0x89 0xCD
Byte 6 from the above frame is 0x89 when converted to binary it is 1000 1001 .
So, in this frame i want to check whether the Bit 3 is 1 or 0 in this case it is 1 and if i want to change the Bit 2 to 1 or 0. How can i do this part. Please help me how can i do this level of monitoring and manupulation.
解決済! 解決策の投稿を見る。
I don't quiet understand your question, there is no difference between my last reply.
.data[6] = (ExtRxMsg12.data[6] >> 3) & 0x01;// read 0x89 bit3
.data[6] = ExtRxMsg12.data[6] | (0x01 << 2);// set 0x89 bit2 to 1,10001101
.data[6] = ExtRxMsg12.data[6] & (~(0x01 << 2));//set 0x89 bit2 to 0,10001001
for example: 0x89
uint8_t Bit_3 = (0x89 >> 3) & 0x01;// read 0x89 bit3
uint8_t Bit_2 = 0x89 | (0x01 << 2);// set 0x89 bit2 to 1,10001101
uint8_t Bit_2 = 0x89 & (~(0x01 << 2));//set 0x89 bit2 to 0,10001001
Hi @Senlent
But the 0x89 is not an ID of the frame and it is not static value. It is the value of a varying (hexadeceimal) Byte 6 of the CAN Frame with ID 301. S0, and if i try to manupulate the bit inside that byte 6 (0x89) then the value of that also changes.
In my Example
ExtRxMsg12.data[6] = 0x89 . So, my question was how can i manupulate the bit values in the ExtRxMsg12.data[6] which is mapped to the 0x301 ID can frame's Byte 6 indicator.
I don't quiet understand your question, there is no difference between my last reply.
.data[6] = (ExtRxMsg12.data[6] >> 3) & 0x01;// read 0x89 bit3
.data[6] = ExtRxMsg12.data[6] | (0x01 << 2);// set 0x89 bit2 to 1,10001101
.data[6] = ExtRxMsg12.data[6] & (~(0x01 << 2));//set 0x89 bit2 to 0,10001001
Hi @Senlent
Sorry if i couldn't able to communicate my issue properly.
But the recent reply where you replaced the 0x89 with ExtRxMsg12.data[6]. This makes more sense to me.
What i was saying in the earlier message was that we can't use 0x89 as a Byte 6 indicator because it will be varrying and i thought it should be inidated with a proper Byte 6 assigned indicator which is ExtRxMsg12.data6. So with your latest reply i got the answer what i am looking for. So, i will try this approach and get back to you if i require any further support
Thank You