PDA

View Full Version : Filling pdu array with gps data!



camolas
- 12th September 2008, 00:12
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

camolas
- 18th September 2008, 20:28
Hi,

I find this code in proton pb, can any one please change this to pbp? (have try to do it but have a lot of errors)


Code:

************************************************** *****************
Device = 16F628
XTAL = 4

Symbol Led1 PORTB.4 ' Leds are used to indicate errors and debug
Symbol Led2 PORTB.5
Symbol Tx PORTB.2 ' Serial transmit 9600,8,N,1
Symbol Rx PORTB.1 ' Serial Receive 9600,8,N,1

Dim textmsg[20] As Byte
Dim mobno[20] As Byte

Dim nn As Byte ' used as a counter
Dim bitcnt As Byte ' used as a counter
Dim Bcnt As Byte ' used as a counter
Dim temp As Byte ' temporary storage when moving bytes about
Dim rotates As Byte ' the number of rotates to be done
Dim source As Byte ' indirect pointer to source string
Dim target As Byte ' indirect pointer to target string

Init:
Low Led1
Low Led2
DelayMS 500 ' Wait for .5 sec
High Led1 ' SMS sent
High Led2 ' Error Led
StrN mobno = "447799999999" ' Put your mobile number here
' If the mobile number is an odd number, then add an F to the end of it making it an
' even number eg: 4477999999991F
StrN textmsg = "N5413518W0135690" ' Put SMS text here

jump_over_subroutines:
GoTo WaitForRing

septets_to_octets: ' Uses a single string and converts in situ
' with lots of shuffling of bytes - a bit slow maybe ??

target = VarPtr(textmsg)' pointer to target byte of string
FSR = target
If INDF = 0 Then done ' zero length string - nothing to do
source = target + 1 ' pointer to source byte of string
FSR = source
If INDF = 0 Then done ' single byte string - nothing to do
movlw 1
movwf rotates ' sets number of rotates to 1
movwf nn ' sets counter nn to 1

loop:
FSR = source ' point indirection register at source
clrf temp ' set temp to all 0s
For nn = 1 To rotates '
clrc ' ensure carry is clear
ror INDF ' rotate nn bits right through carry
ror temp ' into msb of temp
Next
incf rotates ' do 1 more rotate next time round
FSR = target ' set pointer to target
movfw temp ' move temp into the w register
xorwf INDF ' exclusive or the contents of w with the contents of target and store in target
incf source ' add 1 to source pointer
incf target ' add 1 to target pointer
If rotates > 7 Then ' if we have done 7 rotates already then
movlw 1 ' reset number of rotates back to 1
movwf rotates
nn = source ' temporarily store the source pointer
FSR = source
While INDF <> 0 ' We have now converted 8 Septets into 7 Octets in the string
' leaving the 8th byte full of 0s so we now have to
' shuffle the remaining bytes to the left before we can continue
' looping round until reaching the null byte terminator of the string
temp = INDF ' temporarily store source
FSR = target ' set pointer to target
INDF = temp ' retrieve source from temp and store in target
incf source ' increment source pointer
incf target ' increment target pointer
FSR = source ' set pointer back to source
Wend
FSR = target ' set pointer to target and
INDF = 0 ' put a new null byte to terminate the now shorter string
source = nn ' restore the source byte position
target = nn - 1 ' and the target byte position
EndIf
FSR = source ' set pointer to source
If INDF > 0 Then loop ' loop back until we have reached the null byte terminator
done:

output_msg:
bitcnt = 0
Repeat
Inc bitcnt
Until textmsg[bitcnt] = 0
SerOut Tx, 84, [HEX2 bitcnt+1] ' Set the length of the encoded text
bitcnt = 0
Repeat
SerOut Tx, 84, [HEX2 textmsg[bitcnt]]
Inc bitcnt
Until textmsg[bitcnt] = 0
SerOut Tx, 84, [HEX2 textmsg[bitcnt]]
Return

output_mobileno:
bitcnt = 0
Repeat
Inc bitcnt
Until mobno[bitcnt] = 0
SerOut Tx, 84, [HEX2 bitcnt] ' Set the length of the mobile number
SerOut Tx, 84, ["91"] ' Set mobile number to international type
For Bcnt = 0 To bitcnt -1 Step 2 ' Swap digits around...
SerOut Tx, 84, [mobno[Bcnt+1]]
SerOut Tx, 84, [mobno[Bcnt]]
Next
Return

WaitForRing: ' Wait for someone to ring the mobile before send a SMS
Low Led1
SerIn Rx, 84, [Wait("RING")]
For Bcnt = 1 To 30
Low Led1
DelayMS 500
High Led1
DelayMS 500
Next
GoTo SendSMS

SendSMS:
SerOut Tx, 84, ["AT",13,10] ' Check if mobile is responding
SerIn Rx, 84,3000, Timeout, [Wait("O")]
Low Led1
DelayMS 500
High Led1
SerOut Tx, 84, ["AT+CMGS="]
bitcnt = 0
Bcnt = 0
Repeat
Inc bitcnt
Inc Bcnt
Until textmsg[Bcnt] = 0
Bcnt = 0
Repeat
Inc bitcnt
Inc Bcnt
Until mobno[Bcnt] = 0
SerOut Tx, 84, [Dec bitcnt+5,13,10] ' Set SMS pdu mode with PDU length
SerIn Rx, 84, 3000, Timeout, [Wait(">")]
Low Led1
DelayMS 500
High Led1
SerOut Tx, 84, ["001100"] ' Start of PDU protocol
GoSub output_mobileno
SerOut Tx, 84, ["0000FF"] ' Middle part of PDU protocol
GoSub septets_to_octets
SerOut Tx, 84, [26,13,10]
SerIn Rx, 84, 3000, Timeout, [Wait("O")]
Low Led1
DelayMS 4000
High Led1
GoTo WaitForRing ' Need to put a reset phone command here....


Timeout: ' An error has occurred trying to send a SMS
Low Led2
DelayMS 4000
High Led2
GoTo TheEnd

TheEnd:
Stop
************************************************** ******************



Thanks

camolas
- 4th October 2008, 00:54
Hi,

This is a update from my gsm/gps car alarm, i was stock in pdu (simens c55 sms only pdu)encoding i have traid a lot of self-maid/moding others people codes but no sucess (i can encode 9 bites but cant put it to the sending pdu array) for no reasan the big masters of this forum stop hellping me dont no why??? :( .
Now im going to turn my sellf to nokia 6210 (it was me 1st optcion from start have word sms ,but can get it to work with the pic)
I find a away to do it :) i can talk with nokia now, in a few days i will open a new thread and in there i will put the full code from my litle project.

Thanks for the ones that care and for the ones that stop caring too.