|
RSeries astromech firmware
|
|
Go to the documentation of this file.
38 int len = strlen(cmd);
39 while (len > 0 && (isspace(cmd[len-1]) || cmd[len-1] ==
'\n'))
43 for (
CommandEvent* evt = *tail(); evt != NULL; evt = evt->fNext)
45 evt->handleCommand(cmd);
58 for (
CommandEvent* evt = *tail(); evt != NULL; evt = evt->fNext)
60 evt->handleCommand(cmd);
71 const char* cmd =
reinterpret_cast<const char *
>(pcmd);
72 const char* cmd_end = cmd + strlen_P(cmd);
76 const char* pch = cmd;
79 if (((ch = pgm_read_byte(pch++)) == 0) || ch ==
'\n')
81 size_t len = min(
size_t(pch - cmd - 1),
sizeof(buffer)-1);
82 strncpy_P(buffer, cmd, len);
89 if (isspace(ch) || ch ==
'\n')
96 for (
CommandEvent* evt = *tail(); evt != NULL; evt = evt->fNext)
98 evt->handleCommand(buffer);
103 while (cmd < cmd_end && ch != 0);
149 if (fStream->available())
151 int ch = fStream->read();
152 if (ch ==
'\r' || ch ==
'\n' || ch == 0)
154 fBuffer[fPos] =
'\0';
156 if (*fBuffer !=
'\0')
163 fBuffer[fPos++] = ch;
167 fBuffer[fPos-1] =
'\0';
169 if (*fBuffer !=
'\0')
179 char fBuffer[BUFFER_SIZE];
static void process(char *cmd)
Calls handleCommand() for each created CommandEvent subclass.
Definition: CommandEvent.h:33
Base class for all command enabled devices. CommandEvent::handleCommand() is called for each device e...
Definition: CommandEvent.h:17
Base class for all animated devices. AnimatedEvent::animate() is called for each device once through ...
Definition: AnimatedEvent.h:18
CommandEventSerial(Stream *stream)
Definition: CommandEvent.h:141
virtual void animate()
Subclasses must implement this function to run through a single frame of animation/activity.
Definition: CommandEvent.h:147
static void process(const char *cmd)
Calls handleCommand() for each created CommandEvent subclass.
Definition: CommandEvent.h:54
Definition: CommandEvent.h:132
static void process(PROGMEMString pcmd)
Calls handleCommand() for each created CommandEvent subclass.
Definition: CommandEvent.h:68
virtual void handleCommand(const char *cmd)=0
Subclasses should implement this function to process commands specific to their device.
CommandEventSerial(HardwareSerial &serial)
Definition: CommandEvent.h:135
const typedef __FlashStringHelper * PROGMEMString
Definition: ReelTwo.h:235
CommandEvent()
Default Constructor.
Definition: CommandEvent.h:24
virtual void handleCommand(String cmd)
Subclasses should implement this function to process commands specific to their device.
Definition: CommandEvent.h:117
#define SizeOfArray(arr)
Definition: ReelTwo.h:213