• Is it possible to change the baudrate on ESP8266 running espruino ?

    I am trying to wifi enable some old RS232 equipment.
    This equipment need a baudrate of 19200.
    I tried :
    Serial1.println("testing 123");
    I prints the "testing 123" on the connected terminal, but is still uses 115200, as the firmware setup.

  • Good question. I have not looked into the serial driver myself. Given that you currently need uart0 to talk to the espruino interpreter, which serial port are you hoping to use? Uart1 only has TX, no RX. (And perhaps esp-link is a better match for what you need?)

  • @tve it'd need to implement jshUSARTSetup - I don't know if that's actually done right now?

    You can move the console out of the way with something like LoopbackA.setConsole() and then you can use Serial1 for whetever you want...

  • Thanks tve and Gordon

    I still need some help, if you have time I would appreciate that.

    I have saved this script on ESP8266.

    E.on('init', function() {
    Serial1.println("my command");

    My intension is to use the RX and TX to communicate with an instrument instead of the consol.

    I expected to get "my command" sent out on the TX pin with a baud of 19200.

    But i get this continuous repeated on baud 115200:

    -> LoopbackA
    ets Jan 8 2013,rst cause:2, boot mode:(3,6)
    load 0x40100000, len 1396, room 16
    tail 4
    chksum 0x89
    load 0x3ffe8000, len 776, room 4
    tail 4
    chksum 0xe8
    load 0x3ffe8308, len 540, room 4
    tail 8
    chksum 0xc0
    csum 0xc0
    2nd boot version : 1.4(b1)
    SPI Speed : 40MHz
    SPI Mode : DIO
    SPI Flash Size & Map: 32Mbit(512KB+512KB)
    jump to run user1 @ 1000
    rl??rl??â?büLoading 5123 bytes from flash...
    -> LoopbackA
    ets Jan 8 2013,rst cause:2, boot mode:(3,6)

  • I am not able to use serial1 at 19200 baud.
    Do I need to move to C ?

  • Currently the serial devices are not usable for application purposes. Someone needs to fix up the serial device code and make sure that other things, like the debugging console, don't interfere.

  • Thanks

  • Has anyone done any work on this?

    I'm getting to the point where I need to get the hardware serial, and this issue hit me like a ton of bricks. Working serial is critical.

    What needs to be done to make this work?

  • Looking at the code, it seems to me that outputting to Serial1 and Serial2 ought to work. Does it not (sorry, no esp8266 handy)?

    In order to make input on Serial1 work, I believe all that's needed is to change https://github.com/espruino/Espruino/blo­b/master/targets/esp8266/user_main.c#L19­5 to use EV_SERIAL1 (or whatever the right constant is to put the characters into the Serial1 input queue instead of the console).

    There's also an issue when you disconnect from a telnet console in that it resets the espruino console back to the default and that's Serial1. Not sure how to fix that. Maybe it needs to remember what it was before changing to EV_TELNET? See https://github.com/espruino/Espruino/blo­b/master/libs/network/telnet/jswrap_teln­et.c#L212

    In order to set baud rates and such, someone has to implement jshUSARTSetup here: https://github.com/espruino/Espruino/blo­b/master/targets/esp8266/jshardware.c#L6­54 The functions to do the work are all in uart.c, so it's mostly a "wiring-up" job.

  • The whole automatically changing console is something that probably needs improving across Espruino. It'd be nice to just remember whether it was explicitly set and then always use that, but then you probably need some way to make it automatic again.

    But as @tve says, it looks like it's just a few small tweaks needed to get it working correctly.

  • @tve am just looking at this - is there any reason for TASK_APP_RX_DATA that I'm missing? It seems odd to take the RX data and stick it in a buffer just so that it can be taken out of that buffer and shoved into another one... jshPushIOCharEvents is designed to be called from an IRQ so should be ok

  • I noticed the double buffering as well when I prepared one of my last builds but didn't want to change it at that moment for fear of making things unstable. All this predates my involvement. But yes, needs to be ripped out!

    How big is the queue provided by jshPushIOCharEvents? The HW UART queue is 128 chars, so we need to be able to buffer at least that much. The interrupt triggers when it holds 80 (or it's idle a couple of char periods). IIRC the IO Events queue is only 64.

    (I'd make the changes to get serial working if I had time but I'm slammed right now. Testing these changes does take a chunk of time, specially since I usually make a mistake or two to start with :-).

  • IIRC the Espruino event queue is 128 usually, but it stores 4 chars in each item so it can actually grab 512 bytes.

    I might have a play and see what happens.

    No problem about the changes - after all, we're all doing this stuff for free :)

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview

Is it possible to change the baudrate on ESP8266 running espruino ?

Posted by Avatar for jsbaekke @jsbaekke