This code is sufficient for the UART check.
It has been fully tested and I have never seen it fail on this project.
read_azim:
Hserget hdr1 'remote Azimuth from 18F4520 PIC, it expects AxxxExxx in ASCII format'' the hserget flushes out any odd characters
If hdr1 <> "A" Then Goto clr_azim 'wait for 'A' sync character' if Hserget reads only a 'A' will it continue else it will loop back to read_azim and flush the uart buffer
For rx = 0 To 6 'get all 6 characters' Hserin will read in the remaining characters of the string
Hserin gpsrxd
uartrxd = uartrxd + gpsrxd
Next rx
If MidStr(uartrxd, 4, 1) <> "E" Then Goto clr_azim' a further verification of the string, testing for 'E' in the correct location
,
gpsazim = LeftStr(uartrxd, 3)
gpselev = RightStr(uartrxd, 3) '++++ for Elev
azimval = StrValW(gpsazim) 'convert ascii to numeric and
elevval = StrValW(gpselev) '++++
If azimval > 359 Then
Goto clr_azim 'invalid so await next azim input' another string verification checking the value is less then 360 degrees
Endif
It has been fully tested and I have never seen it fail on this project.
read_azim:
Hserget hdr1 'remote Azimuth from 18F4520 PIC, it expects AxxxExxx in ASCII format'' the hserget flushes out any odd characters
If hdr1 <> "A" Then Goto clr_azim 'wait for 'A' sync character' if Hserget reads only a 'A' will it continue else it will loop back to read_azim and flush the uart buffer
For rx = 0 To 6 'get all 6 characters' Hserin will read in the remaining characters of the string
Hserin gpsrxd
uartrxd = uartrxd + gpsrxd
Next rx
If MidStr(uartrxd, 4, 1) <> "E" Then Goto clr_azim' a further verification of the string, testing for 'E' in the correct location
,
gpsazim = LeftStr(uartrxd, 3)
gpselev = RightStr(uartrxd, 3) '++++ for Elev
azimval = StrValW(gpsazim) 'convert ascii to numeric and
elevval = StrValW(gpselev) '++++
If azimval > 359 Then
Goto clr_azim 'invalid so await next azim input' another string verification checking the value is less then 360 degrees
Endif