AndiDittrich / NodeMCU-Tool

:wrench: Upload + Manage Lua files on NodeMCU
https://www.npmjs.com/package/nodemcu-tool
MIT License
310 stars 54 forks source link

Issues with terminal operation on Mac OS X / option --run does not work #58

Closed micheldrescher closed 5 years ago

micheldrescher commented 5 years ago

Hi,

I finally managed to get nodemcu-tool to work on Mac OS X. However, I can't get the --run option of the terminal operation to work - I have no idea what is going on.

It seems that for whatever reason, invoking terminal operation resets the ESP8266 to rebooting. Is that desired behaviour? If so, It should not interfere with the --run sub-command.

See below for a capture on what happens on my terminal when trying to get a very simple hello world Lua script to execute via terminal. The underlying point is that for my actual developments I cannot use the run operation, because my Lua scripts include asynchronous callbacks, and run exits before these even have the chance to run and produce (debug) output.

My .nodemcu contents is:

{
    "baudrate": "115200",
    "port": "/dev/tty.wchusbserial1410",
    "minify": false,
    "compile": false,
    "keeppath": false,
    "connectionDelay": 500
}

And here is the log of my terminal activities. You can clearly see that the file hello_world.lc exists and can be invoked via the run operation of nodemcu-tool - but not when I try to execute it via nodemcu-tool terminal --run hello_world.lc

What is going on?

Cheers, Michel

work-lan:Sandbox oerc0098$ nodemcu-tool upload hello_world.lua --compile
[config]      ~ Project based configuration loaded 
[NodeMCU-Tool]~ Connected 
[device]      ~ Arch: esp8266 | Version: 2.2.0 | ChipID: 0x649c76 | FlashID: 0x1640ef 
[NodeMCU-Tool]~ Uploading "hello_world.lua" >> "hello_world.lua"... 
[connector]   ~ Transfer-Mode: hex 
[device]      ~  |- compiling lua file.. 
[device]      ~  |- success 
[device]      ~  |- original Lua file removed 
[NodeMCU-Tool]~ File Transfer complete! 
[NodeMCU-Tool]~ disconnecting 
work-lan:Sandbox oerc0098$ nodemcu-tool run hello_world.lc
[config]      ~ Project based configuration loaded 
[NodeMCU-Tool]~ Connected 
[device]      ~ Arch: esp8266 | Version: 2.2.0 | ChipID: 0x649c76 | FlashID: 0x1640ef 
[device]      ~ Running "hello_world.lc" 
[device]      ~ >-----------------------------> 
Hello, World!
[device]      ~ >-----------------------------> 
[NodeMCU-Tool]~ disconnecting 
work-lan:Sandbox oerc0098$ nodemcu-tool terminal --run hello_world.lc
[config]      ~ Project based configuration loaded 
[terminal]    ~ Starting Terminal Mode - press ctrl+c to exit 
;ld��|�l�|

          �
           d�
             b<�����c�c��'o�$gn���
                                  #p��l{l{lp�'�
                                               �
                                                d

                                                 cg�|���

                                                        c��o'�l��d`�n
                                                                     d`gs���o
                                                                             d�lx�n�
                                                                                    ;�����

                                                                                          c
                                                                                           n�|�
                                                                                               �p�c��'o�
                                                                                                        d`�'
                                                                                                            l`os���o
                                                                                                                    b�l x�o�
                                                                                                                            ;�����l��
                                                                                                                                     c
                                                                                                                                      n�|$���b��og�
            l �n
                d`gs���o
                        bc� s��'
                                #c�`������{��o|�lll$`#��{�l�o��g�
                                                                 l`��;�d�d�
                                                                           $`��s�l�l�

                                                                                     `��r�l���
                                                                                              $l`{l��{d����#
                                                                                                            ��b|dc������l#��o��'��l�<
                                                                                                                                     ���l
  d��$�|�l�$�n�����c
                    $l���
                         b
                          ����c
                               d�b{l{

NodeMCU custom build by frightanic.com
    branch: master
    commit: 11592951b90707cdcb6d751876170bf4da82850d
    SSL: true
    modules: cron,file,gpio,http,i2c,mdns,mqtt,net,node,ow,pwm,sntp,tmr,uart,wifi,tls
 build created on 2019-01-06 20:18
 powered by Lua 5.1.4 on SDK 2.2.1(6ab97e9)
> 
AndiDittrich commented 5 years ago

@micheldrescher

it is not the desired behaviour... please read https://github.com/AndiDittrich/NodeMCU-Tool/blob/master/docs/Reset_on_Connect.md

the issue is caused by the DTS/RTS lines which are invoked by the serialport driver during initialization....

micheldrescher commented 5 years ago

Thanks for the link, but it doesn't fix my problem.

How do prevent that from happening? The current workaround to invoke terminal and manually do a dofile("hello_world.lc") is rather clunky and time consuming...

To clarify, I am not EE-ing my own boards, I am using a Wemos D1 mini. And it is only the terminal operation that causes the problem!

AndiDittrich commented 5 years ago

use another NodeMCU module......or fix the serialport driver

the issue does only appear on a few modules...for example the "original" NodeMCU module work fine.

micheldrescher commented 5 years ago

Node.js (by proxyof serialport) seems to be a bad choice for IoT/embedded development then, anyway...

Guess I'll have to look for a different tool then.

AndiDittrich commented 5 years ago

@micheldrescher

the issue is related to the OS serialport driver (usb<>serial chip) and the HW design of the NodeMCU modules...