CmdMessenger 3.0 CmdMessenger is a serial port messaging library for the Arduino

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Static Public Member Functions | Properties | List of all members
CommandMessenger.BinaryConverter Class Reference

## Static Public Member Functions
static string | ToString (Single value)
| Convert a float into a string representation. More...
static string | ToString (Double value)
| Convert a Double into a string representation. More...
static string | ToString (int value)
| Convert an int into a string representation. More...
static string | ToString (uint value)
| Convert an unsigned int into a string representation. More...
static string | ToString (short value)
| Convert a short into a string representation. More...
static string | ToString (ushort value)
| Convert an unsigned an unsigned short into a string representation. More...
static string | ToString (byte value)
| Convert a byte into a string representation. More...
static Single | ToFloat (String value)
| Converts a string to a float. More...
static Double | ToDouble (String value)
| Converts a string representation to a double. More...
static Int32 | ToInt32 (String value)
| Converts a string representation to an int 32. More...
static UInt32 | ToUInt32 (String value)
| Converts a string representation to a u int 32. More...
static UInt16 | ToUInt16 (String value)
| Converts a string representation to a u int 16. More...
static Int16 | ToInt16 (String value)
| Converts a string representation to an int 16. More...
static byte | ToByte (String value)
| Converts a string representation to a byte. More...
static byte[] | EscapedStringToBytes (String value)
| Converts an escaped string to a bytes array. More...

## Properties
Encoding StringEncoder | set
| Sets the string encoder. More...

## Member Function Documentation

static byte [] CommandMessenger.BinaryConverter.EscapedStringToBytes | ( | String | value | ) |
| inline static

Converts an escaped string to a bytes array.

Parameters

  value | The value to be converted.

Returns
  input value as an escaped string.

Referenced by CommandMessenger.BinaryConverter.ToByte(), CommandMessenger.BinaryConverter.ToDouble(), CommandMessenger.BinaryConverter.ToFloat(), CommandMessenger.BinaryConverter.ToInt16(), CommandMessenger.BinaryConverter.ToInt32(), CommandMessenger.BinaryConverter.ToUInt16(), and CommandMessenger.BinaryConverter.ToUInt32().

267 {
268 try
269 {
270 string unEscapedValue = Escaping.Unescape(value);
271 return _stringEncoder.GetBytes(unEscapedValue);
272 }
273 catch (Exception)
274 {
275 return null;
276 }
277 }

static byte CommandMessenger.BinaryConverter.ToByte | ( | String | value | ) |
| inline static

Converts a string representation to a byte.

Parameters

  value | The value to be converted.

Returns
  Input string as a byte?

References CommandMessenger.BinaryConverter.EscapedStringToBytes().

233 {
234 try
235 {
236 byte[] bytes = EscapedStringToBytes(value);
237 return bytes[0];
238 }
239 catch (Exception)
240 {
241 return null;
242 }
243 }
CommandMessenger.BinaryConverter.EscapedStringToBytes
static byte[] EscapedStringToBytes(String value)
Converts an escaped string to a bytes array.
Definition: BinaryConverter.cs:266

static Double CommandMessenger.BinaryConverter.ToDouble | ( | String | value | ) |
| inline static

Converts a string representation to a double.

Parameters

  value | The value to be converted.

Returns
  Input string as a Double?

References CommandMessenger.BinaryConverter.EscapedStringToBytes().

153 {
154 try
155 {
156 byte[] bytes = EscapedStringToBytes(value);
157 return BitConverter.ToDouble(bytes, 0);
158 }
159 catch (Exception)
160 {
161 return null;
162 }
163 }
CommandMessenger.BinaryConverter.EscapedStringToBytes
static byte[] EscapedStringToBytes(String value)
Converts an escaped string to a bytes array.
Definition: BinaryConverter.cs:266

static Single CommandMessenger.BinaryConverter.ToFloat | ( | String | value | ) |
| inline static

Converts a string to a float.

Parameters

  value | The value to be converted.

Returns
  Input string as a Single?

References CommandMessenger.BinaryConverter.EscapedStringToBytes().

137 {
138 try
139 {
140 byte[] bytes = EscapedStringToBytes(value);
141 return BitConverter.ToSingle(bytes, 0);
142 }
143 catch (Exception)
144 {
145 return null;
146 }
147 }
CommandMessenger.BinaryConverter.EscapedStringToBytes
static byte[] EscapedStringToBytes(String value)
Converts an escaped string to a bytes array.
Definition: BinaryConverter.cs:266

static Int16 CommandMessenger.BinaryConverter.ToInt16 | ( | String | value | ) |
| inline static

Converts a string representation to an int 16.

Parameters

  value | The value to be converted.

Returns
  This object as an Int16?

References CommandMessenger.BinaryConverter.EscapedStringToBytes().

217 {
218 try
219 {
220 byte[] bytes = EscapedStringToBytes(value);
221 return BitConverter.ToInt16(bytes, 0);
222 }
223 catch (Exception)
224 {
225 return null;
226 }
227 }
CommandMessenger.BinaryConverter.EscapedStringToBytes
static byte[] EscapedStringToBytes(String value)
Converts an escaped string to a bytes array.
Definition: BinaryConverter.cs:266

static Int32 CommandMessenger.BinaryConverter.ToInt32 | ( | String | value | ) |
| inline static

Converts a string representation to an int 32.

