MrYsLab / s3-extend

Control an Arduino Uno, Circuit Playground Express, Raspberry Pi Pico, ESP-8266, ESP-32, Picoboard, Robohat MM1, or Rasberry Pi From Scratch 3
GNU Affero General Public License v3.0
27 stars 13 forks source link

WebSocket connection to 'ws://127.0.0.1:9002/' failed: #44

Closed ucay99 closed 4 months ago

ucay99 commented 4 months ago

Screenshot 2024-03-07 142557

exuse me sir.. when i start the program and connect it with my esp, why shortly afterward the websocket always disconnects

image

MrYsLab commented 4 months ago

I assume that s3e only crashes once you start your Scratch program in the browser. Please let me know if that is incorrect.

One thing you may try is to remove the Connect IP address block from the forever loop, as shown here.

If that does not fix the problem, please use the troubleshooting instructions described here. Please post the crash output from any windows to this issue thread.

If you are running within a Python Virtual environment, you will need to open each of the troubleshooting procedure windows as activated virtual environment windows.

Please let me know if you have any success or any further questions.

ucay99 commented 4 months ago

Thank you, sorry in advance because I didn't attach some picture of the problems I experienced..

browser

s3e. s3e

backplane. backplane

espgw. espgw\

wsgw. wsgw

ucay99 commented 4 months ago

sorry, why is this?? I was able to run s3e earlier, why now it goes straight to websocket gateway exit...??

image

MrYsLab commented 4 months ago

Thank you for providing the information above.

To be sure, when you start s3e, and before you start Scratch, s3e does not crash. You can start the browser and install the ESP-8266 into Scratch 3. The crash occurs only when you begin your Scratch blocks program. Please verify that this is correct.

I have tested here, and I cannot reproduce the problem.

From the exception stack trace, you may have another version of the WebSocket gateway running. This can happen if things do not shut down properly.

You can check this by starting the Windows Task Manager before starting s3e. In the Processes tab, Screenshot from 2024-03-08 09-28-39 you should not see any Python programs running:

After starting s3e, there should be several instances of Python shown:

Screenshot from 2024-03-08 09-32-02

When you quit s3e, the Python processes should disappear.

Please try again by first restarting your computer and then starting s3e.

Please let me know if things are still not working and if my statement above about when the crash appears is correct.

MrYsLab commented 4 months ago

I am closing this issue. If you need more help, post it here, and I will be notified. I can reopen the issue if necessary.

ucay99 commented 4 months ago

Thank you for providing the information above.

To be sure, when you start s3e, and before you start Scratch, s3e does not crash. You can start the browser and install the ESP-8266 into Scratch 3. The crash occurs only when you begin your Scratch blocks program. Please verify that this is correct.

I have tested here, and I cannot reproduce the problem.

From the exception stack trace, you may have another version of the WebSocket gateway running. This can happen if things do not shut down properly.

You can check this by starting the Windows Task Manager before starting s3e. In the Processes tab, Screenshot from 2024-03-08 09-28-39 you should not see any Python programs running:

After starting s3e, there should be several instances of Python shown:

Screenshot from 2024-03-08 09-32-02

When you quit s3e, the Python processes should disappear.

Please try again by first restarting your computer and then starting s3e.

Please let me know if things are still not working and if my statement above about when the crash appears is correct.

yes sir.. scratch will crash when I start running block2, then when I restart my computer s3e can be run again

ucay99 commented 4 months ago

when I run the program in order then wsgw errors as in the previous picture..

MrYsLab commented 4 months ago

Hi Yusuf, I am still unable to reproduce what you are seeing. Is it possible that your router assigned a new address to the ESP-8266? You can check by following these instructions. That address should be used in the ESP-8266 Address block in Scratch.

ucay99 commented 3 months ago

actually i am using esp32, is it possible?

MrYsLab commented 3 months ago

That is a very easy mistake to make. The two boards look very similar, and the printing on the board showing either ESP32 or ESP8266 is very difficult to see. I do not have a Scratch extension for the ESP32, but I have a Python library supporting it. The user guide may be found here. This package provides many examples.

ucay99 commented 3 months ago

is it possible for me who is a beginner to create my own esp32 extension based on the reference of the esp8266 extension?

MrYsLab commented 3 months ago

Creating a new extension is somewhat complicated. The Scratch team has made it very difficult on the Scratch end. You need to modify several of their files, and the development environment requires a specific version of node.js and yarn. I have never had success building in Windows. I usually work in Linux. The Python end is relatively straightforward. A new gateway would need to be created for the ESP32, but it would look very similar to the one for the ESP8266.

Are you trying to use this in a classroom setting, or is this for personal use?

I may be willing to create a new extension for the ESP32, but I don't know when I'll be able to complete it.

Please let me know how soon you require it.

Also, are other GUI's acceptable? Here are screenshots of other GUIs I created to control various microcontrollers.

The first is a web page, the second is a TkInter application and the third uses Flet which can run the GUI in the Browser, as an application on the PC and even as an Android app on an Android device.

Screenshot from 2024-03-19 13-38-33 Screenshot from 2024-03-19 13-29-41 Screenshot from 2024-03-19 13-23-15

MrYsLab commented 3 months ago

Ok. I started to create the ESP32 extension on the Scratch side. You may be interested in what I am doing if your boss asks you to "make a few simple changes."

The Scratch editor consists of two major directories: scratch-gui and scratch-vm. You can see my changes and the new file I added if you click the links below. There are only a few changes, but some are non-obvious. Such as creating a couple of .png files and placing them in the correct directory. Also, one of the .png files must be converted to a base64 format. scratch-gui scratch-vm

The Scratch team made adding extensions difficult; they could have explained things better.

Below are some links that will give you a better idea of how an extension is created.

The Scratch Extension Specification. The Scratch team wrote it, and it is only sometimes correct.

How to Develop Your Own Block for Scratch 3.0. This is how I learned to create extensions. I worked with the author to help improve his article.

I documented things at the beginning in my blog. There are five articles beginning with this one. I am unsure how helpful they are. They document things as I started to develop the extensions.

I will be beginning the Python side of things next. I need to create a new gateway for the ESP32 and am still determining how long that will take. The gateway concept came from a project I developed called python_banyan and the OneGPIO concept. Essentially, a gateway translates one protocol to another. By using OneGPIO, the protocol on the Scratch side is the same for all microcontroller board types. Only the microcontroller side of the gateway needs to be custom-built for each board type. The goal is to improve development times and limit the new code that needs to be written via code reuse.

I hope I haven't overwhelmed you with information and a giant homework assignment.

MrYsLab commented 3 months ago

Ok, I have an extension for the ESP32 working. You can view the esp32 gateway here.

I have several other things I need to do before I can release the code.

Python has changed the build system to use pyproject. toml instead of setup.py. I need to build this file. Also, I will need to create a launcher for the ESP32 and update the documentation. I should have this all done within a week.

MrYsLab commented 3 months ago

I have released new versions of s3-extend (1.30) and the Scratch editor. The documentation has also been updated. ESP32 support is now available.

ucay99 commented 3 months ago

Thank you very much for your hard work, may success always accompany you