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.4. ReadCommPort:
Purpose:
To read the specified number of bytes from the input queue.
Algorithm:
Reads desired number of bytes from input queue of the specified port
and stores them in Buffer. Returns either on timeout or when Count
bytes have been read. Returns an integer value indicating the number
of bytes read from queue.
Syntax:
[data, status] = RS232MEX(action, [CommPort, Buffer, Count])
Parameters:
int CommPort - communication port to operate on
char Buffer – variable in which to store the data that was read from
the selected port
int Count – number of bytes to read from the selected port
Example:
% assign values to the structure element
dataelement = hex2dec(' ');
parameter4.port = 2;
parameter4.data = uint8(dataelement);
parameter4.count = 2;
[result, condition] = RS232MEX('RB', parameter4)
[result, condition] = RS232MEX('rb', parameter4)
9.1.5. WriteBytePort:
Purpose:
To write the specified byte to the output queue.
Algorithm:
Writes a byte to output queue of specified port. The byte written is the
low-order byte of the integer. Returns an integer whose value is 1 or
0, indicating the number of bytes placed in queue.
Syntax:
[data, status] = RS232MEX(action, [CommPort, Byte])
Parameters:
int CommPort - communication port to operate on
int Byte – specifies the value of the byte to be written to the selected
port.
Example:
%assign value to the structure element
dataelement = uint8(hex2dec('85'));
parameter2.port = 1;
parameter2.byte = dataelement;
[result, condition] = RS232MEX('WY', [parameter2])
[result, condition] = RS232MEX(‘wy’, [parameter2]);
28