blob: fe892b1ba6bcfc94d1052b7e12538100a51c6bfa (
plain)
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace com.clusterrr.FelLib
{
public class AWFELStandardRequest
{
public enum RequestType
{
FEL_VERIFY_DEVICE = 0x1, // (Read length 32 => AWFELVerifyDeviceResponse)
FEL_SWITCH_ROLE = 0x2,
FEL_IS_READY = 0x3, // (Read length 8)
FEL_GET_CMD_SET_VER = 0x4,
FEL_DISCONNECT = 0x10,
FEL_DOWNLOAD = 0x101, // (Write data to the device)
FEL_RUN = 0x102, // (Execute code)
FEL_UPLOAD = 0x103, // (Read data from the device)
}
public RequestType Cmd;
public UInt16 Tag;
public AWFELStandardRequest()
{
}
public AWFELStandardRequest(byte[] data)
{
Cmd = (RequestType)(data[0] | (data[1] * 0x100));
Tag = (UInt16)(data[2] | (data[3] * 0x100));
}
public byte[] Data
{
get
{
var data = new byte[16];
data[0] = (byte)((UInt16)Cmd & 0xFF); // mark
data[1] = (byte)(((UInt16)Cmd >> 8) & 0xFF); // mark
data[2] = (byte)(Tag & 0xFF); // tag
data[3] = (byte)((Tag >> 8) & 0xFF); // tag
return data;
}
}
}
}
|