harbaum / ftduino

fischertechnik compatible arduino
31 stars 10 forks source link

[Scratch3] Analog input reading functions break with invalid ports. #7

Closed intrigus closed 4 years ago

intrigus commented 4 years ago

Used scratch file:

analog_input_broken.sb3.zip (You may have to remove the .zip to import it into scratch.

image

Expected behaviour:

Led goes on, then off, then on again and finally after reading from analog input (effectively discarding the result) it should go off again. Note that I'm reading from Port "0" which obviously is invalid.

Actual behaviour:

Led goes on, then off, then on again but the reading from analog input fails, so the led never goes off.

Error:

lib.min.js:270125 Uncaught (in promise) TypeError: Cannot convert undefined or null to object
    at Function.keys (<anonymous>)
    at Scratch3FtduinoBlocks.parse (lib.min.js:270125)
    at ./node_modules/scratch-vm/src/extensions/scratch3_ftduino/index.js.serial.Port.port.onReceive (lib.min.js:270200)
    at lib.min.js:269660
parse @ lib.min.js:270125
port.onReceive @ lib.min.js:270200
(anonymous) @ lib.min.js:269660
Promise.then (async)
readLoop @ lib.min.js:269659
(anonymous) @ lib.min.js:269662
Promise.then (async)
readLoop @ lib.min.js:269659
(anonymous) @ lib.min.js:269662
Promise.then (async)
readLoop @ lib.min.js:269659
(anonymous) @ lib.min.js:269685
Promise.then (async)
./node_modules/scratch-vm/src/extensions/scratch3_ftduino/index.js.serial.Port.connect @ lib.min.js:269684
connect @ lib.min.js:270179
(anonymous) @ lib.min.js:269872
Promise.then (async)
manualConnect @ lib.min.js:269869
onConnectClicked @ lib.min.js:269748

image

harbaum commented 4 years ago

Uhm ... I don't manage to get the variable into the ftDuino input block. How did you replace the I1/I2/... dropdown with the variable?

intrigus commented 4 years ago

I guess you solved this by updating your fork of scratch-vm. I now also can't reproduce my problem, so I'm closing this issue.