I try to write some binary data to the Serial Interface with C#:
0x02 0x81 0xF4 ...
This is a command for a remote device and must be transferred exactly like this. And here starts the Problem. When I use
System.IO.Ports.SerialPort.Write(Byte[] data, int Offset, int Size)
the data gets encoded (to ASCII,UTF-8 or whatever).And that's exactly I don't can need,since my remote device doesn't understand any Encoding.
Is there a Workaround?
bytearray get encoded unless the other end is doing it?SerialPort.Writewill certainly send raw data, unless you encode it before already. Beware that the raw-data is not printable.0x02 0x81 0xF4 ...to byte array being transmitted.. Are you converting abovestringto bytes usingEncoding.GetBytes?0x02 0x81 0xF4 ...is a string?!? Or do you have the data in the formnew byte[] { 0x02, 0x81, 0xF4, ... }?