Automotive and Embedded Networks

cancel
Showing results for 
Search instead for 
Did you mean: 

sending U8 and SGL in same message - Frame API

Solved!
Go to solution

Hi,

 

I am using the Frame API and want to send a message that contains the following information

 Payload length - 8 bytes (most likely)

byte 0 - cmd ID

byte 1 + 2  - unit ID

byte  3 - selection

byte 4-7  - coefficient

 

I have the first 4 bytes working because I take a string, convert it to byte array and insert each byte in the U8 array.  The problem that I am trying to solve is to be able to have the first 4 bytes be U8 and the next 4 bytes hold the coefficient which is stored in a single precision floating point number.  How do I setup the write message starting from position 4 in the payload to properly send the SGL coefficient?  Can a SGL be packed into the 4 byte payload?  I figured it could because 4 bytes =32 bits and a SGL is a 32 bit number.  I am confused because the Write block takes in a U8 array as the data input.

 

Thanks,

Gary

0 Kudos
Message 1 of 2
(6,411 Views)
Solution
Accepted by topic author glstill

I realized that all I need to do is cast the byte array as a single precision floating point number.

 

0 Kudos
Message 2 of 2
(6,404 Views)