Win32_SerialPortConfiguration - WMI sample in Python

The foundations for Manageability in Windows 7/2008/Vista/XP/2000 and Millennium Edition/'98 are Windows Management Instrumentation (WMI; formerly WBEM) and WMI extensions for Windows Driver Model (WDM).

ActiveXperts Network Monitor provides the ability to build monitor check routines based on WMI. ActiveXperts has collected more than a hundred WMI samples. You can use these samples as a base for new check routines you can write yourself.

On this site, you can find many WMI samples.


Win32_SerialPortConfiguration

Description

The Win32_SerialPortConfiguration WMI class represents the settings for data transmission on a Windows serial port. This includes configurations for establishing a connection and error checking.

Example(s)

import win32com.client
def WMIDateStringToDate(dtmDate):
    strDateTime = ""
    if (dtmDate[4] == 0):
        strDateTime = dtmDate[5] + '/'
    else:
        strDateTime = dtmDate[4] + dtmDate[5] + '/'
    if (dtmDate[6] == 0):
        strDateTime = strDateTime + dtmDate[7] + '/'
    else:
        strDateTime = strDateTime + dtmDate[6] + dtmDate[7] + '/'
        strDateTime = strDateTime + dtmDate[0] + dtmDate[1] + dtmDate[2] + dtmDate[3] + " " + dtmDate[8] + dtmDate[9] + ":" + dtmDate[10] + dtmDate[11] +':' + dtmDate[12] + dtmDate[13]
    return strDateTime

strComputer = "."
objWMIService = win32com.client.Dispatch("WbemScripting.SWbemLocator")
objSWbemServices = objWMIService.ConnectServer(strComputer,"root\cimv2")
colItems = objSWbemServices.ExecQuery("SELECT * FROM Win32_SerialPortConfiguration")
for objItem in colItems:
    if objItem.AbortReadWriteOnError != None:
        print "AbortReadWriteOnError:" + ` objItem.AbortReadWriteOnError`
    if objItem.BaudRate != None:
        print "BaudRate:" + ` objItem.BaudRate`
    if objItem.BinaryModeEnabled != None:
        print "BinaryModeEnabled:" + ` objItem.BinaryModeEnabled`
    if objItem.BitsPerByte != None:
        print "BitsPerByte:" + ` objItem.BitsPerByte`
    if objItem.Caption != None:
        print "Caption:" + ` objItem.Caption`
    if objItem.ContinueXMitOnXOff != None:
        print "ContinueXMitOnXOff:" + ` objItem.ContinueXMitOnXOff`
    if objItem.CTSOutflowControl != None:
        print "CTSOutflowControl:" + ` objItem.CTSOutflowControl`
    if objItem.Description != None:
        print "Description:" + ` objItem.Description`
    if objItem.DiscardNULLBytes != None:
        print "DiscardNULLBytes:" + ` objItem.DiscardNULLBytes`
    if objItem.DSROutflowControl != None:
        print "DSROutflowControl:" + ` objItem.DSROutflowControl`
    if objItem.DSRSensitivity != None:
        print "DSRSensitivity:" + ` objItem.DSRSensitivity`
    if objItem.DTRFlowControlType != None:
        print "DTRFlowControlType:" + ` objItem.DTRFlowControlType`
    if objItem.EOFCharacter != None:
        print "EOFCharacter:" + ` objItem.EOFCharacter`
    if objItem.ErrorReplaceCharacter != None:
        print "ErrorReplaceCharacter:" + ` objItem.ErrorReplaceCharacter`
    if objItem.ErrorReplacementEnabled != None:
        print "ErrorReplacementEnabled:" + ` objItem.ErrorReplacementEnabled`
    if objItem.EventCharacter != None:
        print "EventCharacter:" + ` objItem.EventCharacter`
    if objItem.IsBusy != None:
        print "IsBusy:" + ` objItem.IsBusy`
    if objItem.Name != None:
        print "Name:" + ` objItem.Name`
    if objItem.Parity != None:
        print "Parity:" + ` objItem.Parity`
    if objItem.ParityCheckEnabled != None:
        print "ParityCheckEnabled:" + ` objItem.ParityCheckEnabled`
    if objItem.RTSFlowControlType != None:
        print "RTSFlowControlType:" + ` objItem.RTSFlowControlType`
    if objItem.SettingID != None:
        print "SettingID:" + ` objItem.SettingID`
    if objItem.StopBits != None:
        print "StopBits:" + ` objItem.StopBits`
    if objItem.XOffCharacter != None:
        print "XOffCharacter:" + ` objItem.XOffCharacter`
    if objItem.XOffXMitThreshold != None:
        print "XOffXMitThreshold:" + ` objItem.XOffXMitThreshold`
    if objItem.XOnCharacter != None:
        print "XOnCharacter:" + ` objItem.XOnCharacter`
    if objItem.XOnXMitThreshold != None:
        print "XOnXMitThreshold:" + ` objItem.XOnXMitThreshold`
    if objItem.XOnXOffInFlowControl != None:
        print "XOnXOffInFlowControl:" + ` objItem.XOnXOffInFlowControl`
    if objItem.XOnXOffOutFlowControl != None:
        print "XOnXOffOutFlowControl:" + ` objItem.XOnXOffOutFlowControl`