Skip to main content

Python project that emulates Scratch Link, and allows communication between Scratch and Python.

Project description

Mouselink

Mouselink on PyPI

Mouselink is a Python package that emulates Scratch Link, which enables Scratch to connect to hardware peripherals such as a micro:bit or an EV3. Mouselink tricks Scratch into thinking that it is Scratch Link, and allows you to connect Scratch to more then their small selection of hardware peripherals, and to software as well!

Installation

To install it, use:

python -m pip install mouselink

You can use the example code found in the examples directory or copy the code below:

from mouselink import mouselink as sl

p = sl.ev3()

def on_got_data(data):
    print(f"Got data: {data}")
    p.send(f"1{data}0") # send back data with some additional data

p.on_read(on_got_data)

p.run()

Features (and planned ones)

Implemented:

  • Add an EV3 to the device list
  • Allow Scratch to connect to that EV3
  • Transmit data as that EV3

Planned

  • Support connecting as other peripherals
    • micro:bit
    • WeDo 2.0
  • Communication using the Translate extention's data saving glitch

How does it work?

I investigated Scratch's communication with Scratch Link, and discovered it uses a plain, unencrypted WebSocket server. I own an EV3, so I used my web browser's developer tools to monitor the data sent between Scratch and Scratch Link. I then began writing Mouselink, using my real EV3 communication as reference for the protocol. After a few days, I could connect an emulated EV3 device and have it be recognised by Scratch, and a few days after that I could transmit data between Scratch and Mouselink.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mouselink-1.0.0.tar.gz (47.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mouselink-1.0.0-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page