Dim inbuff(40) As Byte
Dim inptr As Byte
Dim outptr As Byte
Dim first(10) As Byte
Dim second(10) As Byte
Dim az As Word
Dim el As Word
Hseropen 19200
WaitMs 100
PIE1.RCIE = 1
INTCON.PEIE = 1
INTCON.GIE = 1
outptr = 0
inptr = 0
main:
If outptr > 0 Then
Call split()
Call getnumb()
outptr = 0
inptr = 0
Hserout "Azmouth = ", #az, 10, 13
Hserout "Elevation = ", #el, 10, 13
Endif
Goto main
End
On Interrupt
Save System
If RCSTA.OERR = True Then
RCSTA.CREN = 0
RCSTA.CREN = 1
Goto fin
Endif
inptr = inptr + 1
If inptr = 39 Then inptr = 0
inbuff(inptr) = RCREG
If inbuff(inptr) = 0xd Then outptr = inptr
fin:
Resume
Proc getnumb()
Dim x As Byte
x = 2
az = 0
While first(x) <> 0x2e
az = az * 10
az = az + first(x) - 0x30
x = x + 1
Wend
x = 2
el = 0
While second(x) <> 0x2e
el = el * 10
el = el + second(x) - 0x30
x = x + 1
Wend
End Proc
Proc split()
Dim x As Byte
Dim y As Byte
x = 1
y = 0
While inbuff(x) <> 32
first(y) = inbuff(x)
x = x + 1
y = y + 1
Wend
first(x) = 0
x = x + 1
y = 0
While inbuff(x) <> 13
second(y) = inbuff(x)
x = x + 1
y = y + 1
Wend
End Proc