You can use the handshake lines of the comm-ports. These lines are accessible with the MSComm object. On the PC-side the plug layout:
Pin1: DCD (inp)
Pin2: RX (not used)
Pin3: TX (not used)
Pin4: DTR (out)
Pin5: GND
Pin6: DSR (inp)
Pin7: RTS (out)
Pin8: CTS (inp)
Pin9: Ring (inp)
An example how to control these lines:
VB Code:
Private Sub Form_Load() 'Init CommPort If (MSComm1.PortOpen = False) Then MSComm1.CommPort = 1 MSComm1.Settings = "9600,N,8,1" MSComm1.Handshaking = comNone MSComm1.RThreshold = 1 MSComm1.PortOpen = True End If End Sub Private Sub Form_Unload(Cancel As Integer) MSComm1.PortOpen = False End Sub Private Sub cmdDTR_Click() 'Toggle DTR If (MSComm1.DTREnable = False) Then MSComm1.DTREnable = True Else MSComm1.DTREnable = False End If End Sub Private Sub cmdRTS_Click() 'Toggle RTS If (MSComm1.RTSEnable = False) Then MSComm1.RTSEnable = True Else MSComm1.RTSEnable = False End If End Sub Private Sub MSComm1_OnComm() Select Case MSComm1.CommEvent 'Events Case comEvReceive Case comEvSend Case comEvCTS 'CTS is changed. Check value If (MSComm1.CTSHolding = True) Then chkCTS.Value = 1 Else chkCTS.Value = 0 End If Case comEvDSR 'DSR is changed. Check value If (MSComm1.DSRHolding = True) Then chkDSR.Value = 1 Else chkDSR.Value = 0 End If Case comEvCD 'DCD is changed. Check value If (MSComm1.CDHolding = True) Then chkDCD.Value = 1 Else chkDCD.Value = 0 End If Case comEvRing 'Ring is changed. Can't check value If (chkRing.Value = 1) Then chkRing.Value = 0 Else chkRing.Value = 1 End If Case comEvEOF 'Errors Case comEventBreak Case comEventCDTO Case comEventCTSTO Case comEventDCB Case comEventDSRTO Case comEventFrame Case comEventOverrun Case comEventRxOver Case comEventRxParity Case comEventTxFull Case Else End Select End Sub




Reply With Quote