-
Notifications
You must be signed in to change notification settings - Fork 0
/
CANParcel.cs
70 lines (55 loc) · 1.42 KB
/
CANParcel.cs
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
using sendme.chai;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace sendme
{
public class CANParcel
{
#region Fields
private byte[] mData = null;
private UInt32 mID = 0x00;
private DateTime mTimeStamp;
#endregion
#region Setters
public void SetData(byte[] data)
{
mData = data;
}
public void SetID(UInt32 id)
{
mID = id;
}
public void SetTimeStamp(DateTime time)
{
mTimeStamp = time;
}
#endregion
#region Getters
public DateTime GetTimestamp()
{
return mTimeStamp;
}
#endregion
public override String ToString()
{
String output = mID.ToString("X8");
for (int i = 0; i < mData.Length; i++)
output += " " + mData[i].ToString("X2");
output += " " + mTimeStamp.ToString("HH:mm:ss.fff");
return output;
}
unsafe public CANMsg GetCANMsg()
{
CANMsg msg = new CANMsg();
msg.id = mID;
for (int i = 0; i < mData.Length; i++)
msg.data[i] = mData[i];
msg.length = (byte) mData.Length;
msg.flags = 0x4;
return msg;
}
}
}