Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Monitoring a serial port breaks upload #384

Closed
aperepel opened this issue Dec 17, 2015 · 6 comments
Closed

Monitoring a serial port breaks upload #384

aperepel opened this issue Dec 17, 2015 · 6 comments
Assignees
Milestone

Comments

@aperepel
Copy link

Solution

platformio run -t upload && platformio serialports monitor

Board: esp12e

If I attach to a serial port to monitor the output, it will prevent upload from working. Not sure what can be done here, but other environments manage to somehow do it. Reverse is true - if I start the upload process and attach to a serial port in another terminal window, it will fail the upload (and attach too).

Ideally, we'd like to keep the monitor open and attached and keep re-uploading the firmware iteratively. This way the monitor won't be skipping some init output and have us re-attach after every upload.

@ivankravets
Copy link
Member

If I attach to a serial port to monitor the output, it will prevent upload from working. Not sure what can be done here

Nothing can be done here 😟 Device is busy by another process. The only one solution is terminate current process using administrative privileges. However, I don't recommend to use platformio with administrative/sudo permissions.

but other environments manage to somehow do it

Do you mean Arduino IDE? They have PID of opened serial monitor and can close/kill it before uploading and then restore it.

PlatformIO is full flexible and independent toolkit. We don't limit users in their actions. Someone likes to use external Serial Monitor with GUI, others like platformio serialports monitor. We don't force users to use all our tools from @platformio. Our aim is to develop useful tools and improve obsolete practice with embedded development. User have ability to decide what is comfortable for him.

As for me, I use CoolTerm. Of course, each time before uploading I manually disconnect/connect to SerialPort in GUI.

@itsjustvenky
Copy link

The Sming framework does this similar to arduino IDE from command line when used "make flash".
After flashing, it open its own serial monitor

TERMINAL     ?= python -m serial.tools.miniterm $(COM_PORT) $(COM_SPEED_SERIAL)
flash: all
    $(vecho) "Killing Terminal to free $(COM_PORT)"
    -$(Q) $(KILL_TERM)
ifeq ($(DISABLE_SPIFFS), 1)
    $(ESPTOOL) -p $(COM_PORT) -b $(COM_SPEED_ESPTOOL) write_flash $(flashimageoptions) 0x00000 $(FW_BASE)/0x00000.bin 0x09000 $(FW_BASE)/0x09000.bin
else
    $(ESPTOOL) -p $(COM_PORT) -b $(COM_SPEED_ESPTOOL) write_flash $(flashimageoptions) 0x00000 $(FW_BASE)/0x00000.bin 0x09000 $(FW_BASE)/0x09000.bin $(SPIFF_START_OFFSET) $(SPIFF_BIN_OUT)
endif
    $(TERMINAL)

Sorry I don't want to mention other frameworks here, but just for example/reference purpose I providing the idea.

If it all this is possible to implement with a extra option to platformio command line, then it will be a great feature.

Thoughts ?

@ivankravets
Copy link
Member

I've explained above the problem. All these IDEs work in own isolated space where they spawn child process and have their PIDs. You can reproduce same logic using own "isolated space" via script upload_and_monitor.sh

platformio run -t upload
platformio serialports monitor

What is more, you can put these line into infinite loop. Exit from Monitor will raise uploading, and ... repeat.

@aperepel
Copy link
Author

I understand your point, Ivan. Was really checking if there was any trick or obvious omission, but was on a cautious side.

For my purposes this one works quite well:

platformio run -t upload && platformio serialports monitor --baud 115200

As soon as upload is done - it connects to the monitor, so I don't skip any early init output. Maybe we can put it in a FAQ as a best practice?

@itsjustvenky
Copy link

@aperepel @ivankravets thanks.

@XhstormR
Copy link

I use the following command and it is very useful:

pio run --target upload --target monitor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants