A computer program establishes an interface between the MATLAB software and the serial data port of a personal computer (PC) that runs either the Windows 95 or the Windows NT operating system. The program makes it possible to utilize the graphical user interface (GUI) and the data-acquisition, control, and data-analysis capabilities of MATLAB while sending or receiving data via the RS-232 serial port. The data in question can be exchanged with external serial-communicating electronic circuitry, which could include another personal computer.

From the MATLAB command line or GUI, the user can initialize a serial-port session, cause the PC to write a byte to (or receive a byte from) the port, then terminate the session. The program provides a single command, "SerIO('x')," that acts in one of five different ways, depending upon which of four allowable values of the parameter x is specified:

  • "SerIO('i')" initializes a Windows 95 or NT serial-port communication interface.
  • Once initialization has been accomplished, "byte=SerIO('r')" utilizes a Windows 95 or NT kernel to read a single byte from the serial port and returns the value of the byte in "byte."
  • "SerIO('w',byte)" utilizes the kernel to write the byte parameters to the serial port.
  • "SerIO('d')" destroys the Windows 95 or NT serial-port handle that was created by "SerIO('i')" and used for reading and/or writing.
  • "SerIO('?')" can be used to ask whether initialization has been performed.

An important feature of this program that helps to distinguish it from programs developed previously for the same purpose arises from the use of the Windows 95/NT kernel calls instead of direct inputs to and outputs from the hardware address of the serial port. This feature is advantageous in that it provides for a better behaved communication interface.

The program utilizes the Microsoft Visual C/C++ compiler in conjunction with the external-file-development capabilities of MATLAB. The program implements 4,096-byte transmitting and receiving buffers that enable communication between systems with varying transmission speeds. The program can readily be modified to return a vector of data (in contradistinction to a single byte) to the MATLAB software environment in order to accelerate or off-load MATLAB processing.

This work was done by Brandon Dewberry of Marshall Space Flight Center. For further information, contact Larry Gagliano, MSFC Software Release Authority, at (256) 544-7175 or This email address is being protected from spambots. You need JavaScript enabled to view it..

MFS-31391


NASA Tech Briefs Magazine

This article first appeared in the April, 2000 issue of NASA Tech Briefs Magazine.

Read more articles from the archives here.