OTG Serial read how do you remove weird hidden character betwen alphanumeric character?

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).

AI2 serial read error

ArduinoReadSerialTesting_10.aia (209.8 KB)

1 Like

Check if the Serial component has a block to tell you if data is available before asking for what the data is

Alternatively, test if the returned data is \0 and filter that out.

Forcing a read when nothing is there might result in an answer of null, or worse, force the block to improvise.

2 Likes

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
image
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:
image
but, as a first attempt, I suggest you to accept only the printable ones of the first page.
Cheers.

4 Likes

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

1 Like

@Seng278

Topic will not be removed. This community is for sharing problems and solutions, this topic may be of value to others.

3 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.