Answer the question
In order to leave comments, you need to log in
When trying to initialize an object of the SerialPort class, it gives an error, what should I do?
I'm writing a plugin in Unity3D.
I want to receive data from a sensor that is connected via USB to a PC (COM3).
SerialPort port = new SerialPort();
port.PortName = "COM3"; // assign the port name
port.BaudRate = 9600; // Baudrate = 9600bps
port.Parity = Parity.None; // Parity bits = none
port.DataBits = 8; // No of Data bits = 8
port.StopBits = StopBits.One;
port.Open();
port.Write("gettemp");
Reference.Tell(args.sender.networkPlayer, $"Temp: {port.ReadLine()}");
Invalid IL code in System.IO.Ports.SerialPort:.ctor() : Method body is Empty.
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question