2600S-901-01 Rev. C / January 2008 Return to Section Topics 12-47
Series 2600 System SourceMeter® Instruments Reference Manual Section 12: Instrument Control Library
serial.parity
Attribute Parity for the RS-232 port.
Usage parity = serial.parity -- Reads parity.
serial.parity = parity -- Writes parity.
Set parity to one of the following values:
"none" or serial.PARITY_NONE Selects no parity.
"even" or serial.PARITY_EVEN Selects even parity.
"odd" or serial.PARITY_ODD Selects odd parity.
Remarks • A new parity setting takes effect when the command to change it is processed.
• The user should allow ample time for the command to be processed before attempting to
communicate with the instrument again. It is recommended that the parity be set from the
GPIB interface or from the front panel.
• The parity setting is stored in non-volatile memory. The reset function has no effect on
parity.
Details See “RS-232 interface operation” in Section 11.
Also see serial.baud, serial.databits, serial.flowcontrol
Example Sets parity to none:
serial.parity = serial.PARITY_NONE
serial.read
Function Reads data from the serial port.
Usage data = serial.read(maxchars)
maxchars Sets the maximum number of characters to
read.
data Returns a string consisting of all data read from
the serial port.
Remarks • This function will read available characters from the serial port. It will not wait for new
characters to arrive. As long as maxchars is a relatively small number (less than several
hundred characters), all characters received by the serial port prior to the call will be
returned. This might be less than maxchars. If too many characters are received in
between calls to this function, the RS-232 buffers will overflow and some characters may
be lost.
• This function can be called as many times as necessary to receive the required number
of characters. For optimal performance, it is suggested that a small delay be used
between repeat calls to this function.
• The data returned is the raw data stream read from the port. Control characters,
terminator characters, etc. will not be processed nor will the data stream be altered in any
way.
• This function cannot be used if the serial port is enabled as a command interface. A
settings conflict error will be generated if the serial port is enabled as a command
interface when this function is called.
Also see serial.write
Example Reads data from the serial port:
data = serial.read(200)
print(data)
Output: John Doe
The above output indicates that the string “John Doe” was read from the serial port.
serial.write
Function Writes data to the serial port.
Usage serial.write(data)
data Specify the data string to write.