Copyright ©

Mongoose OS Forum

ATTENTION! This forum has moved to:

Do not post any new messages.

RPC via terminal and Serial Connection restarts device

edited June 2018 in Mongoose OS


I am controlling two servos with an ESP12E devkit and try to send the new coordinates through the serial connection:

RPC.addHandler('PWM', function(args) {
  print('Got PanTiltCmd:', JSON.stringify(args), '\n');
  goal_pan = args.pan;
  goal_tilt = args.tilt;
  return true;

If I send the command through the MOS Browser Interface, it works fine. But if I use the terminal command (" mos --port /dev/ttyUSB0 call PWM '{"pan": 20, "tilt": 90}'"), the device restarts and afterwards executes the command. I can also use the curl-based method on the command line.

This is my output as soon as I send an RPC through the command line:

[Jun  7 12:55:19.456] rl l  |  l |      d  c|     ; c   d      b o | ll   c  gg  d  l`  no l`   n{   g   d  l r  n   l  

[Jun  7 12:55:19.482] rBoot v1.2.1-cesanta1 - ric
[Jun  7 12:55:19.490] Flash Speed:  40 MHz

[Jun  7 12:55:19.490] rBoot Opt     n  {  g|  d $ll`  c    < sta(5c:cf:7f:23:ec:5e)

[Jun  7 12:55:19.589] add if0
[Jun  7 12:55:19.601] 13 (20180514-130027/???)
[Jun  7 12:55:19.601] esp_mgo0 MHz, RAM: 51736 total, 49260 f_reset_info Reset cause: 6 (sys oose 6.11, LwIP 1.4.1
[Jun  7 12:55:19.621] mg_ssl_if_3fff0184
[Jun  7 12:55:19.631] mgos_vfs_mount       Mount SPIFFS @ / (dev 0x3fff0184, 144}) -> 0x3fff0194
[Jun  7 12:55:19.704] 681, used: 132528, free: 101153
[Jun  7 12:55:19.805] 23EC5E
[Jun  7 12:55:20.753] mgos_wimode : sta(5c:cf:7f:23:ec:5e) + 0
[Jun  7 12:55:20.765] WPA2 ENTERPRISE VERSION: [v2.0ota_lib=(null), ota handler 1
[Jun  7 12:55:20.795] esp8266_23EC5E/rpc
[Jun  7 12:55:21.140] mgos_aws_shadow_init AWS Device mongoose_poll     onnecting
[Jun  7 12:55:21.532] Got PanTiltCmd: {"tilt":90,"pan":20} \x0a          

Any ideas what could cause this behaviour?


  • nliviunliviu Romania
    edited June 2018

    Do you try to send the RPC via serial while the web interface is active?
    Why don't you use mos --port ws://IP/rpc call PWM '{"pan": 20, "tilt": 90}'?

  • edited June 2018

    I tried it with and without active web interface. I currently have the board connected to my workstation that does not have an wifi connection, so I need to use the serial connection. (And so far, I found no way to read directly from serial)

  • nliviunliviu Romania

    Only ONE application can use the serial port at any time.

    Your workstation is connected to local lan?
    Do you have a wireless acess point in the same lan?
    If yes and yes, you can configure the wifi on ESP8266, see the logs in the Web UI and send RPC commands via ws or http.

    What do you mean by "I found no way to read directly from serial"?

  • Is it possible that mos restarts the device every time it wants to establish the serial port?

    What do you mean by "I found no way to read directly from serial"?

    If I can't use the RPC via serial port, I looked for a way to directly send messages on the serial port without the additional layer of the RPC. (Similar to for the Arduinos)

  • nliviunliviu Romania

    There is no reason RPC would not work on serial connection.
    Make sure there is no program using the serial port. You can check with lsof|grep USB.

  • The RPC works fine as it's sending the data to the device. But the device restarts as soon as it gets a command (and executes the callback correctly after the restart). So the problem is most likely on the device side as the workstation is able to send the data.

Sign In or Register to comment.