I am trying to write a command to a serial port. I have constructed the code below to connect to the serial port with the settings I am looking to have but I am running into the issue of how to set up the code to send the command I am looking to send. The C# code I have set up is:
Any ideas would be extremely helpful, I am still brand new to C#
namespace System.IO.Ports
{
class SerialPort
{
private SerialPort port = new SerialPort("COM5",
9600, Parity.None, 8, StopBits.One);
public SerialPort(string v1, int v2, Parity none, int v3, StopBits V4)
{
V1 = "com5";
V2 = 115200;
None = (Parity)0;
V3 = 8;
V4 = (StopBits)1;
}
public string V1 { get; }
public int V2 { get; }
public Parity None { get; }
public int V3 { get; }
public StopBits One { get; }
public void Write(string text)
{text = "IMGSNP1L1B0T";}
}
}
What I have tried:
The powershell version of this command is:
$port.Write([char]22+[char]77+[char]13+[char]73+[char]77+[char]71+[char]83+[char]78+[char]80+[char]49+[char]76+[char]49+[char]66+[char]48+[char]84+[char]46)
I have also tried
SerialPort.Write();
but get errors due the SerialPort.Write
Im a little lost on how I am able to send the command directly to the port