Serial Port

How do you send a Hex Byte like 0xFF out the Serial Port? Need Code example.

  1. Declare a byte array of required size (1 in you case).
  2. Set its first element to the value (0xFF).
  3. Use Write method to send the byte array.

There are plenty of examples in documentation,wiki and forum.

I can’t seem to get the syntax right. The compiler complains. I have used the following for strings

byte[] buffer2 = Encoding.UTF8.GetBytes(crlf + “IRRADIANCE @ 640 nanoMeters” + crlf);
UART.Write(buffer2, 0, buffer2.Length);

but can’t get it for 0xFA .

Try this:

byte[] buffer2 = new byte[]{ 0xFA };
UART.Write(buffer2, 0, buffer2.Length);

Please also use code tags or button with “101010” to format any code snippets in forum posts.

TNX: Ray