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

Linux version of scratch-link? #84

Open
martinohanlon opened this issue Sep 27, 2018 · 21 comments
Open

Linux version of scratch-link? #84

martinohanlon opened this issue Sep 27, 2018 · 21 comments

Comments

@martinohanlon
Copy link

This issue is meant to be a way of opening a discussion relating to the creation a linux version of scratch-link.

From my perspective:

In the near future, we (Raspberry Pi foundation) will need to make some decisions about how to make a future Scratch 3 Raspberry Pi extensions "talk" to the hardware and the presence (or not) of a linux version of scratch-link is a factor.

Current thinking (no more than that, subject to change, etc) is that comms would be via TCP to the pigpiod daemon running on the Pi.

Are there any plans for a scratch-link version for linux? Is it a consideration?

@thisandagain
Copy link
Contributor

Hey @martinohanlon, just to follow-up on this thread from our email discussion:

  • We would be happy to support the community if you/they would like to port Scratch Link to Linux
  • We would be happy to support communication over TCP in Scratch Link as that is becoming a common request (particularly for IoT platforms). To get this landed across all three platforms (Windows, MacOS, and Linux) it would be nice for us to collaborate / work together on the strategy and implementation.

@thisandagain thisandagain added this to the Backlog milestone Oct 12, 2018
@em-be
Copy link

em-be commented May 3, 2019

Hi,

After some quick examination it seems that scrach-link is a flat web server @device-manager.scratch.mit.edu:20110 with websocket capability which handles json requests as described in Network Protocol. json requests for bt/ble are quite simple:

  • discover services and enter connection state;
  • send raw data to bluetooth devices and rebroadcast their responses.

I propose to create scratch-link version for linux as SysV service starting at init which reroutes device-manager.scratch.mit.edu to localhost. It can be implemented in python using flask with websockets or any other simple http-service. For other than bt/ble services eg. tcp pigpiod daemon @ raspberry, scratch-link should just redirect the queries as necessary.
Comments?

@audetto
Copy link

audetto commented Jun 9, 2019

I don't know how the Windows and MacOS versions are implemented, but I think this is very similar to the http-serial-BT bridge developed by MakeBlock for the MBot (like an Arduino)

It is a node.js app which is used by their version of Scratch to send data via the serial port to the device which is running a particular sketch with a compatible protocol.

I've created a github project here if anybody is curious https://github.com/audetto/mblock-mlink.

The good thing about this approach is that the same node.js version works for all platforms and you don't need to maintain a separate source for each of them.

How to create the serial port, is OS-specific, but afterwards the same code works for Win, Mac, USB, BT...

@audetto
Copy link

audetto commented Jun 15, 2019

https://github.com/audetto/asi-link

I've written a super simple implementation in nodejs of a link for serial ports (USB or BT Classic), which should work on all platforms.
Not tested with any real device as I do not have a device to test it with. I am still writing the scratch-vm extension for an mBot, then I will do the full test.

I might be completely off, but it looks super simple, with a few caveats

  • the whole device-manager.scratch.mit.edu + wss:// seems an over complication to me.
    • I am running with ws://localhost and it works perfectly
    • the certificates and the key are available in cleartext from the mac package, so it is hardly providing any security
    • what is the rationale behind this solution? it makes it hard to recompile and reimplement scratch-link
  • about the protocol: using the gui I can load multiple BT extensions, but so far I have not found a way to detect which device each message belongs to. Have I missed something in the protocol?

@audetto
Copy link

audetto commented Jun 16, 2019

My bad, it was a side effect of a poor design (global variables...)
Each extension is a new ws:// connection so there is no need to ad this to the protocol.
Anyway, now it is time to write the Extension in scratch-vm and we will see how this works.

@cwillisf
Copy link
Contributor

@audetto I've just created #137 as a place to discuss WSS rationale and related topics. You're not the first person to ask about it so I figured it was time for a thorough explanation to be posted somewhere.

If you'd like to further discuss other topics related to the protocol or serial ports or anything that isn't specifically related to building a Linux version of Scratch Link, I would recommend creating a separate issue for that discussion. Thanks!

@marek-memsql
Copy link

+1 for the linux port... It would be great because my kids could use a rpi for programming boost...

@audetto
Copy link

audetto commented Jul 11, 2019

Mind you, scratch link linux for a serial device is pretty much done (either USB or Bluetooth Classic)

Lego Boost needs BLE UART which is not written.

There is a node.js module for this

https://github.com/noble/noble

I will have to try it.

@jaafreitas
Copy link

Two years ago I wrote a multi-platform micro:bit extension for ScratchX using noble.
https://github.com/jaafreitas/scratch-microbit-extension

I'm still waiting for the official Scratch Link for Linx, Raspberry PI and Chromebook version.

@jorgenskogmo
Copy link

+1 for Linux (esp. RPI)

@apple502j
Copy link

@thisandagain A Japanese programmer wrote Python implementation of Scratch Link here: https://github.com/kawasaki/bluepy-scratch-link/blob/master/scratch_link.py
Worth checking.

@thisandagain
Copy link
Contributor

@apple502j Thanks for the heads-up! I hadn't seen this yet!

@jsyzthz
Copy link

jsyzthz commented Oct 29, 2019

Can we use a cross-platform language to re-write this tools? like Java, Python ...

@qwertykid
Copy link

do you have copy i can install???

@pepo-k
Copy link

pepo-k commented Dec 20, 2020

Hi
is there any progress in porting of scratch link to linux?
Can anybody make help here to show hot to get the lego boost working over ubuntu/scrattux?

Peter

@jsyzthz
Copy link

jsyzthz commented Jan 6, 2021

i try the go lang and java ,but it's difficult to implement. but i found a idea - Web Bluetooth. who use it? like MakeCode

@Pythone
Copy link

Pythone commented Sep 7, 2021

This issue is meant to be a way of opening a discussion relating to the creation a linux version of scratch-link.

From my perspective:

In the near future, we (Raspberry Pi foundation) will need to make some decisions about how to make a future Scratch 3 Raspberry Pi extensions "talk" to the hardware and the presence (or not) of a linux version of scratch-link is a factor.

Current thinking (no more than that, subject to change, etc) is that comms would be via TCP to the pigpiod daemon running on the Pi.

Are there any plans for a scratch-link version for linux? Is it a consideration?

I tried using pyscrlink and it worked well. (repo: https://github.com/kawasaki/pyscrlink)

@Pythone
Copy link

Pythone commented Sep 7, 2021

@thisandagain A Japanese programmer wrote Python implementation of Scratch Link here: https://github.com/kawasaki/bluepy-scratch-link/blob/master/scratch_link.py
Worth checking.

It turns out that this was renamed to pyscrlink

@wawrzek
Copy link

wawrzek commented Dec 27, 2021

Is there any updated on Linux support?

@zdila
Copy link

zdila commented Jan 1, 2022

I have written scratch-link in Node.js for Linux and Intelino smart train: https://github.com/zdila/intelino-smart-train-scratch-link-linux

Code is quick and dirty (written in cca one day including studying of D-BUS and it's Bluetooth API) and it is hardcoded to search only Intelino devices. Feel free to use it for the inspiration.

@markakis-sch
Copy link

+1 for official Linux support.

I'm using Scratch 3.0 and kawasaki/pyscrlink on Linux (Ubuntu). I confirm that is stable and works fine with Lego WeDo 2.0 and EV3.

I also tried zdila/scratch-link-ble-linux. I was able to connect a WeDO 2.0 but could only use the "set light color to" command. I will continue to try it, because it is new and under development.

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

No branches or pull requests