-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathTargetDataPort.cs
More file actions
58 lines (46 loc) · 1.63 KB
/
Copy pathTargetDataPort.cs
File metadata and controls
58 lines (46 loc) · 1.63 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
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
//
// Base class for e.g. Serial and TCP targets
//
// "Target" to distinguish between e.g. a remote TCP target and a local listen server for TCP<->UART bridge
//
using System;
using System.IO.Ports;
// All configs for all port types.
public class PortConfig
{
// Regular serial stuff
public Parity parity = Parity.None;
public int dataBits = 8;
public StopBits stopBits = StopBits.One;
public int readTimeout = 500;
public int writeTimeout = 500;
// SharkLink and Yaroze compat
public Handshake handshake = Handshake.None;
public bool dtrEnable = true;
public bool rtsEnable = true;
// USB Mod
public bool skipAcks = false;
// TCP stuff
public bool isTCP = false;
public string tcpTargetDevice = "";
public UInt32 tcpTargetPort = 0;
}
abstract public class TargetDataPort
{
public PortConfig config;
public TargetDataPort(PortConfig inConfig) { config = inConfig; }
abstract public int BytesToRead { get; }
abstract public int BytesToWrite { get; }
abstract public int ReadTimeout { get; set; }
abstract public int WriteTimeout { get; set; }
abstract public void Open();
abstract public void Close();
abstract public int ReadByte();
abstract public int ReadChar();
abstract public void Write(string text);
abstract public void Write(char[] buffer, int offset, int count);
abstract public void Write(byte[] buffer, int offset, int count);
}