Reading Binary Data with the SerialPort

I have been scouring the forums and XOJO documentation for and answer to my issue with no luck. So let see if someone has faced this issue and can help me. I am receiving data from a sensor through a Serial Port. The data is Binary. The bytes DO NOT represent ASCII characters. I wand to receive a packet and evaluate the contents to separated the different bits of information per the instrument protocol. Seems that the Serial Port Classes always represent the data as a string. This means a succession of ASCII characters. As I mentioned before, the data is NOT ASCII, so I am at a loss of how to get the RAW data without is being translated into a String by the methods available. Seems there are Binary streams that will do this but only seem to apply to files and I don’t see how to apply them to the Serial Connection Class.

Seems impossible that no one has ran into this before. Could someone help Please!!

A Xojo String is raw bytes with an associated text encoding, such as but not necessarily ASCII. Convert the String to a MemoryBlock to get at the bytes.

Dim data As MemoryBlock = mySerialConnection.Read(1024)

Unless you apply a specific encoding, Xojo strings are a sequence of binary characters/bytes. Extract individual bytes with the MiddleBytes function.

That was easy! I had taken that approach for sending characters but I though you had to assign an encoding to receive the data.

All is well now. On to the next challenge!

Thanks Again