Bluecell_BootProtocol.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. namespace RF_TRIO_PLL_ZIG
  7. {
  8. public enum Bluepro_t
  9. {
  10. bluecell_header0 = 0,
  11. bluecell_header1,
  12. bluecell_header2,
  13. bluecell_header3,
  14. bluecell_type,
  15. bluecell_length_h,
  16. bluecell_length_l,
  17. bluecell_updatecnt_h,
  18. bluecell_updatecnt_l,
  19. bluecell_data,
  20. };
  21. public enum Updateseq
  22. {
  23. Bluecell_Reset = 0,
  24. Bluecell_Firmupdate_start,
  25. Bluecell_Firmupdate_sending,
  26. Bluecell_Firmupdate_end,
  27. };
  28. enum Bluecell_ProtIndex_p
  29. {
  30. Bluecell_Header = 0,
  31. Bluecell_Type,
  32. Bluecell_Length,
  33. Bluecell_CrcIndex,
  34. Bluecell_data,
  35. }
  36. enum Bluecell_Prot_t{
  37. TYPE_BLUECELL_RESET = 0,
  38. TYPE_BLUECELL_SET = 1,
  39. TYPE_BLUECELL_GET = 2,
  40. };
  41. enum Bluecell_TypeIndex_t
  42. {
  43. ATT_1_8G_DL1 = 0,
  44. ATT_1_8G_DL2,
  45. ATT_1_8G_UL1,
  46. ATT_1_8G_UL2,
  47. ATT_1_8G_UL3,
  48. ATT_1_8G_UL4,
  49. ATT_2_1G_DL1,
  50. ATT_2_1G_DL2,
  51. ATT_2_1G_UL1,
  52. ATT_2_1G_UL2,
  53. ATT_2_1G_UL3,
  54. ATT_2_1G_UL4,
  55. ATT_3_5G_DL,
  56. ATT_3_5G_UL,
  57. ATT_3_5G_COM1,
  58. ATT_3_5G_COM2,
  59. ATT_3_5G_COM3,
  60. PLL_1_8G_DL1_H,
  61. PLL_1_8G_DL1_L,
  62. PLL_1_8G_DL2_H,
  63. PLL_1_8G_DL2_L,
  64. PLL_2_1G_DL1_H,
  65. PLL_2_1G_DL1_L,
  66. PLL_2_1G_DL2_H,
  67. PLL_2_1G_DL2_L,
  68. PLL_3_5G_DL1_H,
  69. PLL_3_5G_DL1_L,
  70. PLL_3_5G_DL2_H,
  71. PLL_3_5G_DL2_L,
  72. PLL_LD_6_BIT,
  73. DET_1_8G_DL_IN_H,
  74. DET_1_8G_DL_IN_L,
  75. DET_1_8G_DL_OUT_H,
  76. DET_1_8G_DL_OUT_L,
  77. DET_1_8G_UL_IN_H,
  78. DET_1_8G_UL_IN_L,
  79. DET_1_8G_UL_OUT_H,
  80. DET_1_8G_UL_OUT_L,
  81. DET_2_1G_DL_IN_H,
  82. DET_2_1G_DL_IN_L,
  83. DET_2_1G_DL_OUT_H,
  84. DET_2_1G_DL_OUT_L,
  85. DET_2_1G_UL_IN_H,
  86. DET_2_1G_UL_IN_L,
  87. DET_2_1G_UL_OUT_H,
  88. DET_2_1G_UL_OUT_L,
  89. DET_3_5G_DL_IN_H,
  90. DET_3_5G_DL_IN_L,
  91. DET_3_5G_DL_OUT_L,
  92. DET_3_5G_DL_OUT_H,
  93. DET_3_5G_UL_IN_H,
  94. DET_3_5G_UL_IN_L,
  95. DET_3_5G_UL_OUT_H,
  96. DET_3_5G_UL_OUT_L,
  97. RFU_TEMP_H,
  98. RFU_TEMP_L,
  99. _28V_DET_H,
  100. _28V_DET_L,
  101. ALARM_AC,
  102. ALARM_DC,
  103. PATH_EN_1_8G_DL,
  104. PATH_EN_1_8G_UL,
  105. PATH_EN_2_1G_DL,
  106. PATH_EN_2_1G_UL,
  107. PATH_EN_3_5G_L,
  108. PATH_EN_3_5G_H,
  109. PATH_EN_3_5G_DL,
  110. PATH_EN_3_5G_UL,
  111. PLL_ON_OFF_3_5G_H,
  112. PLL_ON_OFF_3_5G_L,
  113. };
  114. class Bluecell_BootProtocol
  115. {
  116. Serial serial;
  117. /*bluecell Header*/
  118. public const byte Bluecell_Header0 = 0x42;//ASCII : B
  119. public const byte Bluecell_Header1 = 0x4C;//ASCII : L
  120. public const byte Bluecell_Header2 = 0x55;//ASCII : U
  121. public const byte Bluecell_Header3 = 0x45;//ASCII : E
  122. /*bluecell type*/
  123. public const int bluecell_Firmupdate_sendlength = 1024;
  124. Crc16 crc16 = new Crc16();
  125. public const byte BLUECELL_HEADER = 0xBE;
  126. public const byte BLUECELL_TAILER = 0xEB;
  127. const byte BLUECELL_RESET_LENGTH = 6;
  128. const byte BLUECELL_FIX_DATA_LENGTH = 3;
  129. public void Bluecell_Reset(object serial)
  130. {
  131. this.serial = (Serial)serial;
  132. byte[] temp_buf = new byte[BLUECELL_RESET_LENGTH];
  133. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_Header] = BLUECELL_HEADER;
  134. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_Type] = (byte)Bluecell_Prot_t.TYPE_BLUECELL_RESET;
  135. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_Length] = BLUECELL_RESET_LENGTH - BLUECELL_FIX_DATA_LENGTH;
  136. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_CrcIndex] = (byte)Bluecell_ProtIndex_p.Bluecell_data;
  137. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data] = crc16.STH30_CreateCrc(temp_buf, BLUECELL_RESET_LENGTH - 3);
  138. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + 1] = BLUECELL_TAILER;
  139. this.serial.Serial_DataSend(temp_buf, temp_buf.Length);
  140. }
  141. const byte BLUECELL_DATA_SET_LENGTH = 62;
  142. public void Bluecell_BtnSet(object serial,object main_form)
  143. {
  144. Main_Form main_Form = (Main_Form)main_form;
  145. this.serial = (Serial)serial;
  146. byte[] temp_buf = new byte[BLUECELL_DATA_SET_LENGTH];
  147. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_Header] = BLUECELL_HEADER;
  148. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_Type] = (byte)Bluecell_Prot_t.TYPE_BLUECELL_SET;
  149. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_Length] = BLUECELL_RESET_LENGTH - BLUECELL_FIX_DATA_LENGTH;
  150. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_CrcIndex] = (byte)BLUECELL_DATA_SET_LENGTH - 2;
  151. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.ATT_1_8G_DL1] = Convert.ToByte(main_Form.numericUpDown_ATT_1_8G_DL1.Text);
  152. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.ATT_1_8G_DL2] = Convert.ToByte(main_Form.numericUpDown_ATT_1_8G_DL2.Text);
  153. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.ATT_1_8G_UL1] = Convert.ToByte(main_Form.numericUpDown_ATT_1_8G_UL1.Text);
  154. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.ATT_1_8G_UL2] = Convert.ToByte(main_Form.numericUpDown_ATT_1_8G_UL2.Text);
  155. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.ATT_1_8G_UL3] = Convert.ToByte(main_Form.numericUpDown_ATT_1_8G_UL3.Text);
  156. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.ATT_1_8G_UL4] = Convert.ToByte(main_Form.numericUpDown_ATT_1_8G_UL4.Text);
  157. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.ATT_2_1G_DL1] = Convert.ToByte(main_Form.numericUpDown_ATT_2_1G_DL1.Text);
  158. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.ATT_2_1G_DL2] = Convert.ToByte(main_Form.numericUpDown_ATT_2_1G_DL2.Text);
  159. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.ATT_2_1G_UL1] = Convert.ToByte(main_Form.numericUpDown_ATT_2_1G_UL1.Text);
  160. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.ATT_2_1G_UL2] = Convert.ToByte(main_Form.numericUpDown_ATT_2_1G_UL2.Text);
  161. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.ATT_2_1G_UL3] = Convert.ToByte(main_Form.numericUpDown_ATT_2_1G_UL3.Text);
  162. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.ATT_2_1G_UL4] = Convert.ToByte(main_Form.numericUpDown_ATT_2_1G_UL4.Text);
  163. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.ATT_3_5G_DL] =
  164. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.ATT_3_5G_UL] =
  165. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.ATT_3_5G_COM1] =
  166. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.ATT_3_5G_COM2] =
  167. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.ATT_3_5G_COM3] =
  168. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.PLL_1_8G_DL1_H] =
  169. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.PLL_1_8G_DL1_L] =
  170. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.PLL_1_8G_DL2_H] =
  171. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.PLL_1_8G_DL2_L] =
  172. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.PLL_2_1G_DL1_H] =
  173. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.PLL_2_1G_DL1_L] =
  174. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.PLL_2_1G_DL2_H] =
  175. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.PLL_2_1G_DL2_L] =
  176. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.PLL_3_5G_DL1_H] =
  177. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.PLL_3_5G_DL1_L] =
  178. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.PLL_3_5G_DL2_H] =
  179. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.PLL_3_5G_DL2_L] =
  180. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.PLL_LD_6_BIT] =
  181. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.DET_1_8G_DL_IN_H] =
  182. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.DET_1_8G_DL_IN_L] =
  183. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.DET_1_8G_DL_OUT_H] =
  184. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.DET_1_8G_DL_OUT_L] =
  185. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.DET_1_8G_UL_IN_H] =
  186. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.DET_1_8G_UL_IN_L] =
  187. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.DET_1_8G_UL_OUT_H] =
  188. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.DET_1_8G_UL_OUT_L] =
  189. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.DET_2_1G_DL_IN_H] =
  190. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.DET_2_1G_DL_IN_L] =
  191. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.DET_2_1G_DL_OUT_H] =
  192. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.DET_2_1G_DL_OUT_L] =
  193. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.DET_2_1G_UL_IN_H] =
  194. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.DET_2_1G_UL_IN_L] =
  195. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.DET_2_1G_UL_OUT_H] =
  196. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.DET_2_1G_UL_OUT_L] =
  197. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.DET_3_5G_DL_IN_H] =
  198. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.DET_3_5G_DL_IN_L] =
  199. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.DET_3_5G_DL_OUT_L] =
  200. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.DET_3_5G_DL_OUT_H] =
  201. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.DET_3_5G_UL_IN_H] =
  202. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.DET_3_5G_UL_IN_L] =
  203. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.DET_3_5G_UL_OUT_H] =
  204. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.DET_3_5G_UL_OUT_L] =
  205. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.RFU_TEMP_H] =
  206. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.RFU_TEMP_L] =
  207. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t._28V_DET_H] =
  208. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t._28V_DET_L] =
  209. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.ALARM_AC] =
  210. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.ALARM_DC] =
  211. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.PATH_EN_1_8G_DL] =
  212. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.PATH_EN_1_8G_UL] =
  213. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.PATH_EN_2_1G_DL] =
  214. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.PATH_EN_2_1G_UL] =
  215. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.PATH_EN_3_5G_L] =
  216. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.PATH_EN_3_5G_H] =
  217. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.PATH_EN_3_5G_DL] =
  218. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.PATH_EN_3_5G_UL] =
  219. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.PLL_ON_OFF_3_5G_H] =
  220. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.PLL_ON_OFF_3_5G_L] =
  221. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + (int)Bluecell_TypeIndex_t.PLL_ON_OFF_3_5G_L + 1] = crc16.STH30_CreateCrc(temp_buf, BLUECELL_RESET_LENGTH - 3);
  222. temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + 1] = BLUECELL_TAILER;
  223. this.serial.Serial_DataSend(temp_buf, temp_buf.Length);
  224. }
  225. #if false
  226. public int Bluecell_Firmupdate_sendlength() {
  227. return bluecell_Firmupdate_sendlength;
  228. }
  229. private void BootHeaderput(ref byte[] fix_data)
  230. {
  231. fix_data[(int)Bluepro_t.bluecell_header0] = Bluecell_Header0;
  232. fix_data[(int)Bluepro_t.bluecell_header1] = Bluecell_Header1;
  233. fix_data[(int)Bluepro_t.bluecell_header2] = Bluecell_Header2;
  234. fix_data[(int)Bluepro_t.bluecell_header3] = Bluecell_Header3;
  235. }
  236. public byte[] Boot_Reset(object serial,byte[] Updatedata)
  237. {
  238. this.serial = (Serial)serial;
  239. byte[] fix_data = new byte[11];
  240. //Array.Clear(data, 0, data.Length);
  241. BootHeaderput(ref fix_data);
  242. fix_data[(int)Bluepro_t.bluecell_type] = (byte)Updateseq.Bluecell_Reset;
  243. fix_data[(int)Bluepro_t.bluecell_length_h] = 0;
  244. fix_data[(int)Bluepro_t.bluecell_length_l] = 5;
  245. fix_data[(int)Bluepro_t.bluecell_updatecnt_h] = Convert.ToByte((Updatedata.Length & 0xFF00) >> 8);
  246. fix_data[(int)Bluepro_t.bluecell_updatecnt_l] = Convert.ToByte((Updatedata.Length & 0x00FF));
  247. fix_data[(int)Bluepro_t.bluecell_data + 0] = Convert.ToByte((crc16.CRC16_Generate(fix_data, fix_data.Length - 4) & 0xFF00) >> 8);
  248. fix_data[(int)Bluepro_t.bluecell_data + 1] = Convert.ToByte((crc16.CRC16_Generate(fix_data, fix_data.Length - 4) & 0x00FF));
  249. this.serial.Serial_DataSend(fix_data, fix_data.Length);
  250. return fix_data;
  251. }
  252. public byte[] Boot_DataSending(byte[] update_data,UInt16 length, UInt16 updatacnt)
  253. {
  254. //Array.Clear(data, 0, data.Length);
  255. byte[] fix_data = new byte[bluecell_Firmupdate_sendlength];
  256. //BootHeaderput(ref fix_data);
  257. //length += 5;
  258. Array.Copy(update_data, (int)Bluepro_t.bluecell_data, fix_data, (int)Bluepro_t.bluecell_data, length);
  259. BootHeaderput(ref fix_data);
  260. fix_data[(int)Bluepro_t.bluecell_type] = (byte)Updateseq.Bluecell_Firmupdate_sending;
  261. fix_data[(int)Bluepro_t.bluecell_length_h] = Convert.ToByte((length & 0xFF00) >> 8);
  262. fix_data[(int)Bluepro_t.bluecell_length_l] = Convert.ToByte((length & 0x00FF));
  263. fix_data[(int)Bluepro_t.bluecell_updatecnt_h] = Convert.ToByte((updatacnt & 0xFF00) >> 8);
  264. fix_data[(int)Bluepro_t.bluecell_updatecnt_l] = Convert.ToByte((updatacnt & 0x00FF));
  265. //Array.Copy(update_data, 0, fix_data, (int)Bluepro_t.bluecell_data, length-3);
  266. fix_data[length + 9] = Convert.ToByte((crc16.CRC16_Generate(fix_data, length + 5) & 0xFF00) >> 8);
  267. fix_data[length + 10] = Convert.ToByte(crc16.CRC16_Generate(fix_data, length + 5) & 0x00FF);
  268. return fix_data;
  269. }
  270. public byte[] Boot_DataEnd(byte[] update_data, int length)
  271. {
  272. //Array.Clear(data, 0, data.Length);
  273. byte[] fix_data = new byte[11];
  274. Array.Copy(update_data, (int)Bluepro_t.bluecell_data, fix_data, (int)Bluepro_t.bluecell_data, length);
  275. BootHeaderput(ref fix_data);
  276. fix_data[(int)Bluepro_t.bluecell_type] = (byte)Updateseq.Bluecell_Firmupdate_end;
  277. fix_data[(int)Bluepro_t.bluecell_length_h] = Convert.ToByte((length & 0xFF00) >> 8);
  278. fix_data[(int)Bluepro_t.bluecell_length_l] = Convert.ToByte((length & 0x00FF));
  279. fix_data[(int)Bluepro_t.bluecell_updatecnt_h] = 0;
  280. fix_data[(int)Bluepro_t.bluecell_updatecnt_l] = 0;
  281. //Array.Copy(update_data, 0, fix_data, (int)Bluepro_t.bluecell_data, length-3);
  282. fix_data[length + 9] = Convert.ToByte((crc16.CRC16_Generate(fix_data, length + 5) & 0xFF00) >> 8);
  283. fix_data[length + 10] = Convert.ToByte(crc16.CRC16_Generate(fix_data, length + 5) & 0x00FF);
  284. return fix_data;
  285. }
  286. #endif
  287. }
  288. }