convert (serial read) reporter not implemented in Pico-W vm

Issue #455 resolved
SC Spaeth created an issue

I am trying to get my Micro:bit v2 to communicate with my PicoBricks board over serial. I can successfully send and convert data from PicoBricks to Micro:bit. But when I try to send data from Micro:bit to PicoBricks, I successfully receive the intended byte arrary on PicoBricks. But when I try to convert that byte array to a useful number, I get this error message from the PicoBricks script. Is this expected behavior? I have tried various work-around approaches to making the conversion but so far nothing seems to work. Recommendations?

Comments (5)

  1. John Maloney repo owner

    The error suggests that the firmware on your PicoBricks is not current. In fact, any use of the "covert" block will give that error with older firmware.

    But there's another problem, which is that the "convert" blocks does not covert byte sequences into numbers except for one case: a byte array with a single byte, in which case it returns that the value of that byte (0-255).

    So, once you've updated the firmware, you'll get the error "Error: Cannot convert that to an integer".

    The receiver had to decode the integer based on how it was encoded by the sender. For example, if the integer was converted to a string like "123" that was sent via serial then the receiver could first convert the byte array to a string, then convert the string to a number.

    In most cases, I find it helpful to encode messages as human-readable strings. For example, if you want to send three numbers you can use "join" to create a string with those three numbers separated by spaces. On the receiving side, you can use "split" to break the message into three strings, then use convert to convert each string back into a number.

    Hope that helps!

  2. SC Spaeth reporter

    Correct diagnosis and prescription! I was using a byte array with a single item but it needed the updated firmware. What should I look for in the future so that I can make that diagnosis on my own? Thank you.

  3. John Maloney repo owner

    You can use the "firmware version" command in the gear menu to get the firmware version on the board. You can check the latest firmware by looking the "Release Notes" on the Downloads page for either the stable release or the pilot release. The firmware version is the "VM" (virtual machine) version. For example, the firmware version is 210 for the current stable release:

    IDE 1.2.46 VM 210

  4. Log in to comment