Converting a byte to ASCII

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 8.

Moderator: Benj

Post Reply
Clive44
Posts: 52
Joined: Tue Oct 18, 2011 12:35 pm
Has thanked: 3 times
Contact:

Converting a byte to ASCII

Post by Clive44 »

Hi

I'm reading the internal part number number of a device over I2C.
The part number is in the form HDL12345678 and it is transmitted character by character as ASCII ie H = 72, D = 68, L =76 etc
I want to store this in a string variable 11 characters long.
i.e. StringVar = StringVar + ASCII(byte)
So StringVar will end up as "HDL12345678" after receiving the I2C data byte by byte.
I seem to have a mental block on how to do this. !!!

Any help appreciated

Clive44

mnf
Valued Contributor
Valued Contributor
Posts: 1189
Joined: Wed May 31, 2017 11:57 am
Has thanked: 70 times
Been thanked: 439 times
Contact:

Re: Converting a byte to ASCII

Post by mnf »

In pseudocode...

Code: Select all

.pos = 0
for number_of_bytes_needed
    .str[.pos] = .char (read from i2c)
    .pos = .pos + 1
end loop
.str[.pos] = 0   / Mark end of string
Make sure the string is large enough to hold the data plus the termination character.

Martin

Post Reply