make sure serial port is selected

This commit is contained in:
Persephone Bubblegum-Holiday 2025-04-01 11:05:18 -07:00
parent fa3270056d
commit 66afcad064

View file

@ -79,6 +79,11 @@ namespace PinkConnection2_TestApp
void sendFrame() void sendFrame()
{ {
if (port == null)
{
MessageBox.Show("Please select a serial port");
return;
}
byte byte1 = (byte)(64 | ((b & 8) | (b & 4) | (b & 2) | (b & 1))); byte byte1 = (byte)(64 | ((b & 8) | (b & 4) | (b & 2) | (b & 1)));
byte byte2 = (byte)(64 | (((b & 128) | (b & 64) | (b & 32) | (b & 16)) >> 4)); byte byte2 = (byte)(64 | (((b & 128) | (b & 64) | (b & 32) | (b & 16)) >> 4));
port.Write(((char)byte1).ToString()); port.Write(((char)byte1).ToString());
@ -89,7 +94,12 @@ namespace PinkConnection2_TestApp
{ {
if (CommandTextBox.Text.Length != 2) if (CommandTextBox.Text.Length != 2)
{ {
MessageBox.Show("Command Length must not be less than 2"); MessageBox.Show("Command length must not be less than 2");
return;
}
if (port == null)
{
MessageBox.Show("Please select a serial port");
return; return;
} }
port.Write(CommandTextBox.Text); port.Write(CommandTextBox.Text);