Add SerialUART::setPollingMode() #473

Merged
earlephilhower merged 4 commits from pollme into master 2022-02-10 23:22:27 +03:00
earlephilhower commented 2022-02-08 23:38:19 +03:00 (Migrated from github.com)

Fixes #472

Instead of using interrupts, explicitly call the IRQ handler dueing Serial
read/peek/available calls.

Fixes #472 Instead of using interrupts, explicitly call the IRQ handler dueing Serial read/peek/available calls.
earlephilhower commented 2022-02-08 23:38:40 +03:00 (Migrated from github.com)

@SirSydom would appreciate you giving this a whirl and reporting back, please.

@SirSydom would appreciate you giving this a whirl and reporting back, please.
earlephilhower commented 2022-02-10 23:22:03 +03:00 (Migrated from github.com)

Loopback testing with a simple script shows polled mode working properly and immediately returning bytes as receives, while IRQ-based does it in chunks of 4 bytes until the final set.

Loopback testing with a simple script shows polled mode working properly and immediately returning bytes as receives, while IRQ-based does it in chunks of 4 bytes until the final set.
Ing-Dom commented 2022-02-10 23:47:09 +03:00 (Migrated from github.com)

This was at the right time :)
I told you, that #471 fixed my problem with the knx stack, well, that was true for an old version of this stack.
With the current master (of the knx branch) it is screwed again, BUT, when I activate polling it works. Great job.

One question:

do you always get 4byte chunks? also when communication is paused? that would mean somehow, the "32bit times IRQ" does not work properly.

This was at the right time :) I told you, that #471 fixed my problem with the knx stack, well, that was true for an old version of this stack. With the current master (of the knx branch) it is screwed again, BUT, when I activate polling it works. Great job. One question: do you always get 4byte chunks? also when communication is paused? that would mean somehow, the "32bit times IRQ" does not work properly.
earlephilhower commented 2022-02-10 23:53:54 +03:00 (Migrated from github.com)

No, the last bit will be at 32-bit times out. I connect up pins GP0 tp GP1 (i.e Serial1 loopback) and run the following script:

void setup() {
  Serial.begin(115200);
  Serial1.setPollingMode(false);
  Serial1.begin(110);
  delay(5000);
}

void loop() {
  Serial1.printf("hello\n");
  while (Serial1.available() < 6) {
    Serial.printf("Avail: %d\n", Serial1.available());
  }
  Serial.printf("read: ");
  while (Serial1.available()) {
    Serial.printf("%c", Serial1.read());
  }
  Serial.printf("\n");
  delay(1000);
}

For polled you see Avail go 0..1..2..3..4..5..print
For IRQ you see Avail go 0...4...print

IF the 32-bit timeout did not work, then it would never advance because Serial1 only sends out 6 bytes per loop.

No, the last bit will be at 32-bit times out. I connect up pins GP0 tp GP1 (i.e Serial1 loopback) and run the following script: ```` void setup() { Serial.begin(115200); Serial1.setPollingMode(false); Serial1.begin(110); delay(5000); } void loop() { Serial1.printf("hello\n"); while (Serial1.available() < 6) { Serial.printf("Avail: %d\n", Serial1.available()); } Serial.printf("read: "); while (Serial1.available()) { Serial.printf("%c", Serial1.read()); } Serial.printf("\n"); delay(1000); } ```` For polled you see Avail go 0..1..2..3..4..5..print For IRQ you see Avail go 0...4...print IF the 32-bit timeout did not work, then it would never advance because Serial1 only sends out 6 bytes per loop.
Sign in to join this conversation.