Skip to content

Commit aaff0d4

Browse files
committed
Fix response to EOF record
Loading Hex file was terminated prematurely (as soon as record type 1 was recognized), leading to a false error message in dsmtk. Now checksum of EOF record is checked and if correct, proper 'G' code is sent back.
1 parent 105188a commit aaff0d4

3 files changed

Lines changed: 32 additions & 25 deletions

File tree

command_1W.asm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ endif
2525
command_1wire_transfer:
2626
mov P1, #11111011b ; OW_GND do masy, jedynki gdzie indziej
2727
command_1wire_transfer_loop:
28-
acall get_hex_or_char
28+
bcall get_hex_or_char
2929
jnc command_1wire_send_byte
3030
jnz command_1wire_handle_char
3131
; C=1, A=0 -> koniec

library.asm

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
; You should have received a copy of the GNU General Public License
1414
; along with Programator. If not, see <https://www.gnu.org/licenses/>.
1515
;
16-
; Copyright (c) 2022, 2024 Aleksander Mazur
16+
; Copyright (c) 2022, 2024, 2025 Aleksander Mazur
1717
;
1818
; Funkcje pomocnicze, głównie do obsługi wejścia (poleceń)
1919

@@ -303,20 +303,25 @@ receive_hex_rec2:
303303
acall receive_hex_byte
304304
jc receive_hex_rec_error_H ; nie hex
305305
; A = typ rekordu (0 - dane, 1 - koniec)
306+
mov R6, A
307+
; w R6 policzymy sobie sumę kontrolną
308+
add A, R7
309+
add A, R4
310+
add A, R5
311+
xch A, R6
306312
jz receive_hex_rec_payload
313+
cjne A, #1, receive_hex_rec_error_R
314+
receive_hex_rec_check_sum:
315+
; wszystkie bajty odebrane, teraz powinna być suma kontrolna
316+
acall receive_hex_byte
317+
jc receive_hex_rec_error_H ; nie hex
318+
add A, R6
307319
setb C
308-
dec A
309-
jz ret7 ; A=0 i C=1 oznacza EOF
310-
; nieprawidłowy typ rekordu
311-
mov A, #'R'
320+
jz ret7 ; suma OK? to C=1 i A=0
321+
mov A, #'S'
312322
ret7:
313323
ret
314324
receive_hex_rec_payload:
315-
; w R6 policzymy sobie sumę kontrolną
316-
mov A, R7
317-
add A, R4
318-
add A, R5
319-
mov R6, A
320325
mov R0, #input ; R0 = pozycja w buforze
321326
mov A, R7
322327
jz receive_hex_rec_checksum
@@ -329,14 +334,12 @@ receive_hex_rec_loop:
329334
inc R0
330335
djnz R3, receive_hex_rec_loop
331336
receive_hex_rec_checksum:
332-
; wszystkie bajty odebrane, teraz powinna być suma kontrolna
333-
acall receive_hex_byte
334-
jc receive_hex_rec_error_H ; nie hex
335-
add A, R6
336-
jnz receive_hex_rec_error_S
337+
acall receive_hex_rec_check_sum
338+
jnz ret9
339+
; rekord wczytany poprawnie
337340
mov R0, #input
338-
receive_hex_rec_eof:
339341
clr C
342+
ret9:
340343
ret
341344
receive_hex_rec_error_H:
342345
; C=1
@@ -346,9 +349,9 @@ receive_hex_rec_error_L:
346349
setb C
347350
mov A, #'L'
348351
ret
349-
receive_hex_rec_error_S:
352+
receive_hex_rec_error_R:
350353
setb C
351-
mov A, #'S'
354+
mov A, #'R'
352355
ret
353356

354357
;-----------------------------------------------------------
@@ -379,14 +382,13 @@ load_hex_file:
379382
acall ensure_no_args
380383
load_hex_file_loop:
381384
acall receive_hex_rec
382-
jc load_hex_file_check
385+
jc load_hex_rec_check
383386
; pod R0 jest R7 bajtów do zapisu pod adres R4:R5
384387
; (adres z R4:R5 jest w dziedzinie specyficznej dla callbacka)
385388
mov A, R7
386389
jz load_hex_rec_empty ; zabezpieczenie przed rekordem o zerowej długości
387390
clr A
388391
acall jmp_dptr
389-
load_hex_file_check:
390392
jz ret8
391393
load_hex_file_error:
392394
; w A jest znak ACK/NAK
@@ -395,6 +397,11 @@ load_hex_file_error:
395397
load_hex_rec_empty:
396398
mov A, #'G'
397399
sjmp load_hex_file_error
400+
load_hex_rec_check:
401+
; C=1 i A=0 -> EOF; wypisujemy G i wychodzimy
402+
jnz load_hex_file_error
403+
mov A, #'G'
404+
ajmp uart_send_char
398405

399406
;-----------------------------------------------------------
400407
; Dekoduje liczbę szesnastkową podaną w ASCII do rejestrów R2:R3.

main.asm

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -717,7 +717,7 @@ endif
717717
if USE_AVR
718718
s_welcome3: db "AVR"
719719
endif
720-
s_welcome4: db " PROGRAMMER VERSION 1.1 Copyright (c) 2022-2024 Aleksander Mazur",0
720+
s_welcome4: db " PROGRAMMER VERSION 1.2 Copyright (c) 2022-2025 Aleksander Mazur",0
721721

722722
if USE_HELP_DESC
723723
if USE_HELP
@@ -739,9 +739,9 @@ s_help_LR: db "Load internal RAM",0
739739
s_help_VR: db "Verify internal RAM",0
740740
endif
741741
if ICP51_W79EX051
742-
s_help_D: db "Dump W79EX051 memory",0
743-
s_help_V: db "Verify W79EX051 memory",0
744-
s_help_LB: db "Load W79EX051 memory blindly",0
742+
s_help_D: db "Dump W79EX051",0
743+
s_help_V: db "Verify W79EX051",0
744+
s_help_LB: db "Load W79EX051 blindly",0
745745
s_help_K: db "Klear W79EX051: 26=erase all, 22=AP flash (default), 62=NVM",0
746746
s_help_NR: db "Reset W79EX051 & enter ICP mode",0
747747
s_help_NT: db "Transfer to/from W79EX051 (no reset): NT 0000S0BRJ FB00S0CRZ RJ",0

0 commit comments

Comments
 (0)