mxpopstar
2022-05-03 e75ef5f04f61aa5fbd89fd5c413dcee1819b7a91
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package com.dev.ntm.cmd;
 
import java.io.UnsupportedEncodingException;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
 
public class NTM_HeartBeat 
{
    public NTM_Cmd NTM_Cmd = new NTM_Cmd();
    public String inf = "";
    public int CRC;
    
    public void putByteBuffer(final ByteBuffer bf) {
        byte[] inf_b = new byte[bf.limit()];
        bf.get(inf_b);
        try {
            inf = new String(inf_b, "utf-8");
        } catch (UnsupportedEncodingException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
    
    public ByteBuffer getByteBuffer(byte[] inf_b) {
        ByteBuffer bytebuffer = ByteBuffer.allocate(inf_b.length);
        bytebuffer.order(ByteOrder.LITTLE_ENDIAN);
        bytebuffer.put(inf_b);
        return bytebuffer;
    }
}
/***************************************************************************************
****************************** end of file (NTM_HeartBeat) *****************************
***************************************************************************************/