Encoding.UTF8.GetChars Problem?

I’ve been trying to revive my IMU that I haven’t touched in over a year but the code worked then and I’ve got it mostly working now except for the attached. Are there any known issues with UTF8.GetChars()? I’m using the last beta SDK.

Yea. You’re probably right but since this is previously working code I was hoping for an easier answer before I banged my head any more.

@ ianlee74 - I have ordered my necessary parts to compete :wink:

On a very slight tangent, is it normal for the GetChars() method to throw exceptions if the input byte stream contains a value of 128 or greater?

Thanks. It’s funny how Encoding.UTF8.GetDecoder().Convert() behaves a little differently, in that it doesn’t throw exceptions for invalid byte codes, but simply truncates the offending bytes.

ive just had the same problem with the latest SDK.
Here is what i had to do to get it to work.

 byte[] readData = new byte[sender.BytesToRead];
            sender.Read(readData, 0, sender.BytesToRead);
            char[] chars = Encoding.UTF8.GetChars(readData);
            string str = new string(chars);

I figured out my problem. I thought I was doing the right thing by starting out with a lower baud on my IMU. It seems that if I use anything less than 115200 then I end up with a bunch of junk in the stream. :frowning:

Interesting, I wonder if thats what was happening for me.

You have to match what the imu uc is using…