Skip to content

Scripting Overview ​

SerialStudio can be extended with scripts in two places. Both support Lua 5.4 and Python 3.13:

Checksum scriptFrame processing script
PurposeCompute the checksum of HEX data you sendTransform every frame you receive
Entry functioncalculate_checksum(data)process_frame(data)
Where in the UIThe Checksum drop-down in the send areaThe Frame Processing (帧处理) drop-down in the receive area
When it runsWhen sending in HEX mode, before the data is sentAfter received data is split into packets and before it is displayed
Python argumentByte data (convert it with bytes(data) first)bytes
Lua argumentAn array of integers (a table, indexed from 1)A string (raw bytes, may contain \0)
Is the script kept loadedNo, the script is reloaded for every calculationYes, it is loaded once and global variables persist between frames
When the script failsThe send fails and the error is shown in the receive boxThe failing frame is dropped and the error is shown in the receive box

The argument types differ

In Lua, a checksum script receives an array of integers, while a frame processing script receives a string. The entry functions of the two kinds of script are not interchangeable.

Choosing a script type ​

  • To append a checksum that the built-in algorithms do not provide to the data you send, use a checksum script.
  • To rewrite received data before it is displayed or saved, for example to strip headers and trailers, decode it, or filter heartbeat packets, use a frame processing script.

Common rules ​

  • Script files must be UTF-8 encoded. Lua scripts use the .lua extension and Python scripts use .py.
  • The entry function name must match the table above exactly. Otherwise loading the script fails with a "function not found" message.
  • After you pick a script, the program loads and checks it first, and enables it only if the check passes. When the check fails, the reason is printed in the receive box.