-
Notifications
You must be signed in to change notification settings - Fork 33
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
print a variable without print() function #44
Comments
I've always wanted to have this one, but I think it's very difficult. Here's some more information about how difficult it is, when I posted the request to the adafruit version:
So basically, the serial connection to Micropython enters this raw mode (Control-A) which turns off the echoes and interactive outputs -- other than what is explicitly printed -- so you don't get normal behavior, like giving the final value. I can't see a work-around. Fortunately it's not stopping any capabilities, other than the need to write "print()" round stuff. |
Hi @goatchurchprime, I have a solution to this (works the same for both SERIAL and WebREPL connections). The are some limitations like big code blocks or more than a block in a cell (although if they are defined within a function works great) Another limitation is that for the serial communication I use picocom, which is not supported in windows, but in the future there may be an alternative... If you are interested let me know ;). |
I just tried it, but couldn't get it to work. It said it was connected, but nothing got executed on the board unfortunately. No errors were given. Can it connect to a device which is already running a program? Why the dependence on picocom when you already have the serial library? You should steal my guessserialport() function so people don't need the hassle of looking it up on the operating system when there is only one ESP32 plugged in: |
Hi, which class did you test that didn't work?
W_UPYDEVICE class needs WebREPL to be running/available to connect and sends commands so if a device is running a program/while loop you would need to use '.kbi()' method (Keyboard Interrupt) first to be able to send commands and receive output. S_UPYDEVICE by default resets the device at initialization so if there is a while loop in main you would need to use '.kbi()' method first to be able to send commands and receive output too.
Back in the day when I started to write the library it was easier for me ( in fact the only way I got it working) to use Picocom to write to its stdin and read from stdout (see Windows support) but now I got it working with just Pyserial, see this
Thanks for this!, I will definitely implement it in upydevice. :) |
If I use a serial terminal, the following code shows the result (1)
However, if I use MicroPython-USB kernel in Jupygter notebook, I have to use the 'print()' function to display the result as follows.
There is any method to display variable without print() function like normal serial terminal.
The text was updated successfully, but these errors were encountered: