Realterm communications suite

Use Realterm the way you can using the MATLAB "serial" commands and instrument control toolbox.
1.3K Downloads
Updated 21 Aug 2017

View License

This is a package of files for using Realterm like you normally would with serial/fread/fprintf etc etc. from the instrument control toolbox. All files are prefixed "realterm".
rtObject = realterm(Serial Property/Value pairs)
Create a Realterm activeX control in the same manner as you would with serial(). Property/Value pairs can be in serial() format, or the native ActiveX implementation.
realtermfopen(rtObject)
Connects, creating a uniquely-named capture file for the data (used later).
realtermfopen(rtObject, captureFileName)
Same, but you specify the filename.
[captureFileID, captureFileID] = realtermfopen(...)
Returns the capture file information. Not necessary, but speeds up some of the later steps as the program won't need to fetch it every time.
realtermfclose(rtObject)
realtermfclose(rtObject, captureFileID)
Closes and cleans up
isrealterm(rtObject)
True/false if it is a valid Realterm object.

realtermfwrite(rtObject, message)
Sends a message to an rtObject.

realtermfprintf(rtObject, input, terminator)
Wrapped version of fwrite with support for a terminator (can be anything really).

realtermfread(rtObject/fileID/filename)
realtermfread(rtObject/fileID/filename, timeOut)
realtermfread(rtObject/fileID/filename, timeOut, maxCharacters)
realtermfread(rtObject/fileID/filename, timeOut, maxCharacters, precision)
Reads out from the rtObject. Inputs are similar to fread, but the first argument can be the rtObject, the capture file ID, or the capture filename. Default timeout (if unspecified or empty) is 5 seconds. maxCharacters is the maximum number of characters to read out. Precision is as in fwrite - the default is 'uchar'

realtermfscanf(rtObject/fileID/fileName, terminator, timeOut, outputFormat, maxCharacters)
The minimum number of inputs is the rtObject and the terminator. The default timeout is 5 seconds, and the output format is the same as in sscanf - a C language conversion specifier (can be empty to apply nothing). The maxCharacters is the maximum number of characters to be read out.

When reading information, the priority is the same as for serial commands, i.e. it will try to read the number of characters specified, OR up to the terminator, but will timeout if it takes too long.

bytesAvailable = realtermbytesavailable(rtObject/fileID/filename)
Returns the remaining bytes left to read out (comparable as get(serialObject, 'BytesAvailable')). Also doubles up as an improved version of feof (it doesn't update in MATLAB immediately if an external program is writing to a file, as Realterm would).

Enclosed are also:

fid = realtermfid(rtObject)
Returns the file ID for the capture file from rtObject.

fid = getfid(filename)
Returns the fid(s) for filenames in MATLAB. Filename can be a string, in which case fid is a 0xn array of file ids. If filename is a cell array of strings, then it returns a cell array of fids. If the file is not open, it returns [].

filename = createuniquefile(stem)
Generates a unique temporary filename from a supplied (optional) string stem.

rtObject = realtermserial(serialObject)
Returns an rtObject, using the existing serial object as a template for the configuration. The serial object cannot be connected.

tf = ispv(Property/Value pairs)
Checks that a set of property/value pairs is valid.

Cite As

Geoffrey Akien (2024). Realterm communications suite (https://www.mathworks.com/matlabcentral/fileexchange/26287-realterm-communications-suite), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R14SP3
Compatible with any release
Platform Compatibility
Windows macOS Linux
Categories
Find more on Instrument Control Toolbox Supported Hardware in Help Center and MATLAB Answers

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
1.53.0.0

Inclusion of missing files isserial.m and createuniquefile.m

1.52.0.0

Bugfix: added missing files "onoff" and "isnumberbetween"

1.51.0.0

Fixed a bug in fread with a specified number of bytes to read. Renamed isstring to isastring to avoid annoying warnings with the introduction of isstring in one of the newer toolboxes. Now tested up to R2015b.

1.4.0.0

Updated description

1.3.0.0

Tidied up a little, and added realtermfgetl as an analogue to fgetl.

1.2.0.0

Changed realterm.m to remove dependence on serial() - realterm now accepts both serial() and the ActiveX properties at the same time.

1.0.0.0