private String getCommand(String command, String data)
    {
       // Service.WriteLog("сформировал команду");
        byte[] dataByte = null;

        if (data != null && data.length() > 0)
        {
            dataByte = HexTools.fromHexString(data);
        }

        byte[] comm = HexTools.fromHexString(command);
        int length = 6;

        if (dataByte != null)
            length += dataByte.length;
        //log("length:"+length);
        byte[] packet = new byte[length];

        packet[0]=0x2;
        packet[1]=0x3;
        packet[2]=(byte)length;
        packet[3]=comm[0];

        if (data!=null)
        {
            for (int i=0; i<dataByte.length; i++)
            {
                packet[(4+i)]=dataByte[i];
                //log("dataByte[i]"+dataByte[i]);
            }
        }

        byte[] crc = HexTools.getCRC16(packet, length-2, 0x8408);
        packet[length-2] = crc[1];
        packet[length-1] = crc[0];

        return HexTools.getHexString(packet, length);
    }