So I am trying to split a string and send the values as bytes to the serial port .
I have found a few solution's and examples but I just can get it to work with my values .
This is the code I am trying, the problem is the 255 seems to generate an error saying . I have try a few thing but just cant seem to figure this out.
Activated Event Time Duration Thread Exception: Exception thrown: 'System.OverflowException' in mscorlib.dll ("Value was either too large or too small for an unsigned byte."). Exception thrown: 'System.OverflowException' in mscorlib.dll ("Value was either too large or too small for an unsigned byte.") 8.67s [9972] Worker Thread
SerialPort _SP;
_SP = SerialConnect(SelectedPort, 9600);
string str = "0xFE 0xD0 0x255 0x0 0x0";
byte[] bytes = str.Split(' ').Select(s => Convert.ToByte(s, 16)).ToArray();
_SP.Write(bytes, 0, bytes.Length);