Shop OBEX P1 Docs P2 Docs Learn Events
SERIN ASCII to DEC equivalent — Parallax Forums

SERIN ASCII to DEC equivalent

ArchiverArchiver Posts: 46,084
edited 2001-05-11 20:38 in General Discussion
Ok,

I'm trying to do math on the ASCII code of the inbound serial string. I find
my pattern point and load a 6 byte array with the next 5 characters. Then I
want to do some simple math to determine the value of the array. (Not enough
room to do pattern matching to another array)

Example

SerData VAR BYTE(6)
SerData(5) = 0

main:
SERIN 16,16780,[noparse][[/noparse]WAIT("0A0"), STR SerData\5]
' This gets the data and inserts it into the array.

'Now determine witch of the 6 possible strings it is
' ????????

The 6 possible strings that can be stored in SerData are;
2B218
23219
2B21A
2B219
2321A
2321B

If I can use the ASCII code for each slot in the array and sum all the slots
I would end up with;
271
257
280
272
265
266

So my question is how do I get the ASCII code for each character in each
slot from the array?
temp = SerData(0) ''where temp = 50 because SerData(0) = "2"

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2001-05-11 20:38
    Solved my own question. Just looking in the incorrect place.

    If your curious
    '{$STAMP OEM BS2}
    SerData VAR BYTE(6)
    SerData(5) = 0
    bMatch VAR BYTE
    i VAR NIB

    main:
    SERIN 16,16780,[noparse][[/noparse]WAIT("0A0"), STR SerData\5]

    ' Total the arrey slots
    FOR i = 0 to 5
    bMatch = bMatch + SerData(i)
    NEXT

    IF bMatch = 271 THEN drop1 'Receved 2B218
    IF bMatch = 257 THEN drop2 'Receved 23219
    IF bMatch = 272 THEN drop3 'Receved 2B219
    IF bMatch = 265 THEN drop4 'Receved 2321A
    IF bMatch = 280 THEN drop5 'Receved 2B21A
    IF bMatch = 266 THEN drop6 'Receved 2321B



    drop1:
    HIGH 0
    PAUSE 5000
    LOW 0
    GOTO main:
    <snip>
Sign In or Register to comment.