FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Netduino-gcode/StepperBasic/GCodeServer.cs at master · dsuarezv/Netduino-gcode · GitHub
dsuarezv
Netduino-gcode
Repository navigation
Code
Issues
1
(1)
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
Netduino-gcode
/
StepperBasic
/
GCodeServer.cs
Copy path
More file actions
More file actions
Latest commit
History
History
History
68 lines (48 loc) · 1.54 KB
Breadcrumbs
Netduino-gcode
/
StepperBasic
/
GCodeServer.cs
Copy path
File metadata and controls
68 lines (48 loc) · 1.54 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
using
System
;
using
Microsoft
.
SPOT
;
using
Microsoft
.
SPOT
.
Hardware
;
using
SecretLabs
.
NETMF
.
Hardware
;
using
SecretLabs
.
NETMF
.
Hardware
.
Netduino
;
using
System
.
Net
.
Sockets
;
using
NetduinoSocketServer
;
using
gcodeparser
;
namespace
StepperBasic
{
public
class
GCodeServer
:
LineServer
{
// __ Internals _______________________________________________________
static
CncDevice
mDevice
=
new
CncDevice
(
)
;
// __ Port setup ______________________________________________________
static
OutputPort
LED
=
new
OutputPort
(
Pins
.
ONBOARD_LED
,
true
)
;
// __ Server impl _____________________________________________________
public
static
void
Main
(
)
{
DeviceFactory
.
RegisterDevice
(
mDevice
)
;
new
GCodeServer
(
)
.
Listen
(
82
)
;
}
protected
override
void
OnConnect
(
Socket
socket
)
{
SendString
(
"Dave's CNC interface 0.70 with G-Code
\r
\n
"
,
socket
)
;
}
protected
override
bool
ProcessLine
(
string
line
,
Socket
socket
)
{
string
l
=
line
.
ToLower
(
)
.
Trim
(
)
;
if
(
l
==
"exit"
)
return
false
;
LED
.
Write
(
false
)
;
try
{
GCodeParser
.
ParseLine
(
l
)
;
SendString
(
"+
\r
\n
"
,
socket
)
;
}
catch
(
Exception
ex
)
{
SendString
(
"ERROR: "
+
ex
.
Message
+
"
\r
\n
"
,
socket
)
;
}
finally
{
LED
.
Write
(
true
)
;
}
return
true
;
}
}
}
Back
|
FazBrowse Home
|
New Git URL