MrYsLab / pseudo-microbit

A pseudo implementation of the micro:bit micropython API.
Other
16 stars 4 forks source link

Issue with uflash, using micro:bit v2 and Raspberry Pi 4 Model B #5

Closed vkb008 closed 3 years ago

vkb008 commented 3 years ago

Hello, I have read thru your tutorial and I am having issues with the uflash external command.

As I start, I confirmed when I have my micro:bit connected via USB to my Raspberry Pi, I am able to flash hex files from the makecode website.

However, when I try running the uflash command in Terminal, I get a 529 error code on the micro bit (looking at the error code on the micro bit support site ). This tells me I might have issues when implementing the uflash external command in PyCharm.

Regardless, I checked via Terminal where the uflash program was installed. Directory: /usr/lib/python3/dist-packages.

I then attempted to add the uflash command in PyCharm:

PyCharm

However, when I tried running the external command to test it, I am getting this error:

uflashRunError

Any help to resolve this external commands would be really great. I was able to get the minify external command and properly install the pseudo-microbit. I am itching to flash some programs where I can send data via BLE from the microbit to my Pi and I feel like getting through this uflash setup issue will get me there.

Thanks in advance!

MrYsLab commented 3 years ago

Hi Vikram, Thanks for the question. When adding an external tool to PyCharm, in the Program: field of the Edit dialog box, you need to place the name of an executable file and not the path and name of the Python script. So for example, for uflash, you would change

/usr/lib/python3/dist-packages/uflash.py

to

uflash

image

You can also run uflash directly from the command line. If you open a command window and type "which uflash", you should see something like this:

image

As confusing as this might seem, let me explain what is happening and why that is.

Python provides a facility in the disutils package via the setup.py file to install a Python script as a command-line executable. The genius of Python is that using the setup facility, a native executable is created and installed for the operating system in use.

The way this is accomplished is by specifying something called a console_script in the entry_points section of setup.py. You can see an example of this for uflash at this link. The syntax to specify a console_script can be somewhat confusing, but the result is that an executable for the Python script is created and placed on the executable path.

Hopefully, I've shed some light on this for you and not added unnecessary confusion. I am going to close this issue, but please feel free to add any additional comments or qeustions you might have, and your entry will be posted to this issue even if it is in the closed state. If necessary, I can reopen the issue at any time.

vkb008 commented 3 years ago

@MrYsLab Thank you for the explanation. I made the switch to just specify uflash and the code worked!

successfulRun

However now I'm getting the 529 error code. I will create a separate issue where we can discuss this.