|
@@ -13,8 +13,12 @@ namespace Basic_Terminal
|
13
|
13
|
bluecell_header2,
|
14
|
14
|
bluecell_header3,
|
15
|
15
|
bluecell_type,
|
16
|
|
- bluecell_length01,
|
17
|
|
- bluecell_length02,
|
|
16
|
+ bluecell_length_h,
|
|
17
|
+ bluecell_length_l,
|
|
18
|
+ bluecell_updatecnt_h,
|
|
19
|
+ bluecell_updatecnt_l,
|
|
20
|
+ bluecell_data,
|
|
21
|
+
|
18
|
22
|
};
|
19
|
23
|
|
20
|
24
|
class Bluecell_BootProtocol
|
|
@@ -41,34 +45,38 @@ namespace Basic_Terminal
|
41
|
45
|
public byte[] Boot_Reset(object serial)
|
42
|
46
|
{
|
43
|
47
|
this.serial = (Serial)serial;
|
44
|
|
- byte[] fix_data = new byte[8];
|
|
48
|
+ byte[] fix_data = new byte[11];
|
45
|
49
|
//Array.Clear(data, 0, data.Length);
|
46
|
50
|
fix_data[(int)Bluepro_t.bluecell_header0] = Bluecell_Header0;
|
47
|
51
|
fix_data[(int)Bluepro_t.bluecell_header1] = Bluecell_Header1;
|
48
|
52
|
fix_data[(int)Bluepro_t.bluecell_header2] = Bluecell_Header2;
|
49
|
53
|
fix_data[(int)Bluepro_t.bluecell_header3] = Bluecell_Header3;
|
50
|
54
|
fix_data[(int)Bluepro_t.bluecell_type] = Bluecell_Reset;
|
51
|
|
- fix_data[(int)Bluepro_t.bluecell_length01] = 0;
|
52
|
|
- fix_data[(int)Bluepro_t.bluecell_length02] = 5;
|
|
55
|
+ fix_data[(int)Bluepro_t.bluecell_length_h] = 0;
|
|
56
|
+ fix_data[(int)Bluepro_t.bluecell_length_l] = 5;
|
|
57
|
+ fix_data[(int)Bluepro_t.bluecell_updatecnt_h] = 0;
|
|
58
|
+ fix_data[(int)Bluepro_t.bluecell_updatecnt_l] = 0;
|
53
|
59
|
|
54
|
|
- fix_data[(int)Bluepro_t.bluecell_type + 1] = Convert.ToByte((crc16.CRC16_Generate(fix_data, fix_data.Length) & 0xFF00) >> 8);
|
55
|
|
- fix_data[(int)Bluepro_t.bluecell_type + 2] = Convert.ToByte((crc16.CRC16_Generate(fix_data, fix_data.Length) & 0x00FF));
|
|
60
|
+ fix_data[(int)Bluepro_t.bluecell_data + 0] = Convert.ToByte((crc16.CRC16_Generate(fix_data, fix_data.Length) & 0xFF00) >> 8);
|
|
61
|
+ fix_data[(int)Bluepro_t.bluecell_data + 1] = Convert.ToByte((crc16.CRC16_Generate(fix_data, fix_data.Length) & 0x00FF));
|
56
|
62
|
this.serial.Serial_DataSend(fix_data, fix_data.Length);
|
57
|
63
|
return fix_data;
|
58
|
64
|
}
|
59
|
65
|
public byte[] Boot_DataStart()
|
60
|
66
|
{
|
61
|
67
|
//Array.Clear(data, 0, data.Length);
|
62
|
|
- byte[] fix_data = new byte[9];
|
|
68
|
+ byte[] fix_data = new byte[11];
|
63
|
69
|
fix_data[(int)Bluepro_t.bluecell_header0] = Bluecell_Header0;
|
64
|
70
|
fix_data[(int)Bluepro_t.bluecell_header1] = Bluecell_Header1;
|
65
|
71
|
fix_data[(int)Bluepro_t.bluecell_header2] = Bluecell_Header2;
|
66
|
72
|
fix_data[(int)Bluepro_t.bluecell_header3] = Bluecell_Header3;
|
67
|
73
|
fix_data[(int)Bluepro_t.bluecell_type] = Bluecell_Firmupdate_start;
|
68
|
|
- fix_data[(int)Bluepro_t.bluecell_length01] = 0;
|
69
|
|
- fix_data[(int)Bluepro_t.bluecell_length02] = 3;
|
70
|
|
- fix_data[(int)Bluepro_t.bluecell_type + 1] = Convert.ToByte((crc16.CRC16_Generate(fix_data, fix_data.Length) & 0xFF00) >> 8);
|
71
|
|
- fix_data[(int)Bluepro_t.bluecell_type + 2] = Convert.ToByte((crc16.CRC16_Generate(fix_data, fix_data.Length) & 0x00FF));
|
|
74
|
+ fix_data[(int)Bluepro_t.bluecell_length_h] = 0;
|
|
75
|
+ fix_data[(int)Bluepro_t.bluecell_length_l] = 3;
|
|
76
|
+ fix_data[(int)Bluepro_t.bluecell_updatecnt_h] = 0;
|
|
77
|
+ fix_data[(int)Bluepro_t.bluecell_updatecnt_l] = 0;
|
|
78
|
+ fix_data[(int)Bluepro_t.bluecell_data + 0] = Convert.ToByte((crc16.CRC16_Generate(fix_data, fix_data.Length) & 0xFF00) >> 8);
|
|
79
|
+ fix_data[(int)Bluepro_t.bluecell_data + 1] = Convert.ToByte((crc16.CRC16_Generate(fix_data, fix_data.Length) & 0x00FF));
|
72
|
80
|
return fix_data;
|
73
|
81
|
}
|
74
|
82
|
public byte[] Boot_DataSending(byte[] data,int length)
|
|
@@ -80,22 +88,29 @@ namespace Basic_Terminal
|
80
|
88
|
fix_data[(int)Bluepro_t.bluecell_header2] = Bluecell_Header2;
|
81
|
89
|
fix_data[(int)Bluepro_t.bluecell_header3] = Bluecell_Header3;
|
82
|
90
|
fix_data[(int)Bluepro_t.bluecell_type] = Bluecell_Firmupdate_sending;
|
83
|
|
- fix_data[(int)Bluepro_t.bluecell_length01] = Convert.ToByte((length & 0xFF00) >> 8);
|
84
|
|
- fix_data[(int)Bluepro_t.bluecell_length02] = Convert.ToByte((length & 0x00FF));
|
|
91
|
+ fix_data[(int)Bluepro_t.bluecell_length_h] = 0;
|
|
92
|
+ fix_data[(int)Bluepro_t.bluecell_length_l] = 3;
|
|
93
|
+ fix_data[(int)Bluepro_t.bluecell_updatecnt_h] = 0;
|
|
94
|
+ fix_data[(int)Bluepro_t.bluecell_updatecnt_l] = 0;
|
|
95
|
+ fix_data[(int)Bluepro_t.bluecell_data + 0] = Convert.ToByte((length & 0xFF00) >> 8);
|
|
96
|
+ fix_data[(int)Bluepro_t.bluecell_data + 1] = Convert.ToByte((length & 0x00FF));
|
85
|
97
|
return data;
|
86
|
98
|
}
|
87
|
|
- public byte[] Boot_DataEnd()
|
|
99
|
+ public byte[] Boot_DataEnd(byte[] data,int length)
|
88
|
100
|
{
|
89
|
101
|
//Array.Clear(data, 0, data.Length);
|
90
|
|
- byte[] fix_data = new byte[5];
|
|
102
|
+ byte[] fix_data = new byte[11];
|
91
|
103
|
fix_data[(int)Bluepro_t.bluecell_header0] = Bluecell_Header0;
|
92
|
104
|
fix_data[(int)Bluepro_t.bluecell_header1] = Bluecell_Header1;
|
93
|
105
|
fix_data[(int)Bluepro_t.bluecell_header2] = Bluecell_Header2;
|
94
|
106
|
fix_data[(int)Bluepro_t.bluecell_header3] = Bluecell_Header3;
|
95
|
107
|
fix_data[(int)Bluepro_t.bluecell_type] = Bluecell_Firmupdate_end;
|
96
|
|
- fix_data[(int)Bluepro_t.bluecell_length01] = 0;
|
97
|
|
- fix_data[(int)Bluepro_t.bluecell_length02] = 3;
|
98
|
|
-
|
|
108
|
+ fix_data[(int)Bluepro_t.bluecell_length_h] = 0;
|
|
109
|
+ fix_data[(int)Bluepro_t.bluecell_length_l] = 3;
|
|
110
|
+ fix_data[(int)Bluepro_t.bluecell_updatecnt_h] = 0;
|
|
111
|
+ fix_data[(int)Bluepro_t.bluecell_updatecnt_l] = 0;
|
|
112
|
+ fix_data[(int)Bluepro_t.bluecell_data + 0] = Convert.ToByte((length & 0xFF00) >> 8);
|
|
113
|
+ fix_data[(int)Bluepro_t.bluecell_data + 1] = Convert.ToByte((length & 0x00FF));
|
99
|
114
|
return fix_data;
|
100
|
115
|
}
|
101
|
116
|
}
|