I manage to get good serial read (visually) by the assistance from the community from my previous topic. However as I am testing my completed app, I noticed that sometimes the printed text in my label is not what it looks to be. There are weird hidden characters that mess up the test string that I tried to extract. Visually it looks only alphanumeric characters is present but when I want to copy it, when I double click the selection seems to cut halfway through. When I drag the selection manually on the whole text and paste it in a character count website, I notice that there are weird character hides between the alphanumeric characters. Is there any way that I can insert filter to only read alphanumeric or replace weird character that is not alphanumeric with empty " ".
The output should be this 47444C430001000000020023000393B0 but it becomes this instead (refer photo).
If you apply what @ABG has already said, you are 99% sure that weird characters are cut off, but if you want a "double filter" please take a look to the ASCII table below
Printable characters are included between their ASCII (hexadecimal) values 0x30 through 0x7E.
So you can discard everything outside those values.
Something like: if (0x30 <= CharReceived <= 0x07E) accept_character();
If you guess you could receive also extended ASCII characters, their table is the following one:
but, as a first attempt, I suggest you to accept only the printable ones of the first page.
Cheers.
problem have been solved by using custom serial otg extension that have block to check whether there is data to read before actually reading it as suggested by ABG