Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Projet_Pico_ordi_B6
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Man hing Ling
Projet_Pico_ordi_B6
Commits
ae5a82ec
Commit
ae5a82ec
authored
1 year ago
by
Man hing Ling
Browse files
Options
Downloads
Patches
Plain Diff
Toutes les commandes fonctionnent
parent
514b0b2a
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
SD/picofs.c
+23
-19
23 additions, 19 deletions
SD/picofs.c
with
23 additions
and
19 deletions
SD/picofs.c
+
23
−
19
View file @
ae5a82ec
...
@@ -398,7 +398,6 @@ void CP(SD_info *sd, char *source_filename, char *destination_filename) {
...
@@ -398,7 +398,6 @@ void CP(SD_info *sd, char *source_filename, char *destination_filename) {
char
numBuffer
[
64
];
char
numBuffer
[
64
];
int
destination_offset
;
int
destination_offset
;
int
source_offset
;
int
source_offset
;
int
offset
;
int
numDataBlock
;
int
numDataBlock
;
int
newDataBlock
;
int
newDataBlock
;
...
@@ -440,46 +439,54 @@ void CP(SD_info *sd, char *source_filename, char *destination_filename) {
...
@@ -440,46 +439,54 @@ void CP(SD_info *sd, char *source_filename, char *destination_filename) {
writeBlock
(
sd
,
destination_offset
,
0
,
destination_filename
,
strlen
(
destination_filename
));
writeBlock
(
sd
,
destination_offset
,
0
,
destination_filename
,
strlen
(
destination_filename
));
// Copier les blocs de données associés au fichier source dans de nouveaux blocs de données pour le fichier destination
// Copier les blocs de données associés au fichier source dans de nouveaux blocs de données pour le fichier destination
for
(
int
i
=
0
;
i
<
MAX_BLOCKS_PER_FILE_DESCRIPTION
;
i
++
)
{
//for (int i = 1; i < MAX_BLOCKS_PER_FILE_DESCRIPTION; i++) {
if
(
i
==
0
)
{
offset
=
MAX_FILENAME_LENGTH
;
}
else
{
offset
=
0
;
}
// Lecture des numéros de bloc dans les blocs de description
// Lecture des numéros de bloc dans les blocs de description
for
(
int
byteNum
=
0
;
byteNum
<
BLOCK_SIZE
;
byteNum
+=
2
)
{
//
for (int byteNum=0; byteNum<BLOCK_SIZE; byteNum+=2) {
readBlock
(
sd
,
source_offset
+
i
,
offset
+
byteNum
,
numBuffer
,
2
);
readBlock
(
sd
,
source_offset
+
1
,
0
,
numBuffer
,
2
);
numDataBlock
=
reconstituteNumber
(
numBuffer
);
numDataBlock
=
reconstituteNumber
(
numBuffer
);
//si aucune donnée à copier
if
(
numDataBlock
==
0
)
{
if
(
numDataBlock
==
0
)
{
printf
(
"
\n
La copie de
\"
%s
\"
sous le nom
\"
%s
\"
a été créée avec succès.
\n
"
,
source_filename
,
destination_filename
);
printf
(
"
\n
La copie de
\"
%s
\"
sous le nom
\"
%s
\"
a été créée avec succès.
\n
"
,
source_filename
,
destination_filename
);
return
;
return
;
}
}
for
(
int
chunkStart
=
0
;
chunkStart
<
BLOCK_SIZE
;
chunkStart
+=
CHUNK_SIZE
)
{
//
for (int chunkStart = 0; chunkStart < BLOCK_SIZE; chunkStart +=
//
CHUNK_SIZE) {
// On stocke le bloc de données associé au fichier source dans descriptionBuffer
// On stocke le bloc de données associé au fichier source dans descriptionBuffer
readBlock
(
sd
,
numDataBlock
,
chunkStart
,
descriptionBuffer
,
CHUNK_SIZE
);
readBlock
(
sd
,
numDataBlock
,
0
,
descriptionBuffer
,
CHUNK_SIZE
);
if
(
chunkStart
==
0
)
{
// Trouver un nouveau bloc de données disponible
// Trouver un nouveau bloc de données disponible
newDataBlock
=
findAvailableBlock
(
sd
);
newDataBlock
=
findAvailableBlock
(
sd
);
char
dataBlockNumBuffer
[
CHUNK_SIZE
];
readBlock
(
sd
,
newDataBlock
,
0
,
dataBlockNumBuffer
,
CHUNK_SIZE
);
while
(
dataBlockNumBuffer
[
0
]
!=
0
)
{
newDataBlock
++
;
readBlock
(
sd
,
newDataBlock
,
0
,
dataBlockNumBuffer
,
CHUNK_SIZE
);
}
// Mise à jour de la carte de disponibilités
// Mise à jour de la carte de disponibilités
setBlockAvailability
(
sd
,
newDataBlock
,
1
);
setBlockAvailability
(
sd
,
newDataBlock
,
1
);
// Ecriture du numéro de bloc dans la description du fichier
// Ecriture du numéro de bloc dans la description du fichier
createNumberBuffer
(
newDataBlock
,
numBuffer
);
createNumberBuffer
(
newDataBlock
,
numBuffer
);
writeBlock
(
sd
,
destination_offset
+
i
,
offset
+
byteNum
,
numBuffer
,
2
);
writeBlock
(
sd
,
destination_offset
+
1
,
0
,
numBuffer
,
2
);
}
// Ecriture du bloc de données dans le premier bloc disponible
// Ecriture du bloc de données dans le premier bloc disponible
writeBlock
(
sd
,
newDataBlock
,
chunkStart
,
descriptionBuffer
,
CHUNK_SIZE
);
writeBlock
(
sd
,
newDataBlock
,
0
,
descriptionBuffer
,
CHUNK_SIZE
);
}
printf
(
"
\n
La copie de
\"
%s
\"
sous le nom
\"
%s
\"
a été créée avec succès.
\n
"
,
source_filename
,
destination_filename
);
}
//}
}
}
}
int
main
(
int
argc
,
char
*
argv
[])
{
int
main
(
int
argc
,
char
*
argv
[])
{
char
user_data
;
char
user_data
;
...
@@ -497,14 +504,11 @@ int main(int argc, char *argv[]) {
...
@@ -497,14 +504,11 @@ int main(int argc, char *argv[]) {
printf
(
"Pico ordinateur OK
\n\n
"
);
printf
(
"Pico ordinateur OK
\n\n
"
);
erase
(
&
sd
,
0
,
15000
);
current_cmd
[
0
]
=
'\0'
;
// Initialise la chaîne vide
current_cmd
[
0
]
=
'\0'
;
// Initialise la chaîne vide
printf
(
"PicoOrdi>"
);
printf
(
"PicoOrdi>"
);
while
(
1
)
{
while
(
1
)
{
_delay_ms
(
10
);
user_data
=
get_serial
();
user_data
=
get_serial
();
if
(
user_data
==
'\b'
){
if
(
user_data
==
'\b'
){
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment