Hi,

Im been tryaing to macke a gps/sms traker me phone only uses pdu, i have thange a pdu packer from on forum good member and i became with this.


***********************************
@ Device HS_OSC ' High Speed Crystal
define OSC 20

Include "modedefs.bas" ' Include serial modes

' Define LCD registers and bits
Define LCD_DREG PORTB 'Lcd D 4-bit parallel register starts at PortB.4 to PortB.7
Define LCD_DBIT 4
Define LCD_RSREG PORTB
Define LCD_RSBIT 2
Define LCD_EREG PORTB
Define LCD_EBIT 3
Define LCD_COMMANDUS 2000 ' Command Delay (uS)
Define LCD_DATAUS 50 ' Data Delay (uS)
DEFINE OSC 20 'Define oscilator frequency
DEFINE LCD_LINES 4 'Number lines on LCD

DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
DEFINE HSER_TXSTA 24h ' Enable transmit, BRGH = 1
DEFINE HSER_SPBRG 129 ' 9600 Baud @ 20MHz, 0.16%
DEFINE HSER_CLROERR 1 ' Clear overflow automatically

CMCON = %00000111 'PortA digital
;OPTION_REG.7 = 1 ' Disable PORTB pull-ups

TrisD.2=0
TrisC.6=0
TrisC.7=1

clear
a var byte [9]'gps data
char VAR BYTE [9] 'text data
pdu var byte [9] 'pdu data
tmp var byte [9] 'temporary array
ch var byte [9] 'temporary array
b0 var byte
x VAR BYTE

In:
HSERIN, 10000, In,[str a\9]

start:
FOR X=0 TO 8
LOOKup2 X,[a(0),a(1),a(2),a(3),a(4),a(5),a(6),a(7),a(8)],B0 '9bytes Gps data that will be converted in Pdu bytes
CHAR(X)=B0
NEXT X

lcdout $fe,$1,char(0),char(1),char(2),char(3),char(4),cha r(5),char(6),char(7),char(8)
gosub txt2pdu

lcdout $fe,$c0,hex pdu(0),hex pdu(1),hex pdu(2),hex pdu(3),hex pdu(4),hex pdu(5),hex pdu (6),hex pdu (7)


TXT2PDU:
tmp(1)=char(1) << 7
tmp(2)=char(2) << 6
tmp(3)=char(3) << 5
tmp(4)=char(4) << 4
tmp(5)=char(5) << 3
tmp(6)=char(6) << 2
tmp(7)=char(7) << 1
tmp(8)=char(8) << 0

ch(0)=chaR(0)
ch(1)=chaR(1) >> 1
ch(2)=chaR(2) >> 2
ch(3)=chaR(3) >> 3
ch(4)=chaR(4) >> 4
ch(5)=chaR(5) >> 5
ch(6)=chaR(6) >> 6
ch(7)=chaR(7) >> 7

pdu(0)=tmp(1) + ch(0)
pdu(1)=tmp(2) + ch(1)
pdu(2)=tmp(3) + ch(2)
pdu(3)=tmp(4) + ch(3)
pdu(4)=tmp(5) + ch(4)
pdu(5)=tmp(6) + ch(5)
pdu(6)=tmp(7) + ch(6)
pdu(7)=tmp(8) + ch(7)
RETURN

END
***********************
I have put it to encode in pdu for 9 bytes (it was 8 from autor) it works great, but i need 18 bytes and i can put it to work more then 9, can you members please hellp?

Now other problem is how to put in the pdu array that i have pre-made (is read to send only expect the 9 bytes gps data) i have tryed with this lines but no sucess.
Pre made array ["079153912601000011000C915391663921010000AA09 (9 is lenhgt of sms)....dps data....."]

HSEROUT ["AT+CMGS=22",13,10]
PAUSE 500
HSEROUT ["079153912601000011000C915391663921010000AA09, hex pdu(0),hex pdu(1),hex pdu(2),hex pdu(3),hex pdu(4),hex pdu(5),hex pdu (6),hex pdu (7)",26,10]
HSEROUT [13]

Can you members please hellp?

Thanks for caring