forked from ArduPilot/MissionPlanner
-
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.
- Loading branch information
Showing
4 changed files
with
85 additions
and
119 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.IO.Ports; | ||
using System.Text; | ||
|
||
namespace MissionPlanner.Comms | ||
{ | ||
public class CommsStream : Stream | ||
{ | ||
public ICommsSerial CommsSerial { get; set; } | ||
|
||
long _len = 0; | ||
|
||
public CommsStream(ICommsSerial comm, long len) | ||
{ | ||
CommsSerial = comm; | ||
SetLength(len); | ||
} | ||
|
||
public override void Flush() | ||
{ | ||
} | ||
|
||
public override int Read(byte[] buffer, int offset, int count) | ||
{ | ||
var read = CommsSerial.Read(buffer, offset, count); | ||
Position += read; | ||
return read; | ||
} | ||
|
||
public override long Seek(long offset, SeekOrigin origin) | ||
{ | ||
return Position; | ||
} | ||
|
||
public override void SetLength(long value) | ||
{ | ||
_len = value; | ||
} | ||
|
||
public override void Write(byte[] buffer, int offset, int count) | ||
{ | ||
CommsSerial.Write(buffer,offset,count); | ||
} | ||
|
||
public override bool CanRead { get; } = true; | ||
public override bool CanSeek { get; } = false; | ||
public override bool CanWrite { get; } = true; | ||
|
||
public override long Length | ||
{ | ||
get { return _len; } | ||
} | ||
|
||
public override long Position { get; set; } | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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
Binary file not shown.