This commit is contained in:
Florian Briand 2024-08-01 22:55:30 +02:00
parent 419e03c46a
commit 538675de1d
Signed by: florian_briand
GPG Key ID: CC981B9E6B98E70B
2 changed files with 20 additions and 2 deletions

View File

@ -319,6 +319,7 @@ mod test_decode_ssv_memory {
1, 49,
];
let blocks = decode_ssv_memory(&bytes, bytes.len());
println!("{:#?}", blocks);
assert_eq!(blocks.len(), 2);
}
}

View File

@ -182,10 +182,13 @@ pub fn decode_zone_memoire(bytes: &[u8]) {
situations: Vec::new(),
};
println!("--- Decoding Zone Memoire ---");
println!("Taille de la zone mémoire: {}", bytes.len());
while current_pos_general < bytes.len() - 1 {
num_champ = 0;
current_groupe =
256 * bytes[current_pos_general] as i32 + bytes[current_pos_general + 1] as i32;
println!("-- Nouveau groupe : {}", current_groupe);
current_pos_general += 2;
let longueur_groupe: usize;
@ -198,11 +201,13 @@ pub fn decode_zone_memoire(bytes: &[u8]) {
acc + (256_i32.pow(i as u32) * bytes[current_pos_general] as i32) as usize
});
}
println!("--- Longueur groupe: {}", longueur_groupe);
current_pos_general += 1;
let mut current_pos_groupe = 0;
while current_pos_groupe < longueur_groupe {
num_champ += 1;
println!("---- Nouveau champ : {}", num_champ);
let longueur_champs: usize;
let nbre_octets_longueur: usize;
if bytes[current_pos_general] < 128 {
@ -216,6 +221,7 @@ pub fn decode_zone_memoire(bytes: &[u8]) {
acc + (256_i32.pow(i as u32) * bytes[current_pos_general] as i32) as usize
});
}
println!("----- Longueur champ: {}", longueur_champs);
let mut bytes_champ = vec![0; longueur_champs];
if longueur_champs > 0 {
@ -223,6 +229,7 @@ pub fn decode_zone_memoire(bytes: &[u8]) {
&bytes[current_pos_general + nbre_octets_longueur
..current_pos_general + nbre_octets_longueur + longueur_champs],
);
println!("----- Bytes du champ: {:?}", bytes_champ);
match current_groupe {
1 => match num_champ {
@ -374,17 +381,27 @@ pub fn decode_zone_memoire(bytes: &[u8]) {
String::from_utf8_lossy(&bytes_champ).to_string();
}
20 => {
carte_ps.situations.last_mut().unwrap().habilitation_à_signer_une_facture =
carte_ps
.situations
.last_mut()
.unwrap()
.habilitation_à_signer_une_facture =
String::from_utf8_lossy(&bytes_champ).to_string();
}
21 => {
carte_ps.situations.last_mut().unwrap().habilitation_à_signer_un_lot =
carte_ps
.situations
.last_mut()
.unwrap()
.habilitation_à_signer_un_lot =
String::from_utf8_lossy(&bytes_champ).to_string();
}
_ => (),
},
_ => (),
}
} else {
println!("----- Pas de bytes pour ce champ");
}
current_pos_general += longueur_champs + nbre_octets_longueur;