Discuss Scratch

mactro
Scratcher
28 posts

Scratch 2.0 extension - wait block not waiting

Hi,

I'm making an extension to Scratch 2.0 that will allow me to control a robot via Bluetooth. Everything works well except waiting block. I would like to have a block that tells robot to rotate a motor for a specified angle (360 degrees for example) and wait until the rotation is completed. Unfortunately, the mechanism described here: http://wiki.scratch.mit.edu/w/images/ExtensionsDoc.HTTP-9-11.pdf doesn't work.

When my program receives wait command it saves its ID and prints it in the poll response with the “_busy” prefix, until the command completes, but Scratch seems to ignore it completely, and immediately goes to next command. Has anyone managed to make an extension that uses wait blocks? What can be wrong?
itchy20
Scratcher
100+ posts

Scratch 2.0 extension - wait block not waiting

This is not surprising since the hardware extensions are “experimental”. You might want to take a look at Snap!. It has a powerful “Make a block” feature where you might be able to create a block that waits for a specific reporter block to return from your robot before relinquishing control. With Snap! you could even put a watchdog timer in your custom block and if it times out, generate an exception which will outline the executing block in red, indicating the exception. I have found that Snap! is a lot more stable than Scratch in relation to the hardware extensions.
blob8108
Scratcher
1000+ posts

Scratch 2.0 extension - wait block not waiting

It works for me. What does your code look like? What version of the offline editor are you using?

tosh · slowly becoming a grown-up adult and very confused about it
mactro
Scratcher
28 posts

Scratch 2.0 extension - wait block not waiting

I want to use this extension in school, with kids aged 11-12. Snap is a bit too complicated for them. Besides when I tried s2a extension for Arduino it didn't work at all, in any browser, while with Scratch there was no problem.

I created a bare minimum project, to test waiting block and uploaded it to Github: https://github.com/mactro/wait_test It is written in QtCreator with Qt5 libraries. It has only one block that should wait for five seconds. If you first send a command from Scratch and then open http://127.0.0.1:50231/poll in your browser you will find that _busy line appears with unique Id, and vanishes after five seconds, so I guess it's ok on that side.

Below you will find JSON code for the extension:

{
“extensionName”: “Wait - test”,
“extensionPort”: 50231,
“url”: "http://www.trobot.pl“,
”blockSpecs“: [
[
”w“,
”Wait five seconds“,
”wait_test",
]
]
}
blob8108
Scratcher
1000+ posts

Scratch 2.0 extension - wait block not waiting

mactro wrote:

https://github.com/mactro/wait_test It is written in QtCreator with Qt5 libraries
I don't see any HTTP code there at all.

tosh · slowly becoming a grown-up adult and very confused about it
mactro
Scratcher
28 posts

Scratch 2.0 extension - wait block not waiting

Ooops Now should be ok.
blob8108
Scratcher
1000+ posts

Scratch 2.0 extension - wait block not waiting

Hmm, re-testing with the latest Scratch 2 offline editor, blocking reporters do seem to be broken. Are you using v385?

tosh · slowly becoming a grown-up adult and very confused about it
mactro
Scratcher
28 posts

Scratch 2.0 extension - wait block not waiting

When I click “check for updates”, it says that I have a current version. Where can I check the version number?
itchy20
Scratcher
100+ posts

Scratch 2.0 extension - wait block not waiting

Look in the upper left corner right below the blue player maximize button.
mactro
Scratcher
28 posts

Scratch 2.0 extension - wait block not waiting

Aaah, haven't noticed that. So yes, I'm using v385.
itchy20
Scratcher
100+ posts

Scratch 2.0 extension - wait block not waiting

@mactro
When you say s2a_fm did not work with Snap! at all, could you please give me some more detail. In what way did it not work?
I assume that starting s2a_fm succeeded in the console, since you were able to work with Scratch.
Did you see the new blocks after importing the .xml file when working with Snap!?
If you did, did they execute when used?
If not, were there any exceptions or messages on the console or in the log file?

Thanks.
mactro
Scratcher
28 posts

Scratch 2.0 extension - wait block not waiting

I tested it again and:
- in Chrome I can't use Snap - the dropdown menus don't work for me
- in Firefox I get an error saying that script http://snap.berkeley.edu/snapsource/morphic.js:7621 stopped working when I try to import s2a project
- in IE the block loaded fine, but the extension did not connect to the server - the blocks did not execute. Moreover, when I tried to exit console app by Ctrl+C nothing happened. I had to close console window to terminate the app. There were no exceptions on the console nor in the log.
itchy20
Scratcher
100+ posts

Scratch 2.0 extension - wait block not waiting

@mactro
Thanks for testing. What operating system are you using? I know there are some problems with Android (and maybe that means chrome books - but not sure about those).

It should work with Linux, Windows and Mac without issue.

mactro
Scratcher
28 posts

Scratch 2.0 extension - wait block not waiting

Win 7 64 bit
itchy20
Scratcher
100+ posts

Scratch 2.0 extension - wait block not waiting

@mactro
Wow you have me stumped. Are you running via the internet or locally?. What version of s2a_fm are you using - it will print the version to the console after you start s2a_fm.

What happens if you just try loading the .xml file into Snap! without running s2a_fm. Is the behavior different (either crashes or not being able to drop down the menus)?

Just to make sure, is this the order of operations you are using when you are using s2a_fm?



Thanks


mactro
Scratcher
28 posts

Scratch 2.0 extension - wait block not waiting

@itchy20
I use s2a_fm v.1.2. I've always run the python app first, then loaded plugin in Snap!, but changing this order didn't make things any better - I still receive the error message.

And just to clarify - in Chrome I can't use dropdowns even before loading any extension, so it's plainly a Snap! issue.

BTW, this got a little off-topic
TangoZ
New to Scratch
7 posts

Scratch 2.0 extension - wait block not waiting

Hi,

I would like to come back to this subject.

When I add a classic “Command block”, Scratch sends the right REST request (GET /say/hello) to the extension application. Great!

However, when I add a “Command block that waits” (type w), Scratch does not send any request over the net when it hits the w-block on the GUI. It looks like the w-block is simply ignored, from the extension application point of view.

On the Scratch screen however, the entire program block is highlighted in yellow indicating that it's waiting, but no REST command hits my extension application. The w-bock appears well in the “More Blocks” section.

I'm using Offline Scratch 2 v404 (latest), Windows 7, AIR.

Do you have made the same examination? Are they any plans to fix this in the near future?

Thanks in advance,
Tango
blob8108
Scratcher
1000+ posts

Scratch 2.0 extension - wait block not waiting

TangoZ wrote:

the w-block is simply ignored
Yeah, it's a bug.

tosh · slowly becoming a grown-up adult and very confused about it
TangoZ
New to Scratch
7 posts

Scratch 2.0 extension - wait block not waiting

Is there a way to report bugs?
mactro
Scratcher
28 posts

Scratch 2.0 extension - wait block not waiting

Powered by DjangoBB