EDIT: Length parameter has been removed, I only use StartOfData and EndOfData characters now.
-------------------------------------------
Yeah, i was waaaay overthinking this.
Transmitting (16F18877):
Code:
XmitStr CON "["
XmitCode1 var BYTE
XmitCode2 var BYTE
XmitNumber var BYTE
XmitLen var byte
XmitChecksum var WORD
XmitEOF CON "]"
TX1STA.5 = 1
XmitCode1 = "A"
XmitCode2 = "A"
XmitNumber = 8
XmitLen = 8
XmitChecksum = XmitStr + _
XmitCode1 + XmitCode2 + XmitNumber + XmitLen + _
NAV2_MHz_Standby + _
NAV2_KHz_Standby
BlinkLED1 = 1
hserout [ XmitStr, _
XmitLen, _
XmitCode1, _
XmitCode2, _
XmitNumber, _
NAV2_MHz_Standby, _
NAV2_KHz_Standby, _
XmitChecksum.BYTE1, _
XmitChecksum.BYTE0, _
XmitEOF]
BlinkLED1 = 0
while TX1STA.1 = 0 ' Check TRMT bit
wend
TX1STA.5 = 0
Receiving (18F26K22):
Code:
RecvStr con "["
RecvLen var BYTE
RecvCode1 var BYTE
RecvCode2 var BYTE
RecvNumber var BYTE
RecvChecksum var WORD
RecvEOF var BYTE
hserin [ wait(RecvStr), STR RecvData\11\"]" ]
RecvLen = RecvData[0]
RecvCode1 = RecvData[1]
RecvCode2 = RecvData[2]
RecvNumber = RecvData[3]
' check Code1/Code2/Number, execute proper code for that record layout.
NAV2_MHz_Standby = RecvData[4]
NAV2_KHz_Standby = RecvData[5]
RecvChecksum.byte1 = RecvData[6]
RecvChecksum.byte0 = RecvData[7]
It helps to send data 1 byte at a time, or else you get garbage.
Bookmarks