Changeset 133


Ignore:
Timestamp:
Sep 27, 2010, 2:08:51 PM (9 years ago)
Author:
mulligan
Message:

Fixed error in parser for intel hex format entries: entries consist of
lists of *nibbles*, not *bytes*. Changes propagated through rest of
file.

Location:
Deliverables/D4.1
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • Deliverables/D4.1/IntelHex.ml

    r132 r133  
    1313type intel_hex_entry =
    1414{
    15   record_length: byte * byte;
    16   record_addr: byte * byte * byte * byte;
     15  record_length: nibble * nibble;
     16  record_addr: nibble * nibble * nibble * nibble;
    1717  record_type: intel_hex_entry_type;
    18   data_field: byte list;
    19   data_checksum: byte * byte
     18  data_field: nibble list;
     19  data_checksum: nibble * nibble
    2020}
    2121;;
     
    9191         prs_hex_digit >>=
    9292fun a -> prs_hex_digit >>=
    93 fun b -> return (vect_of_hex_string (String.make 1 a) `Eight,
    94                  vect_of_hex_string (String.make 1 b) `Eight)
     93fun b -> return (vect_of_hex_string (String.make 1 a) `Four,
     94                 vect_of_hex_string (String.make 1 b) `Four)
    9595;;
    9696
     
    100100fun b -> prs_hex_digit >>=
    101101fun c -> prs_hex_digit >>=
    102 fun d -> return $ (vect_of_hex_string (String.make 1 a) `Eight,
    103                    vect_of_hex_string (String.make 1 b) `Eight,
    104                    vect_of_hex_string (String.make 1 c) `Eight,
    105                    vect_of_hex_string (String.make 1 d) `Eight)
     102fun d -> return $ (vect_of_hex_string (String.make 1 a) `Four,
     103                   vect_of_hex_string (String.make 1 b) `Four,
     104                   vect_of_hex_string (String.make 1 c) `Four,
     105                   vect_of_hex_string (String.make 1 d) `Four)
    106106;;
    107107
     
    119119fun a ->
    120120  let a_as_strs = List.map (String.make 1) a in
    121   let byte_data = List.map (fun x -> vect_of_hex_string x `Eight) a_as_strs in
     121  let byte_data = List.map (fun x -> vect_of_hex_string x `Four) a_as_strs in
    122122    return $ byte_data
    123123;;
     
    126126         prs_hex_digit >>=
    127127fun a -> prs_hex_digit >>=
    128 fun b -> return (vect_of_hex_string (String.make 1 a) `Eight,
    129                  vect_of_hex_string (String.make 1 b) `Eight)
     128fun b -> return (vect_of_hex_string (String.make 1 a) `Four,
     129                 vect_of_hex_string (String.make 1 b) `Four)
    130130;;
    131131
     
    137137fun d ->
    138138  let (l_u_b, l_l_b) = b in
    139   let len = int_of_vect (mk_word l_u_b l_l_b) in
     139  let len = int_of_vect (mk_byte l_u_b l_l_b) in
    140140    prs_data (2 * len) >>=
    141141fun e -> prs_checksum  >>=
     
    200200        aux (full_add hd bs cry) tl
    201201  in
    202     aux (false, (vect_of_int 0 `Eight)) r
     202    aux (false, (vect_of_int 0 `Four)) r
    203203
    204204let checksum_valid hex_entry =
     
    208208    let chk_1, chk_2 = hex_entry.data_checksum in
    209209    let _, cs_total = half_add chk_1 chk_2 in
    210     let len_1, len_2 = hex_entry.record_length in
     210(*    let len_1, len_2 = hex_entry.record_length in
    211211    let _, ln_total = half_add len_1 len_2 in
    212212    let adr_1, adr_2, adr_3, adr_4 = hex_entry.record_addr in
    213213    let _, ad_total1 = half_add adr_1 adr_2 in
    214     let _, ad_total2 = half_add adr_3 adr_4 in
     214    let _, ad_total2 = half_add adr_3 adr_4 in*)
    215215    let _, dt_total = add_bytes hex_entry.data_field in
    216     let _, total = add_bytes [cs_total; ln_total; ad_total1; ad_total2; dt_total] in
    217     let total = complement total in
     216(*    let _, total = add_bytes [cs_total; ln_total; ad_total1; ad_total2; dt_total] in *)
     217    let total = complement dt_total in
    218218      cs_total = total
     219
     220(* DPM: Debug
     221   let Some entry = intel_hex_format_of_string ":00000001FF";;
     222   checksum_valid $ List.hd entry;;
     223*)
  • Deliverables/D4.1/IntelHex.mli

    r131 r133  
    1212type intel_hex_entry =
    1313{
    14   record_length: byte * byte;
    15   record_addr: byte * byte * byte * byte;
     14  record_length: nibble * nibble;
     15  record_addr: nibble * nibble * nibble * nibble;
    1616  record_type: intel_hex_entry_type;
    17   data_field: byte list;
    18   data_checksum: byte * byte
     17  data_field: nibble list;
     18  data_checksum: nibble * nibble
    1919};;
    2020
Note: See TracChangeset for help on using the changeset viewer.