Properties and methods related to receiving data.
| Property | Definition |
|---|---|
| receive.isFrameStart | start of frame flag |
| receive.isHexDisplay | Whether Hex display |
| receive.isSaveToFile | whether to save to file |
| receive.isPauseReceivingDisplay | Whether to suspend receiving |
| receive.isAutoBreakFrame | Whether to automatically break the frame |
| receive.currentRowIsEmpty | Whether the current row of the receive window is empty |
| Method | Definition |
|---|---|
| receive.get() | refer to receive.getString() |
| receive.getString() | currently received string
1. Use the character encoding converted string () 2. String in Hex format (When hexadecimal display is enabled) |
| receive.getBytes() | Currently received byte array (raw data) |
| receive.write(string) | write a string to the display window string the string to send |
| receive.write(string,colorStr) | write a string to the display window
string the string to send colorStr color string. For example "red" "yellow" "#FF00FF00" |
| receive.clear() | Clear the receive window |
| receive.clearLastReceived() | Clear the last received data |
Properties and methods related to sending data.
| Property | Definition |
|---|---|
| send.isSendFile | Whether to send the file |
| send.isHexSend | Whether to send Hex |
| send.isTimingSend | Whether to send regularly |
| send.isDisplaySendString | Whether to display the sent string |
| Method | Definition |
|---|---|
| send.get() | currently sent string |
| send.getString() | currently sent string |
| send.getBytes() | Get the currently sent byte array |
| send.write(string) | send string |
| send.write(string,isHexStr) | Whether to send a string in HEX format
string the string to send isHexStr Whether the string is in hexadecimal style For example: send.write("AB CD 12",true);
|
| send.writeBytes(Array) | Send a byte array
Array Uint8Array array, other types will be converted to Uint8Array before being sent.
|
| send.writeToReceice(string) | Write a string from the sending script to the receiving window
It is recommended to use receive.write(string) |
| send.writeToReceice(string,color) | Write a string from the sending script to the receiving window
It is recommended to use receive.write(string,colorStr) |
The drawing control operation class, including the method of sending data to the drawing control
| Method | Definition |
|---|---|
| chart.write(formatStr) | Write data to the drawing control
formatStr String conforming to the drawing protocol For example: chart.write("line1=12.2\n");
chart.write("line1=100,line2=200\n");
|
| chart.write(name,datas) | Write data to the drawing control
name Waveform name datas Waveform data (supports numeric values, strings, and arrays) For example: chart.write("line1",100);
chart.write("line1","200");
chart.write("line1",[20,"10",50]);
|
Print debug information to the Output window
| Method | Definition |
|---|---|
| console.log(obj) | print to output window |
| console.dir(obj) | format print |
| console.error(obj) | error red |
| console.warn(obj) | warning dark green |
| console.write(obj,,,color) | print object
obj,,, supports multiple parameters color The last parameter can control the character color |
| console.time() | start the timer |
| console.timeEnd() | End the timer and print the elapsed time in the output window.
Use with console.time() to count the running time of the code |
Auxiliary tools
| Method | Definition |
|---|---|
| util.isNull(object) | Is it null |
| util.isUndefined(object) | Is it undefined |
| util.isNullOrUndefined(object) | is null or undefined |
| util.timeToString() | get time string h:m:s.ms |
| util.hexStringToBytes(string) | String to byte array
string hexadecimal format string "68 65 6C 6C 6F"
|
| util.bytesToHexString(bytes, isUpper = false) | Convert byte array to hexadecimal string
bytes byte array isUpper Uppercase letters (default lowercase letters) |
| util.bytesToInteger(buf, index, len, bigEndian = true) | Byte array to integer
buf byte array index start index len The integer occupies the number of bytes bigEndian Use big endian byte order |
| util.bytesTofloat(buf, index, bigEndian = true) | Convert IEEE754 float memory array (4 bytes) to float
buf byte array index start index bigEndian Use big endian byte order |
| util.types.isBoolean(object) | Is it a boolean type |
| util.types.isNumber(object) | Is it a number |
| util.types.isString(object) | Is it a string |
| util.types.isFunction(object) | Is it a function |
| util.types.isInt8Array(object) | is an array of 8-bit signed integers |
| util.types.isUint8Array(object) | is an array of 8-bit unsigned integers |
| util.types.isInt16Array(object) | Is it an array of 16-bit signed integers |
| util.types.isUint16Array(object) | Is it an array of 16-bit unsigned integers |
File operations
| Method | Description |
|---|---|
| file.exists(path) | Determine if the specified file exists
path File path |
| file.readText(path) | Read all the text in the file into a string
path File path |
| file.writeText(path, string) | Write a string to a file (UTF-8 encoding)
path File path string Text string |
| file.appendText(path,str) | Append a string to the end of a text (UTF-8 encoding)
path File path string Text string |
| file.readBytes(path) | Read the contents of a file into a byte array
path File path |
| file.writeBytes(path, bytes) | Write byte array to file
path File path bytes Byte array |
| file.appendBytes(path, bytes) | Add character byte array to the end of text
path File path bytes Byte array |
| file.getTempPath(path, bytes) | Return the path of the current user's temporary folder |
| file.delete(path) | Delete specified file
path File path |
| Method | Definition |
|---|---|
| alert(title, message) | Show alert box
title alert box title message alert box message |
| delay(ms) | Async delay (use with caution)
ms millisecond |
| sleep(ms) | Suspend a thread (use with caution)
ms millisecond |