Parameters

  value | The value to be converted.

Returns
  This object as an Int32?

References CommandMessenger.BinaryConverter.EscapedStringToBytes().

169 {
170 try
171 {
172 byte[] bytes = EscapedStringToBytes(value);
173 return BitConverter.ToInt32(bytes, 0);
174 }
175 catch (Exception)
176 {
177 return null;
178 }
179 }
CommandMessenger.BinaryConverter.EscapedStringToBytes
static byte[] EscapedStringToBytes(String value)
Converts an escaped string to a bytes array.
Definition: BinaryConverter.cs:266

static string CommandMessenger.BinaryConverter.ToString | ( | Single | value | ) |
| inline static

Convert a float into a string representation.

Parameters

  value | The value to be converted.

Returns
  A string representation of this object.

23 {
24 try
25 {
26 byte[] byteArray = BitConverter.GetBytes(value);
27 return BytesToEscapedString(byteArray);
28 }
29 catch (Exception)
30 {
31 return null;
32 }
33 }

static string CommandMessenger.BinaryConverter.ToString | ( | Double | value | ) |
| inline static

Convert a Double into a string representation.

Parameters

  value | The value to be converted.

Returns
  A string representation of this object.

39 {
40 try
41 {
42 byte[] byteArray = BitConverter.GetBytes(value);
43 return BytesToEscapedString(byteArray);
44 }
45 catch (Exception)
46 {
47 return null;
48 }
49 }

static string CommandMessenger.BinaryConverter.ToString | ( | int | value | ) |
| inline static

Convert an int into a string representation.

Parameters

  value | The value to be converted.

Returns
  A string representation of this object.

55 {
56 try
57 {
58 byte[] byteArray = BitConverter.GetBytes(value);
59 return BytesToEscapedString(byteArray);
60 }
61 catch (Exception)
62 {
63 return null;
64 }
65 }

static string CommandMessenger.BinaryConverter.ToString | ( | uint | value | ) |
| inline static

Convert an unsigned int into a string representation.

Parameters

  value | The value to be converted.

Returns
  A string representation of this object.

71 {
72 try
73 {
74 byte[] byteArray = BitConverter.GetBytes(value);
75 return BytesToEscapedString(byteArray);
76 }
77 catch (Exception)
78 {
79 return null;
80 }
81 }

static string CommandMessenger.BinaryConverter.ToString | ( | short | value | ) |
| inline static

Convert a short into a string representation.

Parameters

  value | The value to be converted.

Returns
  A string representation of this object.

87 {
88 try
89 {
90 byte[] byteArray = BitConverter.GetBytes(value);
91 return BytesToEscapedString(byteArray);
92 }
93 catch (Exception)
94 {
95 return null;
96 }
97 }

static string CommandMessenger.BinaryConverter.ToString | ( | ushort | value | ) |
| inline static

Convert an unsigned an unsigned short into a string representation.

Parameters

  value | The value to be converted.

Returns
  A string representation of this object.

103 {
104 try
105 {
106 byte[] byteArray = BitConverter.GetBytes(value);
107 return BytesToEscapedString(byteArray);
108 }
109 catch (Exception)
110 {
111 return null;
112 }
113 }

static string CommandMessenger.BinaryConverter.ToString | ( | byte | value | ) |
| inline static

Convert a byte into a string representation.

Parameters

  value | The value to be converted.

Returns
  A string representation of this object.

119 {
120 try
121 {
122 return BytesToEscapedString(new byte[] {value});
123 }
124 catch (Exception)
125 {
126 return null;
127 }
128 }

static UInt16 CommandMessenger.BinaryConverter.ToUInt16 | ( | String | value | ) |
| inline static

Converts a string representation to a u int 16.

Parameters

  value | The value to be converted.

Returns
  Input string as a UInt16?

References CommandMessenger.BinaryConverter.EscapedStringToBytes().

201 {
202 try
203 {
204 byte[] bytes = EscapedStringToBytes(value);
205 return BitConverter.ToUInt16(bytes, 0);
206 }
207 catch (Exception)
208 {
209 return null;
210 }
211 }
CommandMessenger.BinaryConverter.EscapedStringToBytes
static byte[] EscapedStringToBytes(String value)
Converts an escaped string to a bytes array.
Definition: BinaryConverter.cs:266

static UInt32 CommandMessenger.BinaryConverter.ToUInt32 | ( | String | value | ) |
| inline static

Converts a string representation to a u int 32.

Parameters

  value | The value to be converted.

Returns
  Input string as a UInt32?

References CommandMessenger.BinaryConverter.EscapedStringToBytes().

185 {
186 try
187 {
188 byte[] bytes = EscapedStringToBytes(value);
189 return BitConverter.ToUInt32(bytes, 0);
190 }
191 catch (Exception)
192 {
193 return null;
194 }
195 }
CommandMessenger.BinaryConverter.EscapedStringToBytes
static byte[] EscapedStringToBytes(String value)
Converts an escaped string to a bytes array.
Definition: BinaryConverter.cs:266

## Property Documentation

Encoding StringEncoder CommandMessenger.BinaryConverter.set

Sets the string encoder.

The string encoder.

The documentation for this class was generated from the following file:

- D:/My Documents/Github/Arduino-Code-and-Libraries/Libraries/CmdMessenger/CSharp/CommandMessenger/BinaryConverter.cs