OSDN Git Service

NMEAパケットの部分実装(GPDTM, GPGBS, GPGLL)
[yubeshi/yubeshi.git] / Yubeshi / UnknownPacket.cs
1 /*\r
2  *      Yubeshi GPS Parser\r
3  *\r
4  *      This software is distributed under a zlib-style license.\r
5  *      See license.txt for more information.\r
6  */\r
7 \r
8 using System;\r
9 using System.Collections.Generic;\r
10 using System.Text;\r
11 \r
12 namespace Yubeshi\r
13 {\r
14     public class UnknownPacket\r
15     {\r
16         #region constructors\r
17 \r
18         public UnknownPacket()\r
19         { \r
20         }\r
21 \r
22         public UnknownPacket(byte[] sentence, int length)\r
23         {\r
24             Raw = new byte[length];\r
25             Array.Copy(sentence, Raw, Raw.Length);\r
26         }\r
27 \r
28         #endregion\r
29 \r
30         #region properties\r
31 \r
32         public byte[] Raw\r
33         {\r
34             get;\r
35             protected set;\r
36         }\r
37 \r
38         #endregion\r
39 \r
40         #region public methods\r
41 \r
42         public override string ToString()\r
43         {\r
44             StringBuilder builder = new StringBuilder(Raw.Length);\r
45             for (int i = 0; i < Raw.Length; ++i)\r
46             {\r
47                 byte c = Raw[i];\r
48                 if (c < 32 || c > 127)\r
49                 { \r
50                     builder.Append(@"\x" + c.ToString("X2"));\r
51                 }\r
52                 else\r
53                 {\r
54                     builder.Append(Char.ConvertFromUtf32(c));\r
55                 }\r
56             }\r
57             return builder.ToString();\r
58         }\r
59         #endregion\r
60     }\r
61 }\r