Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
marlin-anet-a8
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
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
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
Jonas Leder
marlin-anet-a8
Commits
869cee74
Commit
869cee74
authored
Nov 19, 2011
by
Bernhard Kubicek
Browse files
Options
Downloads
Patches
Plain Diff
host-based sd card printing seems now to work with folders
parent
70abca19
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
Marlin/cardreader.pde
+72
-29
72 additions, 29 deletions
Marlin/cardreader.pde
with
72 additions
and
29 deletions
Marlin/cardreader.pde
+
72
−
29
View file @
869cee74
...
@@ -64,7 +64,7 @@ void CardReader::lsDive(char *prepend,SdFile parent)
...
@@ -64,7 +64,7 @@ void CardReader::lsDive(char *prepend,SdFile parent)
strcat
(
path
,
lfilename
);
strcat
(
path
,
lfilename
);
strcat
(
path
,
"/"
);
strcat
(
path
,
"/"
);
Serial
.
print
(
path
);
//
Serial.print(path);
SdFile
dir
;
SdFile
dir
;
if
(
!
dir
.
open
(
parent
,
lfilename
,
O_READ
))
if
(
!
dir
.
open
(
parent
,
lfilename
,
O_READ
))
...
@@ -81,6 +81,8 @@ void CardReader::lsDive(char *prepend,SdFile parent)
...
@@ -81,6 +81,8 @@ void CardReader::lsDive(char *prepend,SdFile parent)
}
}
else
{
if
(
p
.
name
[
0
]
==
DIR_NAME_FREE
)
break
;
if
(
p
.
name
[
0
]
==
DIR_NAME_FREE
)
break
;
if
(
p
.
name
[
0
]
==
DIR_NAME_DELETED
||
p
.
name
[
0
]
==
'.'
||
p
.
name
[
0
]
==
'_'
)
continue
;
if
(
p
.
name
[
0
]
==
DIR_NAME_DELETED
||
p
.
name
[
0
]
==
'.'
||
p
.
name
[
0
]
==
'_'
)
continue
;
if
(
!
DIR_IS_FILE_OR_SUBDIR
(
&
p
))
continue
;
if
(
!
DIR_IS_FILE_OR_SUBDIR
(
&
p
))
continue
;
...
@@ -108,6 +110,7 @@ void CardReader::lsDive(char *prepend,SdFile parent)
...
@@ -108,6 +110,7 @@ void CardReader::lsDive(char *prepend,SdFile parent)
}
}
}
}
}
}
}
void
CardReader
::
ls
()
void
CardReader
::
ls
()
{
{
...
@@ -180,17 +183,57 @@ void CardReader::openFile(char* name,bool read)
...
@@ -180,17 +183,57 @@ void CardReader::openFile(char* name,bool read)
{
{
if
(
!
cardOK
)
if
(
!
cardOK
)
return
;
return
;
file
.
close
();
file
.
close
();
sdprinting
=
false
;
sdprinting
=
false
;
SdFile
myDir
;
curDir
=&
root
;
char
*
fname
=
name
;
char
*
dirname_start
,
*
dirname_end
;
dirname_start
=
strchr
(
name
,
'/'
)
+
1
;
while
(
dirname_start
!=
NULL
)
{
dirname_end
=
strchr
(
dirname_start
,
'/'
);
//SERIAL_ECHO("start:");SERIAL_ECHOLN((int)(dirname_start-name));
//SERIAL_ECHO("end :");SERIAL_ECHOLN((int)(dirname_end-name));
if
(
dirname_end
!=
NULL
&&
dirname_end
>
dirname_start
)
{
char
subdirname
[
13
];
strncpy
(
subdirname
,
dirname_start
,
dirname_end
-
dirname_start
);
subdirname
[
dirname_end
-
dirname_start
]
=
0
;
SERIAL_ECHOLN
(
subdirname
);
if
(
!
myDir
.
open
(
curDir
,
subdirname
,
O_READ
))
{
SERIAL_PROTOCOLPGM
(
"open failed, File: "
);
SERIAL_PROTOCOL
(
subdirname
);
SERIAL_PROTOCOLLNPGM
(
"."
);
return
;
}
else
SERIAL_ECHOLN
(
"dive ok"
);
curDir
=&
myDir
;
dirname_start
=
dirname_end
+
1
;
}
else
// the reminder after all /fsa/fdsa/ is the filename
{
fname
=
dirname_start
;
//SERIAL_ECHOLN("remaider");
//SERIAL_ECHOLN(fname);
break
;
}
}
if
(
read
)
if
(
read
)
{
{
if
(
file
.
open
(
&
root
,
name
,
O_READ
))
if
(
file
.
open
(
curDir
,
f
name
,
O_READ
))
{
{
filesize
=
file
.
fileSize
();
filesize
=
file
.
fileSize
();
SERIAL_PROTOCOLPGM
(
"File opened:"
);
SERIAL_PROTOCOLPGM
(
"File opened:"
);
SERIAL_PROTOCOL
(
name
);
SERIAL_PROTOCOL
(
f
name
);
SERIAL_PROTOCOLPGM
(
" Size:"
);
SERIAL_PROTOCOLPGM
(
" Size:"
);
SERIAL_PROTOCOLLN
(
filesize
);
SERIAL_PROTOCOLLN
(
filesize
);
sdpos
=
0
;
sdpos
=
0
;
...
@@ -204,10 +247,10 @@ void CardReader::openFile(char* name,bool read)
...
@@ -204,10 +247,10 @@ void CardReader::openFile(char* name,bool read)
}
}
else
else
{
//write
{
//write
if
(
!
file
.
open
(
&
root
,
name
,
O_CREAT
|
O_APPEND
|
O_WRITE
|
O_TRUNC
))
if
(
!
file
.
open
(
curDir
,
f
name
,
O_CREAT
|
O_APPEND
|
O_WRITE
|
O_TRUNC
))
{
{
SERIAL_PROTOCOLPGM
(
"open failed, File: "
);
SERIAL_PROTOCOLPGM
(
"open failed, File: "
);
SERIAL_PROTOCOL
(
name
);
SERIAL_PROTOCOL
(
f
name
);
SERIAL_PROTOCOLLNPGM
(
"."
);
SERIAL_PROTOCOLLNPGM
(
"."
);
}
}
else
else
...
...
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