Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 245b3e6

Browse filesBrowse files
committed
Update examples/SerialCommandExample/SerialCommandExample.pde
Ethernet commands are processed instead of serial
1 parent 3dbc44b commit 245b3e6
Copy full SHA for 245b3e6

File tree

Expand file treeCollapse file tree

1 file changed

+28
-18
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+28
-18
lines changed
Open diff view settings
Collapse file

‎examples/SerialCommandExample/SerialCommandExample.pde‎

Copy file name to clipboardExpand all lines: examples/SerialCommandExample/SerialCommandExample.pde
+28-18Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,38 @@
1-
// Demo Code for SerialCommand Library
2-
// Steven Cogswell
3-
// May 2011
4-
5-
#include <SerialCommand.h>
1+
#include <SPI.h>
2+
#include <Ethernet.h>
3+
byte mac[] = {
4+
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
5+
IPAddress ip(192,168,1, 177);
6+
IPAddress gateway(192,168,1, 1);
7+
IPAddress subnet(255, 255, 0, 0);
8+
EthernetServer EtherServer(23);
9+
EthernetClient EtherClient;
10+
#include <EtherCommand.h>
611

712
#define arduinoLED 13 // Arduino LED on board
813

9-
SerialCommand sCmd; // The demo SerialCommand object
14+
EtherCommand eCmd; // The demo EtherCommand object
1015

1116
void setup() {
1217
pinMode(arduinoLED, OUTPUT); // Configure the onboard LED for output
1318
digitalWrite(arduinoLED, LOW); // default to LED off
1419

1520
Serial.begin(9600);
16-
17-
// Setup callbacks for SerialCommand commands
18-
sCmd.addCommand("ON", LED_on); // Turns LED on
19-
sCmd.addCommand("OFF", LED_off); // Turns LED off
20-
sCmd.addCommand("HELLO", sayHello); // Echos the string argument back
21-
sCmd.addCommand("P", processCommand); // Converts two arguments to integers and echos them back
22-
sCmd.setDefaultHandler(unrecognized); // Handler for command that isn't matched (says "What?")
21+
Ethernet.begin(mac, ip, gateway, subnet);
22+
EtherServer.begin();
23+
24+
// Setup callbacks for EtherCommand commands
25+
eCmd.addCommand("ON", LED_on); // Turns LED on
26+
eCmd.addCommand("OFF", LED_off); // Turns LED off
27+
eCmd.addCommand("HELLO", sayHello); // Echos the string argument back
28+
eCmd.addCommand("P", processCommand); // Converts two arguments to integers and echos them back
29+
eCmd.setDefaultHandler(unrecognized); // Handler for command that isn't matched (says "What?")
2330
Serial.println("Ready");
2431
}
2532

2633
void loop() {
27-
sCmd.readSerial(); // We don't do much, just process serial commands
34+
EtherClient = EtherServer.available();
35+
eCmd.readSerial(EtherClient); // We don't do much, just process serial commands
2836
}
2937

3038

@@ -40,7 +48,7 @@ void LED_off() {
4048

4149
void sayHello() {
4250
char *arg;
43-
arg = sCmd.next(); // Get the next argument from the SerialCommand object buffer
51+
arg = eCmd.next(); // Get the next argument from the EtherCommand object buffer
4452
if (arg != NULL) { // As long as it existed, take it
4553
Serial.print("Hello ");
4654
Serial.println(arg);
@@ -56,7 +64,7 @@ void processCommand() {
5664
char *arg;
5765

5866
Serial.println("We're in processCommand");
59-
arg = sCmd.next();
67+
arg = eCmd.next();
6068
if (arg != NULL) {
6169
aNumber = atoi(arg); // Converts a char string to an integer
6270
Serial.print("First argument was: ");
@@ -66,7 +74,7 @@ void processCommand() {
6674
Serial.println("No arguments");
6775
}
6876

69-
arg = sCmd.next();
77+
arg = eCmd.next();
7078
if (arg != NULL) {
7179
aNumber = atol(arg);
7280
Serial.print("Second argument was: ");
@@ -80,4 +88,6 @@ void processCommand() {
8088
// This gets set as the default handler, and gets called when no other command matches.
8189
void unrecognized(const char *command) {
8290
Serial.println("What?");
83-
}
91+
EtherClient.println("What?");
92+
93+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.