Oi pessoal
Tenho andado a programar bascom para o arduino e tem funcionado.
No entanto não consigo fazer o bascom comunicar com o módulo gps que tenho aqui ... alguém ajuda...
Tirei o código de outro site e alterei-o um pouco ... alguém me diz porque n
ao funciona ?
'--------------------------------------------------------------
' GPS PARSE NEMA MESSAGE RMC
' Douglas Burkett
' 9 January 2002
'--------------------------------------------------------------
$crystal = 16000000
$baud = 9600
Dim Sync_char As Byte , Tmdt As String * 7 , Tmp As String * 3 , Sentence_hdr As String * 6
Dim A As Byte , Hh As Integer , Mm As Integer , Ss As Integer
Dim Xx As Word
Cls
Sync: 'use $ as sync character, it starts every NMEA sentence
Hh = -1
Mm = -1
Ss = -1
'Loops until a start of sentence character is received.
Open "comd.0:9600,8,N,1" For Input As #1
Open "comd.1:9600,8,N,1" For Output As #2
Do
Set Portb.5
Print #2 , " Not Parsing ...." 'message available
Sync_char = Inkey(#1) 'check serial port
Print #2 , Sync_char 'message available
If Sync_char = "$" Then
Print #2 , "Parsing ...." 'message available
Goto Msg_parse
End If
Reset Portb.5
Loop 'Forever
Msg_parse:
Inputbin Sentence_hdr 'get five characters, weird because the sixth character triggers the action and is lost
'which in this case is okay because it is the comma separator, odd.
If Sentence_hdr <> "GPRMC" Then Goto Sync 'Is it the right sentence?
Inputbin Tmdt
Tmp = Left(tmdt , 2)
Hh = Val(tmp)
If Hh < 0 Or A > 24 Then Goto Invalid_time
Tmp = Mid(tmdt , 3 , 2)
Mm = Val(tmp)
If Mm < 0 Or Mm > 59 Then Goto Invalid_time
Tmp = Mid(tmdt , 5 , 2)
Ss = Val(tmp)
If Ss < 0 Or Ss > 59 Then Goto Invalid_time
Print #2 , "Time " ; Hh ; ":" ; Mm ; ":" ; Ss
Goto Sync
Invalid_time:
Wait 3 'pause to read
Goto Sync
Close #1
Close #2
End