Distinguish serial index from mask (#21287)
This commit is contained in:
@ -38,7 +38,7 @@
|
||||
#endif
|
||||
|
||||
void host_action(PGM_P const pstr, const bool eol) {
|
||||
PORT_REDIRECT(SERIAL_ALL);
|
||||
PORT_REDIRECT(SerialMask::All);
|
||||
SERIAL_ECHOPGM("//action:");
|
||||
SERIAL_ECHOPGM_P(pstr);
|
||||
if (eol) SERIAL_EOL();
|
||||
@ -78,19 +78,19 @@ void host_action(PGM_P const pstr, const bool eol) {
|
||||
PromptReason host_prompt_reason = PROMPT_NOT_DEFINED;
|
||||
|
||||
void host_action_notify(const char * const message) {
|
||||
PORT_REDIRECT(SERIAL_ALL);
|
||||
PORT_REDIRECT(SerialMask::All);
|
||||
host_action(PSTR("notification "), false);
|
||||
SERIAL_ECHOLN(message);
|
||||
}
|
||||
|
||||
void host_action_notify_P(PGM_P const message) {
|
||||
PORT_REDIRECT(SERIAL_ALL);
|
||||
PORT_REDIRECT(SerialMask::All);
|
||||
host_action(PSTR("notification "), false);
|
||||
SERIAL_ECHOLNPGM_P(message);
|
||||
}
|
||||
|
||||
void host_action_prompt(PGM_P const ptype, const bool eol=true) {
|
||||
PORT_REDIRECT(SERIAL_ALL);
|
||||
PORT_REDIRECT(SerialMask::All);
|
||||
host_action(PSTR("prompt_"), false);
|
||||
SERIAL_ECHOPGM_P(ptype);
|
||||
if (eol) SERIAL_EOL();
|
||||
@ -98,7 +98,7 @@ void host_action(PGM_P const pstr, const bool eol) {
|
||||
|
||||
void host_action_prompt_plus(PGM_P const ptype, PGM_P const pstr, const char extra_char='\0') {
|
||||
host_action_prompt(ptype, false);
|
||||
PORT_REDIRECT(SERIAL_ALL);
|
||||
PORT_REDIRECT(SerialMask::All);
|
||||
SERIAL_CHAR(' ');
|
||||
SERIAL_ECHOPGM_P(pstr);
|
||||
if (extra_char != '\0') SERIAL_CHAR(extra_char);
|
||||
|
@ -132,17 +132,17 @@ struct MeatpackSerial : public SerialBase <MeatpackSerial < SerialT >> {
|
||||
uint8_t charCount;
|
||||
uint8_t readIndex;
|
||||
|
||||
NO_INLINE size_t write(uint8_t c) { return out.write(c); }
|
||||
void flush() { out.flush(); }
|
||||
void begin(long br) { out.begin(br); readIndex = 0; }
|
||||
void end() { out.end(); }
|
||||
NO_INLINE size_t write(uint8_t c) { return out.write(c); }
|
||||
void flush() { out.flush(); }
|
||||
void begin(long br) { out.begin(br); readIndex = 0; }
|
||||
void end() { out.end(); }
|
||||
|
||||
void msgDone() { out.msgDone(); }
|
||||
void msgDone() { out.msgDone(); }
|
||||
// Existing instances implement Arduino's operator bool, so use that if it's available
|
||||
bool connected() { return Private::HasMember_connected<SerialT>::value ? CALL_IF_EXISTS(bool, &out, connected) : (bool)out; }
|
||||
void flushTX() { CALL_IF_EXISTS(void, &out, flushTX); }
|
||||
bool connected() { return Private::HasMember_connected<SerialT>::value ? CALL_IF_EXISTS(bool, &out, connected) : (bool)out; }
|
||||
void flushTX() { CALL_IF_EXISTS(void, &out, flushTX); }
|
||||
|
||||
int available(uint8_t index) {
|
||||
int available(serial_index_t index) {
|
||||
// There is a potential issue here with multiserial, since it'll return its decoded buffer whatever the serial index here.
|
||||
// So, instead of doing MeatpackSerial<MultiSerial<...>> we should do MultiSerial<MeatpackSerial<...>, MeatpackSerial<...>>
|
||||
// TODO, let's fix this later on
|
||||
@ -160,7 +160,7 @@ struct MeatpackSerial : public SerialBase <MeatpackSerial < SerialT >> {
|
||||
return charCount;
|
||||
}
|
||||
|
||||
int readImpl(const uint8_t index) {
|
||||
int readImpl(const serial_index_t index) {
|
||||
// Not enough char to make progress?
|
||||
if (charCount == 0 && available(index) == 0) return -1;
|
||||
|
||||
@ -168,9 +168,9 @@ struct MeatpackSerial : public SerialBase <MeatpackSerial < SerialT >> {
|
||||
return serialBuffer[readIndex++];
|
||||
}
|
||||
|
||||
int read(uint8_t index) { return readImpl(index); }
|
||||
int available() { return available(0); }
|
||||
int read() { return readImpl(0); }
|
||||
int read(serial_index_t index) { return readImpl(index); }
|
||||
int available() { return available(0); }
|
||||
int read() { return readImpl(0); }
|
||||
|
||||
MeatpackSerial(const bool e, SerialT & out) : BaseClassT(e), out(out) {}
|
||||
};
|
||||
|
Reference in New Issue
Block a user