Changeset 133 for Deliverables/D4.1/IntelHex.ml
 Timestamp:
 Sep 27, 2010, 2:08:51 PM (9 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

Deliverables/D4.1/IntelHex.ml
r132 r133 13 13 type intel_hex_entry = 14 14 { 15 record_length: byte * byte;16 record_addr: byte * byte * byte * byte;15 record_length: nibble * nibble; 16 record_addr: nibble * nibble * nibble * nibble; 17 17 record_type: intel_hex_entry_type; 18 data_field: byte list;19 data_checksum: byte * byte18 data_field: nibble list; 19 data_checksum: nibble * nibble 20 20 } 21 21 ;; … … 91 91 prs_hex_digit >>= 92 92 fun 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)93 fun b > return (vect_of_hex_string (String.make 1 a) `Four, 94 vect_of_hex_string (String.make 1 b) `Four) 95 95 ;; 96 96 … … 100 100 fun b > prs_hex_digit >>= 101 101 fun 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)102 fun 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) 106 106 ;; 107 107 … … 119 119 fun a > 120 120 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 in121 let byte_data = List.map (fun x > vect_of_hex_string x `Four) a_as_strs in 122 122 return $ byte_data 123 123 ;; … … 126 126 prs_hex_digit >>= 127 127 fun 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)128 fun b > return (vect_of_hex_string (String.make 1 a) `Four, 129 vect_of_hex_string (String.make 1 b) `Four) 130 130 ;; 131 131 … … 137 137 fun d > 138 138 let (l_u_b, l_l_b) = b in 139 let len = int_of_vect (mk_ wordl_u_b l_l_b) in139 let len = int_of_vect (mk_byte l_u_b l_l_b) in 140 140 prs_data (2 * len) >>= 141 141 fun e > prs_checksum >>= … … 200 200 aux (full_add hd bs cry) tl 201 201 in 202 aux (false, (vect_of_int 0 ` Eight)) r202 aux (false, (vect_of_int 0 `Four)) r 203 203 204 204 let checksum_valid hex_entry = … … 208 208 let chk_1, chk_2 = hex_entry.data_checksum in 209 209 let _, cs_total = half_add chk_1 chk_2 in 210 let len_1, len_2 = hex_entry.record_length in210 (* let len_1, len_2 = hex_entry.record_length in 211 211 let _, ln_total = half_add len_1 len_2 in 212 212 let adr_1, adr_2, adr_3, adr_4 = hex_entry.record_addr in 213 213 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*) 215 215 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 in216 (* let _, total = add_bytes [cs_total; ln_total; ad_total1; ad_total2; dt_total] in *) 217 let total = complement dt_total in 218 218 cs_total = total 219 220 (* DPM: Debug 221 let Some entry = intel_hex_format_of_string ":00000001FF";; 222 checksum_valid $ List.hd entry;; 223 *)
Note: See TracChangeset
for help on using the changeset viewer.