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
514b0b2a
Commit
514b0b2a
authored
1 year ago
by
Man hing Ling
Browse files
Options
Downloads
Patches
Plain Diff
RM CAT TYPE MV LS fonctionnels, manque CP
parent
9cbc6286
No related branches found
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
+28
-40
28 additions, 40 deletions
SD/picofs.c
with
28 additions
and
40 deletions
SD/picofs.c
+
28
−
40
View file @
514b0b2a
...
...
@@ -51,20 +51,6 @@ void writeBlock(SD_info *sd, unsigned int numBlock, int offset, char *source, in
}
// void eraseSD(SD_info *sd){ //met des 0 partout dans la carte SD
// char zeros[BLOCK_SIZE];
// for(int i = 0; i< BLOCK_SIZE-1;i++){
// zeros[i] = '0';
// }
// zeros[BLOCK_SIZE-1] = '\0';
//
// for (int blockNum = 0; blockNum < 5000; blockNum ++){
// //printf("erase\n");
// writeBlockSD(sd,blockNum,zeros);
// }
// return;
// }
void
LS
(
SD_info
*
sd
)
{
char
buffer
[
MAX_FILENAME_LENGTH
];
int
fileCount
=
0
;
...
...
@@ -154,11 +140,7 @@ void RM(SD_info *sd, char *filename) {
}
for
(
int
blockNum
=
offset
+
1
;
blockNum
<
offset
+
16
;
blockNum
++
)
{
int
startOffset
=
0
;
if
(
blockNum
==
offset
)
{
startOffset
=
MAX_FILENAME_LENGTH
;
}
//for (int chunkStart = startOffset; chunkStart < BLOCK_SIZE/2; chunkStart += CHUNK_SIZE) {
// int chunkSize = min(CHUNK_SIZE, BLOCK_SIZE/2 - chunkStart);
...
...
@@ -291,8 +273,17 @@ void TYPE(SD_info *sd, char *filename, char *data) {
writeBlock
(
sd
,
blockNum
,
0
,
filename
,
sizeFilename
);
placeFound
=
blockNum
;
//
Lire les données depuis l'entrée standard et écrire dans le fichier
//
chercher où mettre les données du
int
dataBlockNum
=
findAvailableBlock
(
sd
);
// Premier bloc de données à partir du bloc 1040
char
dataBlockNumBuffer
[
CHUNK_SIZE
];
readBlock
(
sd
,
dataBlockNum
,
0
,
dataBlockNumBuffer
,
CHUNK_SIZE
);
while
(
dataBlockNumBuffer
[
0
]
!=
0
)
{
dataBlockNum
++
;
readBlock
(
sd
,
dataBlockNum
,
0
,
dataBlockNumBuffer
,
CHUNK_SIZE
);
}
int
blockSizeUsed
=
0
;
// Compteur d'octets dans le bloc actuel
char
chunkBuffer
[
CHUNK_SIZE
];
...
...
@@ -356,7 +347,7 @@ void CAT(SD_info *sd, char *filename) {
char
filenameBuffer
[
MAX_FILENAME_LENGTH
];
char
byteBuffer
[
CHUNK_SIZE
];
char
dataBuffer
[
CHUNK_SIZE
];
int
offset
;
// Parcours des blocs réservés pour la description des fichiers (superbloc)
for
(
int
blockNum
=
0
;
blockNum
<
MAX_BLOCKS_IN_SUPERBLOCK
;
blockNum
+=
16
)
{
...
...
@@ -368,29 +359,26 @@ void CAT(SD_info *sd, char *filename) {
// Parcours les blocs de description
for
(
int
descrBlockNum
=
1
;
descrBlockNum
<
MAX_BLOCKS_PER_FILE_DESCRIPTION
;
descrBlockNum
++
)
{
if
(
descrBlockNum
==
0
)
{
offset
=
MAX_FILENAME_LENGTH
;
}
else
{
offset
=
0
;
}
// Lecture des octets deux par deux
for
(
int
i
=
0
;
i
<
BLOCK_SIZE
;
i
+=
2
)
{
readBlock
(
sd
,
descrBlockNum
+
blockNum
,
offset
+
i
,
byteBuffer
,
2
);
printf
(
"
\n
Byte buffer: %s
\n
"
,
byteBuffer
);
//for (int i=0; i<BLOCK_SIZE;i+=2) {
readBlock
(
sd
,
descrBlockNum
+
blockNum
,
0
,
byteBuffer
,
2
);
if
(
byteBuffer
[
0
]
==
0
&&
byteBuffer
[
1
]
==
0
)
return
;
// printf("\nByte buffer: %s\n", byteBuffer);
// Lire les numéros de blocs associés à ce fichier depuis les blocs de description
int
dataBlockNum
=
reconstituteNumber
(
byteBuffer
);
// Vérifier si le numéro de bloc est valide (non nul)
if
(
dataBlockNum
==
0
)
{
return
;
// Fin du fichier
}
//
if (dataBlockNum == 0) {
//
return; // Fin du fichier
//
}
//for (int chunkStart = 0; chunkStart < BLOCK_SIZE; chunkStart += CHUNK_SIZE) {
// Lire et afficher le contenu du bloc de données
readBlock
(
sd
,
dataBlockNum
,
0
,
dataBuffer
,
CHUNK_SIZE
);
printf
(
"
\n
%s
\n
"
,
dataBuffer
);
//}
}
//
}
}
return
;
// Fichier affiché, sortie de la fonction
...
...
@@ -508,11 +496,11 @@ int main(int argc, char *argv[]) {
printf
(
"taille=%ld
\n\n
"
,
size
);
printf
(
"Pico ordinateur OK
\n\n
"
);
// char current_cmd[CMD_SIZE + 1]; // +1 pour le caractère nul
erase
(
&
sd
,
0
,
15000
);
current_cmd
[
0
]
=
'\0'
;
// Initialise la chaîne vide
printf
(
"PicoOrdi>"
);
//eraseSD(&sd);
while
(
1
)
{
_delay_ms
(
10
);
...
...
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