/* special address description flags for the CAN_ID */
#define CAN_EFF_FLAG 0x80000000UL /* EFF/SFF is set in the MSB */
#define CAN_RTR_FLAG 0x40000000UL /* remote transmission request */
It looks like the MSB bits of the ID are used. The ID is only 29 bits and stored in a 32 bit variable which leaves 3 bits for additional information.
Just a SWAG but CAN will not work without a responder. You made no mention of anything on the network, its topology etc. A schematic, not a frizzy drawing would help as would all of the code.
canMsg1.can_id = 0x0F6; // standard ID
canMsg1.can_id = 0x800000F6UL; // extended ID
You could use the define and logic OR it with the ID if you wanted to make the code more explicit. I did not try this, but I believe this should work. This will be computed at compile time and should result in the same code as above.
canMsg1.can_id = 0xF6 | CAN_EFF_FLAG; // extended ID
Klaus_K:
Ben okurken sadece bayrağı ayarlamanız gerekiyor. Örneğin , kodu daha açık hale getirmek istiyorsanız, tanım ve mantığı VEYA bunu ID ile kullanabilirsiniz. Bunu denemedim ama işe yaraması gerektiğine inanıyorum. Bu, derleme zamanında hesaplanacak ve yukarıdaki ile aynı kodla sonuçlanacaktır.
canMsg1.can_id = 0x0F6; // standard ID
canMsg1.can_id = 0x800000F6UL; // extended ID
canMsg1.can_id = 0xF6 | CAN_EFF_FLAG; // extended ID
thank you so much. What if ext and rtr were used at the same time?
I'll even tell you my rtr and ext code. Can you adapt it?
rtr 0
ext 1
In case you do not know/remember how binary logic works, it is not complicated and very useful for microcontroller programming. You can use the Windows 10 Calc to play with it. Switch to programmers mode and you will find all the basic functions (AND, OR, ..., Shift) as well as numbers in all the number formats (binary, decimal, hexadecimal).