我记错了不少东西.一年前的印象了.下面是信标发送的详细过程,供大家参考
;send out a beacon. if gps unit connected do some checking and then let nmea do it.
beacon //信标发送
btfsc beacon_enable //是否允许发送?
goto check_addresses
goto beacon_return //不允许,退出
; mycall, btext, and unproto should be valid before sending
;a beacon. via will be used if it is valid 我的呼号\文本和unproto是可用.如故via设置了,也要被用到
check_addresses
btfss valid_mycall //没设置呼号,退出
goto beacon_return
btfss valid_unproto //没设置unproto,退出
goto beacon_return
;is there a gps unit connected? if so, gather the input and process
btfss gps_connected //gps连接?
goto no_gps //不处理gps数据
;is a gps so go ahead and process nmea
;turn the uart receive back on
bsf rcsta,cren //打开串口,接收gps数据
;should be a stream of chars coming in
nmea_start_again //等待gps数据
call getc_sleep
btfsc char_timeout ;规定时间内没有gps数据进入,退出
goto beacon_return ;we timed out, just get out
is_it_start?
;sit here waiting around until you get a valid start of a nmea sentence
movfw rcd_char
xorlw '$' ;start of sentence? //寻找字符'$',作为gps开始数据
skpnz
goto buffer_nmea ;saw the $, start buffering
goto nmea_start_again ;look again,no $
buffer_nmea //发现gps开始字符
call load_tty_buffer ;load the buffer //读入缓冲区数据
;check timeout again
btfsc char_timeout //检查是否超时
goto beacon_return ;timed out with partial sentence //超时退出
call nmea_sum ;is it the right nmea sentence? //类加校验和
movwf temp ;could be either gprmc or gpgll
btfss gprmc // 判断gps数据类型是否rmc
goto try_gpgll
movlw 'g'+'p'+'r'+'m'+'c' //处理rmc数据
goto do_nema_test
try_gpgll
btfss gpgll
goto try_gpgga
movlw 'g'+'p'+'g'+'l'+'l' //处理gll数据
goto do_nema_test
try_gpgga
btfss gpgga
goto beacon_return //不是指定3种类型,退出 ;a sentence type is not set, get out
movlw 'g'+'p'+'g'+'g'+'a' //处理gga数据
do_nema_test
xorwf temp,w //根据校验和判断gps数据接受结束?
skpz
goto nmea_start_again
;nmea complete input, sent it
add_btext
;but first, turn the uart receive back off
bcf rcsta,cren //关闭串口
call send_a_header //首先发送一个包含呼号和unproto的包头
movlw '$' ;put out the $
call reg_packet_out ;send it
;now do the body. don't want to map these to upper case
bcf to_upper
clrf offset ;now point back to start of text
send_data_loop //发送gps数据
call unload_tty_buffer
movfw rcd_char
call reg_packet_out ;send it
movlw cr
xorwf rcd_char,w
skpz
goto send_data_loop
goto end_of_beacon ;done, finish up //发完了
no_gps //无gps连接,为普通信标 ;no gps found, do as normal beacon
btfss valid_btext //信标文本设置?
goto beacon_return //没有设置退出
call send_a_header //首先发送包含呼号和unproto的包头
;do the beacon text
movlw beacon_ee_start //从eerom中读取信标文本
movwf var_1
beacon_loop
movfw var_1
bank2
movwf eeadr
bank3
bsf eecon1,rd ;pull the data from the ee ram
bank2
movf eedata,w
bank0
;w now has the character, there is a null at the end
skpnz
goto end_of_beacon
call reg_packet_out //发送信标文本
incf var_1,f
goto beacon_loop
end_of_beacon
call finish_up //添加ax.25校验码
call key_up //关闭发送,停止t0中断
beacon_return
bcf run_beacon ;deschedule //停止信标发送
return