Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
LibLaserCut
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Elektronikföreningen Admittansen
LibLaserCut
Commits
7fe600e5
Commit
7fe600e5
authored
9 years ago
by
Thomas Oster
Browse files
Options
Downloads
Patches
Plain Diff
Fix: HTTP Upload, Smoothie specific identification line.
parent
5eafb648
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/com/t_oster/liblasercut/drivers/GenericGcodeDriver.java
+48
-17
48 additions, 17 deletions
src/com/t_oster/liblasercut/drivers/GenericGcodeDriver.java
src/com/t_oster/liblasercut/drivers/SmoothieBoard.java
+26
-0
26 additions, 0 deletions
src/com/t_oster/liblasercut/drivers/SmoothieBoard.java
with
74 additions
and
17 deletions
src/com/t_oster/liblasercut/drivers/GenericGcodeDriver.java
+
48
−
17
View file @
7fe600e5
...
...
@@ -315,12 +315,10 @@ public class GenericGcodeDriver extends LaserCutter {
out
.
flush
();
if
(
isWaitForOKafterEachLine
())
{
String
line
=
in
.
readLine
();
//TODO: Remove
System
.
out
.
println
(
"< "
+
line
);
String
line
=
waitForLine
();
if
(!
"ok"
.
equals
(
line
))
{
throw
new
IOException
(
"Lasercutter did not respond 'ok'"
);
throw
new
IOException
(
"Lasercutter did not respond 'ok'
, but '"
+
line
+
"'instead.
"
);
}
}
}
...
...
@@ -334,6 +332,37 @@ public class GenericGcodeDriver extends LaserCutter {
{
throw
new
IOException
(
"Error during POST Request"
);
}
System
.
out
.
println
(
"Response: "
+
response
.
toString
());
//TODO: Remove
}
protected
String
waitForLine
()
throws
IOException
{
String
line
=
""
;
while
(
""
.
equals
(
line
))
{
//skip empty lines
line
=
in
.
readLine
();
}
System
.
out
.
println
(
"< "
+
line
);
//TODO: remove
return
line
;
}
/**
* Waits for the Identification line and returns null if it's allright
* Otherwise it returns the wrong line
* @return
* @throws IOException
*/
protected
String
waitForIdentificationLine
()
throws
IOException
{
if
(
getIdentificationLine
()
!=
null
&&
getIdentificationLine
().
length
()
>
0
)
{
String
line
=
waitForLine
();
if
(!
getIdentificationLine
().
equals
(
line
))
{
return
line
;
}
}
return
null
;
}
protected
String
connect_serial
(
CommPortIdentifier
i
,
ProgressListener
pl
)
throws
PortInUseException
,
IOException
,
UnsupportedCommOperationException
...
...
@@ -351,17 +380,12 @@ public class GenericGcodeDriver extends LaserCutter {
}
out
=
new
PrintStream
(
port
.
getOutputStream
(),
true
,
"US-ASCII"
);
in
=
new
BufferedReader
(
new
InputStreamReader
(
port
.
getInputStream
()));
if
(
get
IdentificationLine
()
!=
null
&&
getIdentificationLine
().
length
()
>
0
)
if
(
waitFor
IdentificationLine
()
!=
null
)
{
String
line
=
in
.
readLine
();
if
(!
getIdentificationLine
().
equals
(
line
))
{
in
.
close
();
out
.
close
();
port
.
close
();
return
(
"Does not seem to be a smoothieboard on "
+
i
.
getName
());
}
in
.
close
();
out
.
close
();
port
.
close
();
return
"Does not seem to be a "
+
getModelName
()+
" on "
+
i
.
getName
();
}
portIdentifier
=
i
;
return
null
;
...
...
@@ -397,6 +421,13 @@ public class GenericGcodeDriver extends LaserCutter {
socket
.
connect
(
new
InetSocketAddress
(
getHost
(),
23
),
1000
);
in
=
new
BufferedReader
(
new
InputStreamReader
(
socket
.
getInputStream
()));
out
=
new
PrintStream
(
socket
.
getOutputStream
(),
true
,
"US-ASCII"
);
String
line
=
waitForIdentificationLine
();
if
(
line
!=
null
)
{
in
.
close
();
out
.
close
();
throw
new
IOException
(
"Wrong identification Line: "
+
line
+
"\n instead of "
+
getIdentificationLine
());
}
}
else
if
(
getComport
()
!=
null
&&
!
getComport
().
equals
(
""
))
{
...
...
@@ -444,12 +475,12 @@ public class GenericGcodeDriver extends LaserCutter {
}
}
protected
void
disconnect
()
throws
IOException
,
URISyntaxException
protected
void
disconnect
(
String
jobname
)
throws
IOException
,
URISyntaxException
{
if
(
outputBuffer
!=
null
)
{
out
.
close
();
http_upload
(
new
URI
(
getHttpUploadUrl
()),
outputBuffer
.
toString
(
"UTF-8"
),
"VisiCut.gcode"
);
http_upload
(
new
URI
(
getHttpUploadUrl
()),
outputBuffer
.
toString
(
"UTF-8"
),
jobname
);
}
else
{
...
...
@@ -505,7 +536,7 @@ public class GenericGcodeDriver extends LaserCutter {
pl
.
progressChanged
(
this
,
20
+
(
int
)
(
i
*(
double
)
60
/
max
));
}
writeShutdownCode
();
disconnect
();
disconnect
(
job
.
getName
()+
".gcode"
);
pl
.
taskChanged
(
this
,
"sent."
);
pl
.
progressChanged
(
this
,
100
);
}
...
...
This diff is collapsed.
Click to expand it.
src/com/t_oster/liblasercut/drivers/SmoothieBoard.java
+
26
−
0
View file @
7fe600e5
...
...
@@ -18,6 +18,7 @@
**/
package
com.t_oster.liblasercut.drivers
;
import
java.io.IOException
;
import
java.util.Arrays
;
import
java.util.LinkedList
;
import
java.util.List
;
...
...
@@ -37,7 +38,32 @@ public class SmoothieBoard extends GenericGcodeDriver {
setBaudRate
(
115200
);
setLineend
(
"CRLF"
);
}
@Override
public
String
getIdentificationLine
()
{
if
(
getHost
()
==
null
||
""
.
equals
(
getHost
()))
{
return
"Smoothie"
;
}
else
{
return
"Smoothie command shell"
;
}
}
@Override
protected
String
waitForLine
()
throws
IOException
{
String
line
=
super
.
waitForLine
();
//The telnet interface for smoothie prepends lines with '> '
if
(
getHost
()
!=
null
&&
!
""
.
equals
(
getHost
())
&&
line
.
startsWith
(
"> "
))
{
return
line
.
substring
(
2
);
}
return
line
;
}
@Override
public
String
[]
getPropertyKeys
()
{
...
...
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