Hi
I've done a lot of stuff over the years in getting Scratch/BYOB controlling the pins on the Raspberry Pi thru a python handler that listens/responds to Scratch 1.4 type broadcast/sensor-update msgs.
So when we get a version of GP that runs natively on the Pi - it would be really nice if there was a method that was at least as good as the old 1.4 facility, to help do this.
Having the broadcast send out 1.4 type broadcast msgs would be perfect of course :)
Today, I've managed to make a very simple "cloud server" listener on a Pi ( having modified CloudDataServer.gp to point to the Pi ip address) as a proof of concept and I'm looking forward to the native Pi binary coming out soon to see if it will work natively.
regards Simon
SimpleScratch on ScratchForums/ @cymplecy Twitter
Interfacing to external programs
Moderator: MSandro
Re: Interfacing to external programs
Nice to meet you, SimpleSi.
You've already discovered that the CloudData server is written in GP itself. The server pointed to by the cloud data blocks runs on a DigitalOcean server (only $5/month!). As you probably discovered, you can run GP headless by invoking it from the command line, and you've seen that the protocol used by the CloudData server is a simple binary message protocol implemented in 'messageServer.gp'.
Earlier today I pushed a new version of GP (v068) with a RaspberryPI executable. It should not need any non-standard libraries because I statically linked in libraries like SDL2, but it's possible I missed some dependency. Let me know it works for you.
I haven't explored how to access pins in the Raspberry Pi. Sounds like there is a Python API for that? GP can talk to a serial port, if that's of any use. However, since you've already got a server that understands the old Scratch 1.4 mesh networking protocol and talks to the pins, I agree it's probably easiest to have GP talk to that. I don't think it would be too difficult for someone like to you implement the Scratch protocol in GP, perhaps after studying the messageServer code as a model for how to use GP's socket API. Let me know if you need any help or advice.
Will you be at the Scratch conference in Bordeaux by any chance?
-- John
You've already discovered that the CloudData server is written in GP itself. The server pointed to by the cloud data blocks runs on a DigitalOcean server (only $5/month!). As you probably discovered, you can run GP headless by invoking it from the command line, and you've seen that the protocol used by the CloudData server is a simple binary message protocol implemented in 'messageServer.gp'.
Earlier today I pushed a new version of GP (v068) with a RaspberryPI executable. It should not need any non-standard libraries because I statically linked in libraries like SDL2, but it's possible I missed some dependency. Let me know it works for you.
I haven't explored how to access pins in the Raspberry Pi. Sounds like there is a Python API for that? GP can talk to a serial port, if that's of any use. However, since you've already got a server that understands the old Scratch 1.4 mesh networking protocol and talks to the pins, I agree it's probably easiest to have GP talk to that. I don't think it would be too difficult for someone like to you implement the Scratch protocol in GP, perhaps after studying the messageServer code as a model for how to use GP's socket API. Let me know if you need any help or advice.
Will you be at the Scratch conference in Bordeaux by any chance?
-- John
Re: Interfacing to external programs
Thanks for the info - I'll look into your suggestions :)
Won't be going to Bordeaux unfortunately :(
Won't be going to Bordeaux unfortunately :(
Re: Interfacing to external programs
I understand the the IO pins on the Raspberry Pi can be controlled by writing to certain files. If that's the case, GP can control them directly, since GP has file read and write commands. (They are in the "Words" category.)
If you need to read and write binary data to work with the I/O pins, that's possible by might require using some normally hidden features. If you need help with this, let me know. I'll be busy preparing for and attending the Scratch conference the next two weeks, so I can't dig in and help, but I can at least point you in the right directions...
If you need to read and write binary data to work with the I/O pins, that's possible by might require using some normally hidden features. If you need help with this, let me know. I'll be busy preparing for and attending the Scratch conference the next two weeks, so I can't dig in and help, but I can at least point you in the right directions...