Shop OBEX P1 Docs P2 Docs Learn Events
Help with SMS - Specified digit of number — Parallax Forums

Help with SMS - Specified digit of number

Robert KRobert K Posts: 6
edited 2010-03-07 02:49 in BASIC Stamp
I am tryling to use Basic Stamp to send SMS. Cell phones normaly accept PDU format, so I need to convert data to PDU. Please look at program below. The problem that I have is: putting·digits ·directly into the program - everything is working great, when I am trying to take a number and use specified digits, I am getting some non-sens.

I am sure solution , like always is rather easy, but for some reason I can not see that. Please help ;

Thanks

Robert

PDU·· VAR Byte(7)
CH··· VAR Byte(8)
Value VAR Word


Value = 1234

CH(0)=Value DIG 3
CH(1)=Value DIG 2
CH(2)=Value DIG 1
CH(3)=Value DIG 0
CH(4)="5"
CH(5)="6"
CH(6)="7"
CH(7)="8"
' PDU shift routine
PDU(0)=(CH(1) << 7)+(CH(0) >> 0)
PDU(1)=(CH(2) << 6)+(CH(1) >> 1)
PDU(2)=(CH(3) << 5)+(CH(2) >> 2)
PDU(3)=(CH(4) << 4)+(CH(3) >> 3)
PDU(4)=(CH(5) << 3)+(CH(4) >> 4)
PDU(5)=(CH(6) << 2)+(CH(5) >> 5)
PDU(6)=(CH(7) << 1)+(CH(6) >> 6)
'PDU OUTPUT (should be :· 31 D9 8C 56 B3 DD 70
DEBUG HEX2 PDU(0),HEX2 PDU(1),HEX2 PDU(2),HEX2 PDU(3),HEX2 PDU(4),HEX2 PDU(5),HEX2 PDU(6),CR

Comments

  • FranklinFranklin Posts: 4,747
    edited 2010-03-06 16:30
    Robert K said...
    when I am trying to take a number and use specified digits, I am getting some non-sens
    What nonsense are you getting? The program is probably doing exactly what you are telling it to do, but you are telling it to do something other than what you want. Computers work that way.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • Robert KRobert K Posts: 6
    edited 2010-03-06 16:48
    I am getting :
    01 C1 80 50 B3 DD 70
    which after conversion back to text is :
    £$¥è567

    Should be :
    31 D9 8C 56 B3 DD 70
    which convert to (cottected values)
    1234567
    So first 4 numbers are translated wrong, the one that I left unchanged are ok
  • Mike GreenMike Green Posts: 23,101
    edited 2010-03-06 16:52
    Value DIG 3

    This gives you a value from 0 to 9, not an ANSI character.

    Try: (Value DIG 3) + "0"
  • Robert KRobert K Posts: 6
    edited 2010-03-07 02:49
    Thanks that works !!!,
    Robert
Sign In or Register to comment.