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

Characters \r\n when loading a file are converted to line breaks in the file itself. #25

Closed
EugeneRymarev opened this issue Nov 23, 2022 · 12 comments
Assignees

Comments

@EugeneRymarev
Copy link

Problem
image
Original
image
File

@ubidefeo
Copy link
Collaborator

@EugeneRymarev
Please be more specific with describing your issue.

adding text and code blocks can better help us understand and compare.
Screenshots are not the right way to submit an issue

thank you

@EugeneRymarev
Copy link
Author

@ubidefeo
test.zip
Try to upload this file.
source
image

print('200 OK \r\n')

result after upload to device
image

print('200 

@jcristine
Copy link

I am having the same issue. The target file on the microcontroller, in my case a Pi Pico W, is truncated at the "\r\n" exactly as shown in the comment above this one.

@EugeneRymarev
Copy link
Author

@jcristine
You can upload your files via ampy.

@jcristine
Copy link

"You can upload your files via ampy"

Yes - that is what I've been doing for years but was happy to see that the new Arduino IDE has it all in one UI (unless we use \r\n in code)

@EugeneRymarev
Copy link
Author

@jcristine, I meant that I would have to do this until this bug is fixed. By the way, the plugin for PyCharm has the same bug.

@EugeneRymarev
Copy link
Author

@ubidefeo, do you understand the problem?

@murilopolese
Copy link
Contributor

Thank you @EugeneRymarev for the report!
I think this is expected due to the way we are saving files on the board.
The IDE (currently) send files to be board as text strings and I think this is the reason for the behaviour you reported.
I think we should look into this, @ubidefeo 👍

@murilopolese
Copy link
Contributor

I did a quick investigation and I can reproduce the bug.
My new guess is that the method read_until from micropython.js may be related to the issue:
https://github.com/arduino/lab-micropython-editor/blob/main/micropython.js#L72

@ubidefeo
Copy link
Collaborator

hey @murilopolese
let's put this one in the next Sprint.

It would be great if any character in the source could be handled nicely and never be stripped/replaced.
(refer to the behaviour in #8 )

@chrisbuerginrogers
Copy link

I solved it by converting the desired string to binary and then writing it out as hex values:

gc.collect()
with open("Fred.py","wb") as bfile:
f = bfile.write(bytes([0x73,0x22,0x10])). #I do this in 256 byte chunks (so not these three random numbers)
f = bfile.write(bytes([0x73,0x22,0x10]))
f = bfile.write(bytes([0x73,0x22,0x10]))
f = bfile.write(bytes([0x73,0x22,0x10]))

That seems to work fairly flawlessly

@ubidefeo
Copy link
Collaborator

Fixed in 0.9.x

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

No branches or pull requests

5 participants