This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] TMS320F280025:CANbus,浮点对点字符类型的对话,反之亦然

Guru**** 2572775 points
Other Parts Discussed in Thread: TMS320F28379D

请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/microcontrollers/c2000-microcontrollers-group/c2000/f/c2000-microcontrollers-forum/1085750/tms320f280025-canbus-floato-to-char-type-conversation-and-vice-versa

部件号:TMS320F280025
“线程”中讨论的其它部件:TMS320F28379D

我正在使用2块 TMS320F28379D 板进行 CAN 总线通信,因为它占用了16位地址空间,而我正面临将浮点转换为 CHAR 的问题。

//发送部件,f 是要发送的浮点值,f= 151.71 , txMsgData 是无符号字符的数组  

PTR=& f;// PTR 是 int Pinter,f 是浮点值

txMsgData[0]=(*PTR>>0)&0xff;
txMsgData[1]=(*PTR>>8)&0xff;

PTR++;
txMsgData[2]=(*PTR>>0)&0xff;
txMsgData[3]=(*PTR>>8)&0xff;


CAN_sendMessage (CANB_BASE,TX_MSG_OBJ_ID,MSG_DATA_Length, txMsgData);

 这是 CAN 分析仪发送的值,相当于 f =151.71。

//接收零件时  

 我收到了正确的发送值。

现在,我如何将 rxMsgData 转换 为 float,以便我可以将 float 值用于我的代码!!!

我尝试了直接复制,但对于 memcpy 和指针,复制为16位,而不是8位。