tinygo-org / tinygo

Go compiler for small places. Microcontrollers, WebAssembly (WASM/WASI), and command-line tools. Based on LLVM.
https://tinygo.org
Other
15.41k stars 909 forks source link

WASM: syscall/js.finalizeRef not implemented #1652

Open Nerzal opened 3 years ago

Nerzal commented 3 years ago

The error is a syscall/js.finalizeRef not implemented. It does not seem to disrupt the flow of my code, but we might want to implement it.

TinyGo Version:

tinygo version 0.17.0-dev linux/amd64 (using go version go1.16 and LLVM version 11.1.0)

Error: grafik

Exported function by:

    js.Global().Set("messageHandler", js.FuncOf(messageHandler))

Call in js:

    messageHandler(message.payloadString)

Function in wasm.go

func MessageHandler(this js.Value, args []js.Value) interface{} {
    println("mqtt: message received")

    message := args[0].String()

    splittedStrings := strings.Split(message, "#")

    temperature, err := strconv.ParseFloat(splittedStrings[4], 32)
    if err != nil {
        println("failed to parse temperature from message")
        println(message)
    }

    pressure, err := strconv.ParseFloat(splittedStrings[6], 32)
    if err != nil {
        println("failed to parse pressure from message")
        println(message)
    }

    humidity, err := strconv.ParseFloat(splittedStrings[8], 32)
    if err != nil {
        println("failed to parse humidity from message")
        println(message)
    }

    mqttMessages <- SensorEvent{
        TimeStamp:   splittedStrings[0],
        Message:     splittedStrings[2],
        Temperature: float32(temperature),
        Pressure:    float32(pressure),
        Humidity:    float32(humidity),
    }

    return nil
}
deadprogram commented 3 years ago

See discussion at https://github.com/tinygo-org/tinygo/issues/1140

Seems like still needs to be done! :smile_cat:

Nerzal commented 3 years ago

Oh sorry, should have searched first

deadprogram commented 3 years ago

Not at all, that info was a little buried unless doing a text search. I only did, because I recalled it existed. :mag_right: