generated from ut-issl/repository-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from ut-issl/feature/add_secondary_obc_compo
WINGSのSECONDARY_OBCコンポの作成に伴った改修
- Loading branch information
Showing
4 changed files
with
71 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
Services/UserDefined/SECONDARY_OBC/SecondaryObcTcPacketHandler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using System; | ||
using System.Linq; | ||
using WINGS_TMTC_IF.Models; | ||
|
||
namespace WINGS_TMTC_IF.Services.SECONDARY_OBC | ||
{ | ||
public class SecondaryObcTcPacketHandler : TcPacketHandlerBase, ITcPacketHandler | ||
{ | ||
public SecondaryObcTcPacketHandler(IPortManager portManager) : base(portManager) | ||
{ | ||
} | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
Services/UserDefined/SECONDARY_OBC/SecondaryObcTmPacketExtractor.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
using System; | ||
using System.Linq; | ||
using WINGS_TMTC_IF.Models; | ||
|
||
namespace WINGS_TMTC_IF.Services.SECONDARY_OBC | ||
{ | ||
public class SecondaryObcTmPacketExtractor : TmPacketExtractorBase, ITmPacketExtractor | ||
{ | ||
private static readonly byte[] STX = new byte[]{0xeb, 0x90}; | ||
private static readonly byte[] ETX = new byte[]{0xc5, 0x79}; | ||
|
||
public SecondaryObcTmPacketExtractor(IPortManager portManager) | ||
: base(portManager, new ReceivedDataConfig { | ||
HeaderLength = 4, | ||
BodyLength = 6 + 7 + 223, | ||
FooterLength = 4 | ||
}) | ||
{ | ||
} | ||
|
||
protected override bool AnalyzeHeader() | ||
{ | ||
if (!_buffer.GetRange(0, STX.Count()).SequenceEqual(STX)) | ||
{ | ||
return false; | ||
} | ||
byte[] packet_tmp = _buffer.GetRange(2, 2).ToArray(); | ||
if (BitConverter.IsLittleEndian) | ||
{ | ||
Array.Reverse(packet_tmp); | ||
} | ||
_config.BodyLength = BitConverter.ToUInt16(packet_tmp); | ||
|
||
return true; | ||
} | ||
|
||
protected override bool AnalyzeFooter() | ||
{ | ||
return _buffer.GetRange(_config.TotalLength - ETX.Count(), ETX.Count()).SequenceEqual(ETX); | ||
} | ||
|
||
protected override TmPacketData ConvertToTmPacketData(byte[] receivedDataInByteArray) | ||
{ | ||
Console.WriteLine("Received"); | ||
return base.ConvertToTmPacketData(receivedDataInByteArray); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters