These are chat archives for esp8266/Arduino

11th
Jun 2015
Russ Mathis
@RussMathis
Jun 11 2015 12:48
@Makuna, thanks! good job on the RTC support. Still testing and will keep you aprised of any issues or success! :)
Ivan Grokhotkov
@igrr
Jun 11 2015 15:18
finally pushed an update to the staging release
regarding ESP.reset(), yes, something's crashing after reset. I think we need to disable some interrupts before going into reset, because the CPU reset doesn't seem to clear the enable flags.
i didn't have time to investigate it though
Michael Miller
@Makuna
Jun 11 2015 15:51
@igrr Gettting some warnings, but so far no problems.
Ivan Grokhotkov
@igrr
Jun 11 2015 15:52
i think @Links2004 went a little overboard enabling -pedantic, i also get lots of warnings from some Arduino libraries
Michael Miller
@Makuna
Jun 11 2015 16:13
Do you know if the log wdt reset got fixed?
Ivan Grokhotkov
@igrr
Jun 11 2015 16:42
no I didn't fix it yet...
if you have some time, could you try replacing libhal.a with an open source version?
I.e. the one from nodemcu
Ivan Grokhotkov
@igrr
Jun 11 2015 16:51
OTOH probably not worth trying
doesn't have any FP-related stuff inside
Russ Mathis
@RussMathis
Jun 11 2015 17:13
@Links2004, can your arduinoWebSockets be used in AP mode?
@Anybody, can ESP8266WiFiMulti be used in Access Point mode?
Me No Dev
@me-no-dev
Jun 11 2015 17:19
yes on the first question
and have no clue what to say on the second one, since WiFi multi is a STATION feature and has nothing to do with AP mode
Russ Mathis
@RussMathis
Jun 11 2015 17:20
@me-no-dev , researching his Example that uses both for STATION mode. Thx!
micropet
@micropet
Jun 11 2015 17:53
works for me with analogWrite - no reboot :smile:
Ivan Grokhotkov
@igrr
Jun 11 2015 18:14
cool, I didn't test that...
if someone else can verify we can get rid of 1.0 branch
Russ Mathis
@RussMathis
Jun 11 2015 18:22
@me-no-dev , keep getting WDT when using the WebSocketServer & WebSocketClient. I made simple changes to use access point mode and send message from the client every 5 seconds.
Were there any fixes you made to get it to work properly?
Me No Dev
@me-no-dev
Jun 11 2015 18:23
nope
Russ Mathis
@RussMathis
Jun 11 2015 18:24
Did you send text messages, or just binary?
Me No Dev
@me-no-dev
Jun 11 2015 18:24
text only
Russ Mathis
@RussMathis
Jun 11 2015 18:24
and you used sendTXT(...) ?
Me No Dev
@me-no-dev
Jun 11 2015 18:25
WebSocketsServer webSocket = WebSocketsServer(81);

void webSocketSend(uint8_t num, String msg){
  webSocket.sendTXT(num, msg.c_str(), msg.length());
}

void webSocketBroadcast(String msg){
  webSocket.broadcastTXT(msg.c_str(), msg.length());
}

void webSocketSendError(uint8_t num, String msg){
  webSocketSend(num, "{\"error\":1,\"message\":\""+msg+"\"}");
}

void webSocketSendSuccess(uint8_t num){
  webSocketSend(num, "{\"error\":0,\"message\":\"control\",\"turn\":"+String(rcValue[0])+",\"throttle\":"+String(rcValue[1])+"}");
}

void webSocketBroadcastMove(){
  webSocketBroadcast("{\"error\":0,\"message\":\"move\",\"direction\":"+String(roverDirection)+",\"left\":"+String(roverMotors[0])+",\"right\":"+String(roverMotors[1])+",\"turn\":"+String(rcValue[0])+",\"throttle\":"+String(rcValue[1])+"}");
}

void webSocketEvent(uint8_t num, uint8_t type, uint8_t * data, size_t len) {
  if(type == WStype_TEXT){
    String payload = String((const char *)data);
    int pos = payload.indexOf("{\"throttle\"");
    if(pos != 0){
      webSocketSendError(num, "missing throttle");
      return;
    }
    payload = payload.substring(11);

    pos = payload.indexOf("\"turn\"");
    if(pos < 0){
      webSocketSendError(num, "missing turn");
      return;
    }
    pos = payload.indexOf(':');
    if(pos < 0){
      webSocketSendError(num, "missing ':'");
      return;
    }
    payload = payload.substring(pos+1);
    pos = payload.indexOf(',');
    if(pos < 0){
      webSocketSendError(num, "missing ','");
      return;
    }
    rcValue[1] = payload.substring(0, pos).toInt();
    payload = payload.substring(pos+1);
    pos = payload.indexOf(':');
    if(pos < 0){
      webSocketSendError(num, "missing ':'");
      return;
    }
    payload = payload.substring(pos+1);
    pos = payload.indexOf('}');
    if(pos < 0){
      webSocketSendError(num, "missing '}'");
      return;
    }
    rcValue[0] = payload.substring(0, pos).toInt();
    rcLastPacket = millis();
    rcUpdated = true;
    webSocketSendSuccess(num);
  }
}

