/
NetworkDevice.cs
88 lines (72 loc) · 2.44 KB
/
NetworkDevice.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Cosmos.HAL;
using Cosmos.HAL.Network;
namespace Cosmos.HAL
{
public delegate void DataReceivedHandler(byte[] packetData);
public enum CardType
{
Ethernet,
Wireless
}
public abstract class NetworkDevice
{
public static List<NetworkDevice> Devices { get; private set; }
static NetworkDevice()
{
Devices = new List<NetworkDevice>();
}
public DataReceivedHandler DataReceived;
protected NetworkDevice()
{
//mType = DeviceType.Network;
Devices.Add(this);
}
public abstract CardType CardType
{
get;
}
public abstract MACAddress MACAddress
{
get;
}
public abstract string Name
{
get;
}
public abstract bool Ready
{
get;
}
/// <summary>
/// Add bytes to the transmit buffer queue.
/// </summary>
/// <param name="buffer">bytes array to queue.</param>
/// <returns>TRUE on success.</returns>
/// <exception cref="ArgumentOutOfRangeException">Thrown on memory error.</exception>
/// <exception cref="OverflowException">Thrown if buffer length is bigger than Int32.MaxValue.</exception>
public virtual bool QueueBytes(byte[] buffer)
{
return QueueBytes(buffer, 0, buffer.Length);
}
/// <summary>
/// Add bytes to the transmit buffer queue.
/// </summary>
/// <param name="buffer">bytes array to queue.</param>
/// <param name="offset">Offset of the data in the buffer.</param>
/// <param name="length">Data length.</param>
/// <returns>TRUE on success.</returns>
/// <exception cref="ArgumentOutOfRangeException">Thrown on memory error.</exception>
/// <exception cref="OverflowException">Thrown if length is bigger than Int32.MaxValue.</exception>
public abstract bool QueueBytes(byte[] buffer, int offset, int length);
public abstract bool ReceiveBytes(byte[] buffer, int offset, int max);
public abstract byte[] ReceivePacket();
public abstract int BytesAvailable();
public abstract bool Enable();
public abstract bool IsSendBufferFull();
public abstract bool IsReceiveBufferFull();
}
}