VirtualSerial is a RS232 Serial console with integrated LUA scripting capability that can send and receive on the attached serial port.
It supports an input and output log, different encoding and buffer strategies, a dark mode (Bloomberg style) as well as saving and loading session history and serial port presets.
For example you may wish to compile and execute the following script:
setbuffer("STOP", "OD")
connect(57600, "ODD", "1", "5", 100, 100)
send("GET TX HELP")
Receive("GET TX HELP", func (response)
print("we got something! " . response)
end)
Assuming this is a RS232 protocol where the receiver to the message responds with command + response, at compile time this will attach a receive event to the script to receive data matching the string “GET TX HELP”
Then when you run the script this will set the serial port buffer mode with setbuffer
and then connect
the serial port and send the TX instruction GET TX HELP
The most useful part of this program for sure is the ability to load and then execute different scripts from the LUA environment, automatically encoded in the preffered byte encoding scheme. The lua environment has access to send and receive, as well as loading and saving files to the computer.
This in my use case – and the reason for it’s creation (aside the general learning to do so) wa it’s uses to commission devices by loading the premade script and executing it to send all commands to set the device up – with an easily debuggable output
Unlike other toolbelts with a featurelist the length of your arm – and therefore unpredictability this contains all the features I need to reliably program basic components in a one-shot capacity with the scripts created per the reference scripting manual for the device.
Main features:
Settings > Dark Mode
Dark mode! Lets you see in a lovely bloomberg black.
Session > Load / Save Preset
Loads or saves the current connection settings to a config file. I added this as I got very bored of having to set the same settings between debugging efforts to the code.
Session > Load / Save Session
Console > Input Text
Console > Input Hex
Console > I/O History
Connection > Buffer Mode
With the following avaliable options of "Line Buffer, Raw, Stopcode Buffer"
this lets the user select different buffer modes.
- Raw – This sends the current contents in the port buffer immediately to the terminal and the running script windows
- Line buffer – This sends the buffer delimited by \n to the terminal and running script windows
- Stopcode buffer – This sends the buffer delimited into lines by the stopcode text input, the stopcode is parsed as hex encoded bytes
Connection > Buffer Mode > Stop Code Line Ending detection
This feature came about as I found during testing that many RS232 programs on the client devices often don’t return correctly formatted responses.
For example the on the CYP SY 70 Slim Pro Video Transmitter the command:
GET TX HELP\n
Returns a list of all the functions on this firmware version and their acceptable arguments, however the transmitter doesn’t return a line feed character at the end of the response – this causes any subsequent response to fail if read by the baked in get line function:
SerialPort.Readline
(https://learn.microsoft.com/en-us/dotnet/api/system.io.ports.serialport.readline)
Instead of this problem with readline expectations you can just change the stopcode field to the expected needs of the response.