25 Locust St, Haverhill, Massachusetts 01830 • Tel: 800/252-7074, 978/374-0761 • FAX: 978/521-1839
e-mail: [email protected] • Web Address: http://www.freqdev.com
SPPDF-01 Development Suite
User’s Manual
Software Plug
Appendix B
9.1.6. WriteCommPort:
Purpose:
To write the specified number of bytes to the output queue.
Algorithm:
Writes Count bytes to output queue of specified port. Returns an
integer indicating number of bytes placed in queue.
Syntax:
[data, status] = RS232MEX(action, [CommPort, Buffer, Count])
Parameters:
int CommPort - communication port to operate on
char Buffer – variable in which the data to be written to the selected
port is stored
int Count – number of bytes to write
Example:
% assign values to the structure element
dataelement = [hex2dec('85') hex2dec('84')];
parameter2.port = 2;
parameter2.data = uint8(dataelement );
parameter2.count = 2;
[result, condition] = RS232MEX('WB', parameter2)
[result, condition] = RS232MEX('wb', parameter2)
9.1.7. ReadToFile:
Purpose:
To read from the input queue until either the requested number of
bytes is satisfied or the termination byte is encountered, and to store
them in a file.
Algorithm:
Reads from input queue of specified COM port and writes data to file
specified by FileHandle. Bytes are read from input queue until Count
is satisfied, Termination Byte is encountered, or an error occurs.
Returns number of bytes successfully written or an error code if an
error occurs.
Syntax:
[data, status] = RS232MEX(action, [CommPort, FileHandle, Count,
TerminationByte])
Parameters:
int CommPort - communication port to operate on
int FileHandle – handle of the file to which the data is written
int Count – number of bytes to read from the selected port
int TerminationByte – byte value used to terminate the read
29