Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SerialSupportProxy: add TCP option #3468

Merged
merged 1 commit into from
Dec 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 63 additions & 25 deletions Controls/SerialSupportProxy.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 35 additions & 5 deletions Controls/SerialSupportProxy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,14 @@ public SerialSupportProxy()

MissionPlanner.Utilities.Tracking.AddPage(this.GetType().ToString(), this.Text);

// Load radio buttons from settings
rad_udp.Checked = Settings.Instance.GetBoolean("SerialSupportProxy_UDP", true);
rad_tcp.Checked = !rad_udp.Checked;

// Load saved host name and port from settings
TXT_host.Text = Settings.Instance["UDP_host_SerialSupportProxy"] ?? "support.ardupilot.org";
NUM_port.Value = int.Parse(Settings.Instance["UDP_port_SerialSupportProxy"] ?? "1");
var settings_prefix = rad_udp.Checked ? "UDP" : "TCP";
TXT_host.Text = Settings.Instance[settings_prefix + "_host_SerialSupportProxy"] ?? "support.ardupilot.org";
NUM_port.Value = int.Parse(Settings.Instance[settings_prefix + "_port_SerialSupportProxy"] ?? "1");

// Highlight the port for immediate typing
NUM_port.Select();
Expand All @@ -55,12 +60,34 @@ private void BUT_connect_Click(object sender, EventArgs e)
else
{
// The "Connect" button has been clicked. Create connection
var udpSerial = new UdpSerialConnect() { ConfigRef = "_SerialSupportProxy" };
MainV2.comPort.MirrorStream = udpSerial;
ICommsSerial serial;
if (rad_udp.Checked)
{
serial = new UdpSerialConnect() { ConfigRef = "_SerialSupportProxy" };
}
else
{
serial = new TcpSerial()
{
retrys = 999999,
autoReconnect = true,
Host = TXT_host.Text,
Port = NUM_port.Value.ToString("0"),
ConfigRef = "_SerialSupportProxy"
};
}
MainV2.comPort.MirrorStream = serial;
MainV2.comPort.MirrorStreamWrite = true;
try
{
udpSerial.Open(TXT_host.Text, NUM_port.Value.ToString());
if (rad_udp.Checked)
{
(serial as UdpSerialConnect).Open(TXT_host.Text, NUM_port.Value.ToString("0"));
}
else
{
serial.Open();
}
}
catch
{
Expand All @@ -72,6 +99,9 @@ private void BUT_connect_Click(object sender, EventArgs e)
BUT_connect.Text = Strings.Stop;
TXT_host.Enabled = false;
NUM_port.Enabled = false;

// Save the UDP/TCP selection
Settings.Instance["SerialSupportProxy_UDP"] = rad_udp.Checked.ToString();
}
}
}
Expand Down
Loading