wiki:decoderupload
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| wiki:decoderupload [2023/07/28 17:49] – mbrauer | wiki:decoderupload [2023/07/28 18:10] (current) – mbrauer | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== Custom JavaScript Decoder Upload Requirements ====== | ====== Custom JavaScript Decoder Upload Requirements ====== | ||
| - | To ensure compatibility, | + | To ensure compatibility, |
| - | ===== Necessities for Uploading a Custom | + | ===== Example |
| - | *** Function Signature**: | + | Here's a simple example of a custom JavaScript |
| - | * Other functions can be used in the file can called from the Decoder function, but the Decoder(...) function acts as the main function. | + | |
| - | | + | <code javascript> |
| + | /** | ||
| + | * Custom decoder function for decoding data. | ||
| + | * @param bytes - The payload data to be decoded (an array of bytes). | ||
| + | * @param port - The port number | ||
| + | * @returns {string} - The decoded result as a string. | ||
| + | */ | ||
| + | function Decoder(bytes, port) { | ||
| + | // Your decoding logic here | ||
| + | let decodedResult = {}; //empty object that holds all UDT tag values | ||
| + | decodedResult.Measurement = bytes[0] | ||
| + | decodedResult.BatteryLevel = bytes[1] | ||
| + | decodedResult.Temperature = bytes[2] | ||
| + | return decodedResult; | ||
| + | } | ||
| + | </ | ||
| + | ===== Necessities for Uploading a Custom JavaScript Decoder ===== | ||
| - | - `bytes`: This parameter represents | + | *** Function Signature**: The decoder function must have the following signature: function Decoder(bytes, port) { //Your decoding logic here// } |
| - | - `port`: This parameter denotes the port number that might be used within | + | * Other functions can be used in the file can called from the Decoder |
| - | - **Dependency Management**: Ensure | + | |
| - | - **Runtime Limitations**: Be aware of the runtime limitations and constraints of GraalVM. For example, certain features or APIs available in other JavaScript engines may not be present in GraalVM. Refer to the GraalVM documentation for any restrictions you should consider while writing your custom decoder. | + | |
| - | - **Testing**: Before uploading | + | |
| - | ===== Example Custom Decoder Function ===== | + | - **Runtime Limitations**: |
| + | |||
| + | - **Testing**: | ||
| - | Here's a simple example of a custom JavaScript decoder function conforming to the specified function signature: | ||
| - | <code javascript> | ||
| - | function addNumbers(a, | ||
| - | return a + b; | ||
| - | } | ||
| - | </ | ||
wiki/decoderupload.1690566599.txt.gz · Last modified: 2023/07/28 17:49 by mbrauer