Test Command parsing send through Serial
parent
c076fce76d
commit
bb59163d11
|
@ -19,3 +19,6 @@
|
|||
*.exe
|
||||
*.out
|
||||
*.app
|
||||
/Release
|
||||
/spec.d
|
||||
/arduino
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
#include "Command.h"
|
||||
|
||||
const char axisCodes[3] = { 'X', 'Y', 'Z' };
|
||||
const char feedRate = 'F';
|
||||
const char extrusionAmount = 'E';
|
||||
|
||||
Command::Command(String commandString) {
|
||||
char charBuf[commandString.length()];
|
||||
char* charPointer;
|
||||
commandString.toCharArray(charBuf, commandString.length());
|
||||
|
||||
charPointer = strtok(charBuf," ");
|
||||
|
||||
if(charPointer[0] == 'G') {
|
||||
Serial.println("G command found:" + *charPointer);
|
||||
return;
|
||||
}
|
||||
while(charPointer != NULL) {
|
||||
Serial.println(charPointer);
|
||||
charPointer = strtok(NULL, " ");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
#include "Arduino.h"
|
||||
#include "string.h"
|
||||
enum CommandCodeEnum
|
||||
{
|
||||
G00 = 0,
|
||||
G01,
|
||||
G02,
|
||||
G03,
|
||||
G04
|
||||
};
|
||||
|
||||
#define NULL 0
|
||||
|
||||
class Command {
|
||||
CommandCodeEnum codeEnum;
|
||||
public:
|
||||
Command(String);
|
||||
};
|
|
@ -1,2 +1,3 @@
|
|||
farmbot_arduino_controller
|
||||
farmbot-arduino-controller
|
||||
==========================
|
||||
Created with eclipseArduino V2
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
// Do not remove the include below
|
||||
#include "farmbot_arduino_controller.h"
|
||||
|
||||
static char commandEndChar = 0x0A;
|
||||
|
||||
//The setup function is called once at startup of the sketch
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
}
|
||||
|
||||
// The loop function is called in an endless loop
|
||||
void loop() {
|
||||
String commandString = Serial.readStringUntil(commandEndChar);
|
||||
if (commandString && commandString.length() > 0) {
|
||||
Serial.print("Board 1 received : ");
|
||||
Command* command = new Command(commandString);
|
||||
}
|
||||
delay(100);
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
// Only modify this file to include
|
||||
// - function definitions (prototypes)
|
||||
// - include files
|
||||
// - extern variable definitions
|
||||
// In the appropriate section
|
||||
|
||||
#ifndef _farmbot_arduino_controller_H_
|
||||
#define _farmbot_arduino_controller_H_
|
||||
#include "Arduino.h"
|
||||
//add your includes for the project farmbot_arduino_controller here
|
||||
#include "Command.h"
|
||||
|
||||
//end of add your includes here
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
void loop();
|
||||
void setup();
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
//add your function definitions for the project farmbot_arduino_controller here
|
||||
|
||||
|
||||
|
||||
|
||||
//Do not add code below this line
|
||||
#endif /* _farmbot_arduino_controller_H_ */
|
Loading…
Reference in New Issue