Help with SMS - Specified digit of number
Robert K
Posts: 6
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
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
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
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
This gives you a value from 0 to 9, not an ANSI character.
Try: (Value DIG 3) + "0"
Robert