File Exchange

image thumbnail

Realterm communications suite

version 1.52 (11 KB) by

Use Realterm the way you can using the MATLAB "serial" commands and instrument control toolbox.



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.
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, captureFileID)
Closes and cleans up

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, 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.

Comments and Ratings (1)

Taylor Hearn

You have a number of user-defined functions in this package that are not included in the package.



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


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.


Updated description


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


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

MATLAB Release
MATLAB 7.1.0 (R14SP3)

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video