-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOneWireException.cs
More file actions
87 lines (75 loc) · 2.52 KB
/
OneWireException.cs
File metadata and controls
87 lines (75 loc) · 2.52 KB
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
using System;
namespace OneWireAPI
{
[Serializable]
public class OneWireException : Exception
{
public enum ExceptionFunction
{
Access,
Crc,
ReadBit,
ReadByte,
Select,
SendBit,
SendBlock,
SendByte,
SetLevel
}
public Identifier DeviceId { get; private set; }
public ExceptionFunction Function { get; private set; }
public int Number { get; private set; }
public OneWireException(ExceptionFunction function, int number)
{
// Store the exception function
Function = function;
// Store the exception number
Number = number;
}
public OneWireException(ExceptionFunction function, Identifier deviceId)
{
// Store the exception function
Function = function;
// Store the device ID
DeviceId = deviceId;
}
public OneWireException(ExceptionFunction function, Identifier deviceId, int number)
{
// Store the exception function
Function = function;
// Store the device ID
DeviceId = deviceId;
// Store the exception number
Number = number;
}
public override string Message
{
get
{
switch (Function)
{
case ExceptionFunction.Access:
return "Unable to access device";
case ExceptionFunction.Crc:
return "CRC mismatch";
case ExceptionFunction.ReadBit:
return "Error reading bit";
case ExceptionFunction.ReadByte:
return "Error reading byte";
case ExceptionFunction.Select:
return "Unable to select device";
case ExceptionFunction.SendBit:
return "Error sending bit";
case ExceptionFunction.SendBlock:
return "Error sending block";
case ExceptionFunction.SendByte:
return "Error sending byte";
case ExceptionFunction.SetLevel:
return "Error setting level";
default:
return "Unknown error in function" + Function;
}
}
}
}
}