void setup(){
  webSocket.begin();
  webSocket.onEvent(webSocketEvent);
}

void loop() {
  webSocket.loop();
}
Russ Mathis
@RussMathis
Jun 11 2015 18:27
Thx!
Russ Mathis
@RussMathis
Jun 11 2015 18:44
Maybe my version is broke. When ever I try to send messages either from the server or client the watch dog time kicks in and kills the ESP.
Russ Mathis
@RussMathis
Jun 11 2015 18:52
keep getting:
wdt reset
load 0x4010f800, len 368, room 16
tail 0
chksum 0xf1
csum 0xf1
On both the server and client! hmmm....
Me No Dev
@me-no-dev
Jun 11 2015 18:53
you probably have a totally different problem
Russ Mathis
@RussMathis
Jun 11 2015 18:54
That's what I'm thinking too..
Michael Miller
@Makuna
Jun 11 2015 19:40

I have hit an interesting problem, the first pulse in a bit bang (neo pixel library) can vary in length even though the others after it are consistent. If I put a single pin high, pin low just before my pulse timing code, my first pulse is now fine and this simple pin toggle varies in width between 300ns and 4us.

    digitalWrite(pin, HIGH);
    digitalWrite(pin, LOW);

And all of this is inside noInterrupts() / interrupts() sandwich.

Me No Dev
@me-no-dev
Jun 11 2015 19:47
what if you put twice low or high, thus not generating a pulse?
but is an interesting issue
and what if you directly write to the registers?
Michael Miller
@Makuna
Jun 11 2015 19:49
directly writing to the registers does the same thing
Me No Dev
@me-no-dev
Jun 11 2015 19:50
is it every first write? like if you delay and do again, will it have the same wrong time?
Michael Miller
@Makuna
Jun 11 2015 19:53
it is not consistent, but it is about 50% of the time the pulse width is modified. The strange this is that if I modify other code (no related to this) it may not repro at all. Modify the code again, and it repros. While it acts like the compiler is modifying the code, the actual obj file that contains the bit bag was not recompiled between the changes.
Its like the instruction pipelining is doing something wrong
Ivan Grokhotkov
@igrr
Jun 11 2015 20:09
have you tried placing the function into RAM?
perhaps this is code caching which takes some time
but I would like to take a look at the generated code
placing digitalWrite into RAM may also help
Michael Miller
@Makuna
Jun 11 2015 20:41
interesting enough, writing pin low once before my bit bang loop doesn't help, writing twice in row before bit bang loop (suggested by me-no-dev) did!?!?
@igrr I just put out a pull for 1.0 (should be both branches) for some corrections that got lost in a previous merge for changes I made for correct sync usage. esp8266/Arduino#416
@igrr I am using gpio write instead of digitalwrite, both show the same problem.
uint32_t pinRegister = _BV(pin);
GPIO_REG_WRITE(GPIO_OUT_W1TC_ADDRESS, pinRegister);
@igrr __digitalWrite is already marked for ram (ICACHE_RAM_ATTR)
Michael Miller
@Makuna
Jun 11 2015 20:48
@igrr marking the bitbang code for ram didn't help (ICACHE_RAM_ATTR)
Could it be that the IO Pin registers is a "peripheral" and that the feature itself has some sort of "caching" or latency?
Ivan Grokhotkov
@igrr
Jun 11 2015 20:50
yes I think I read somewhere that GPIO is clocked at around 26 MHz
but this doesn't explain why you get variation of the first pulse length only
Michael Miller
@Makuna
Jun 11 2015 23:26
exactly, further, changing code elsewhere should not effect it, but it seems too. I keep thinking it is some sort of instruction pipeline code generation problem.
its easy to repro for most, get my neopixel library (Makuna\NeoPixelBus), open the example for NeoPixelTest, make sure the pin is a valid pin, no need for actual LEDs if you connect a logic analyzer, just sample once in a while to capture it setting four pixels off or four pixels to RGBW.