# Javascript Function to Process Modbus Values not Running on Edge Compute

**URL:** <https://forums.losant.com/t/javascript-function-to-process-modbus-values-not-running-on-edge-compute/5168>\
**Category:** Bug Report\
**Tags:** edge, modbus\
**Created:** [July 27, 2023, 5:11pm UTC](https://forums.losant.com/t/javascript-function-to-process-modbus-values-not-running-on-edge-compute/5168 "2023-07-27T17:11:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michael\_Murdy](https://avatars.discourse-cdn.com/v4/letter/m/c57346/32.png) [@Michael\_Murdy](https://forums.losant.com/u/Michael_Murdy)\
**Post date:** [July 27, 2023, 5:11pm UTC](https://forums.losant.com/t/javascript-function-to-process-modbus-values-not-running-on-edge-compute/5168/1 "2023-07-27T17:11:42Z")

</div>

Hi Losant Team: I have a need to process incoming 16bit ints from a modbus device into 32bit integers and floats. I have put together a Javascript function that works in the application workflows, but times out when run on the edge.

Is this a bug or intended behavior? If intended, why does the edge workflow timeout overall (not the function node)?

This can be tested with the following function simply using a virtual button, function node, and a debug node.

```auto
let measuredValueLowWord = 18417; // 16-bit value at offset 4
let measuredValueHighWord = 8293; // 16-bit value at offset 5
let measuredValue32Bit = (measuredValueHighWord << 16) | measuredValueLowWord;

let buf = new ArrayBuffer(4)
let ints = new Uint16Array(buf)
ints[0] = measuredValueHighWord
ints[1] = measuredValueLowWord
let convertToFloat = new Float32Array(buf)
let measuredValue32Float = convertToFloat[0]

console.log(measuredValue32Float)
console.log(measuredValue32Bit)

```

---

<div class="post-metadata">

**Author:** ![Sebastian\_Turner](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/sebastian_turner/32/4024_2.png) [@Sebastian\_Turner](https://forums.losant.com/u/Sebastian_Turner)\
**Post date:** [July 27, 2023, 6:55pm UTC](https://forums.losant.com/t/javascript-function-to-process-modbus-values-not-running-on-edge-compute/5168/2 "2023-07-27T18:55:31Z")

</div>

Hi @Michael_Murdy !

I am able to execute this script (using a Virtual Button → Function Node → Debug workflow) in both an Application and an Edge workflow without it timing out. The Edge workflow completes in about 9ms.

To clarify, is it timing out on your Edge device with just a Virtual Button → Function Node → Debug workflow, or do you have other nodes preceding the Function Node?

---

<div class="post-metadata">

**Author:** ![Michael\_Murdy](https://avatars.discourse-cdn.com/v4/letter/m/c57346/32.png) [@Michael\_Murdy](https://forums.losant.com/u/Michael_Murdy)\
**Post date:** [July 27, 2023, 8:27pm UTC](https://forums.losant.com/t/javascript-function-to-process-modbus-values-not-running-on-edge-compute/5168/3 "2023-07-27T20:27:31Z")

</div>

Interesting. Thank you for testing @Sebastian_Turner. Correct - no other preceding nodes. I pulled everything to a separate path. I also just tried on a clean workflow and deployed it to the device. It is running version 1.39. Not sure if that might be an issue.

I’ll follow up with you by email with the device specifics in case you want to check it out further.
