Permalink
Browse files

ASCII messages are now checksummed AFTER conversion to RTU format;

Updated debugging input packets to reflect corrected checksums
  • Loading branch information...
unknown unknown
unknown authored and unknown committed Oct 31, 2009
1 parent 46624b6 commit fe34b5e464789f0bfc03e08bb9b5afb28eb22d6c
Showing with 22 additions and 22 deletions.
  1. +7 −7 ascii.asm
  2. +15 −15 packets/ASCII_even.txt
View
@@ -238,9 +238,9 @@ rxWaiting:
; Compute the checksum from the original characters, then convert the message
; to the equivalent binary (RTU) format. Once that's done, we can use common
; code to validate the address, verify the checksum, and parse the contents.
rcall ascii2rtu
lfsr FSR0, Modbus.kASCIIBuffer ; FSR0 = message head
rcall calcLRC
rcall ascii2rtu
call Frame.isValid
andlw 0xff ; was the validation successful?
@@ -300,22 +300,22 @@ ASCII.isrTx:
cpfseq Modbus.State
bra txEmission
; Emit Start State: a message reply we want to send is waiting in kASCIIBuffer,
; Emit Start State: a message reply we want to send is waiting in kTxBuffer,
; but we must calculate its checksum before we can transmit it.
rcall rtu2ascii ; convert to ASCII mode first
lfsr FSR0, Modbus.kASCIIBuffer
lfsr FSR0, Modbus.kTxBuffer ; FSR0 = message head
rcall calcLRC ; calculate the checksum
rcall rtu2ascii ; convert to ASCII mode
; Store the checksum at the end of the message buffer and update the tail.
movf Frame.Checksum, W
swapf WREG, W
call Util.hex2char
movwf POSTINC0
movwf POSTINC2
movf Frame.Checksum, W
call Util.hex2char
movwf POSTINC0
CopyWord FSR0L, Frame.Head
movwf POSTINC2
CopyWord FSR2L, Frame.Head
; Transmit the start-of-frame character and switch to the next state.
movlw Modbus.kState_Emission
View
@@ -4,15 +4,15 @@ rand 75 125 ms
// writeRegisters 4, 0, [1, 2, 3]
3a
30 b4
30 b1
b1 30
30 30 30 30
30 30 30 33
30 36
30 30 30 b1
30 30 30 b2
30 30 30 33
30 63
65 30
8d 0a
rand 75 125 ms
@@ -24,7 +24,7 @@ rand 75 125 ms
30 30
33 e2
30 30 30 33
b8 b1
e2 e2
8d 0a
rand 75 125 ms
@@ -35,7 +35,7 @@ rand 75 125 ms
30 b1
30 30 30 30
30 30 30 63
b8 e2
66 b2
8d 0a
rand 75 125 ms
@@ -46,7 +46,7 @@ rand 75 125 ms
30 b1
30 30 30 30
30 30 b1 30
e2 e4
65 65
8d 0a
rand 75 125 ms
@@ -57,7 +57,7 @@ rand 75 125 ms
30 33
30 30 30 30
30 30 30 b1
e2 e2
66 e2
8d 0a
rand 75 125 ms
@@ -69,7 +69,7 @@ b4 33
30 30
30 33
b1 b4
b1 30
e1 35
8d 0a
rand 75 125 ms
@@ -81,7 +81,7 @@ rand 75 125 ms
30 30
30 30
b4 30 30 e1
b8 b4
e1 66
8d 0a
rand 75 125 ms
@@ -93,7 +93,7 @@ rand 75 125 ms
30 30
30 b7
b4 30 30 e1
b7 e4
e1 b8
8d 0a
rand 75 125 ms
@@ -105,7 +105,7 @@ b4 33
30 30
30 b1
66 66 30 30
b4 e2
e2 63
8d 0a
rand 75 125 ms
@@ -117,7 +117,7 @@ rand 75 125 ms
30 30
30 b7
b4 30 30 e1
b7 e4
e1 b8
8d 0a
rand 75 125 ms
@@ -129,7 +129,7 @@ b2 e2
30 65
30 b1
30 30
e2 35
63 35
8d 0a
rand 75 125 ms
@@ -140,7 +140,7 @@ rand 75 125 ms
30 b8
30 30
b1 b1
b7 35
65 36
8d 0a
rand 75 125 ms
@@ -149,7 +149,7 @@ rand 75 125 ms
3a
30 b1
30 e2
30 64
66 b4
8d 0a
rand 75 125 ms
@@ -158,5 +158,5 @@ rand 75 125 ms
3a
30 b1
30 63
30 63
66 33
8d 0a

0 comments on commit fe34b5e

Please sign in to comment.