Hi,
Would like to use two serial ports and hopefully Mach4 has fixed the Mach3 limitation of 1 serial port.
In Mach3 and VB script you can use more than one serial port:
Sub Main()
Const MyPort = 1 ' COM1
Const MyBaud = "57600" ' bps rate
Const MyThreshold = 6 ' how many characters to receive until done
Const comEvSend = 1 ' enumeration of comm events
Const comEvReceive = 2
Const comEvCTS = 3
Const comEvDSR = 4
Const comEvCD = 5
Const comEvRing = 6
Const comEvEOF = 7
Const comInputModeText = 0 ' enumeration of input mode constants
Const comInputModeBinary = 1
Set objTest = CreateObject ("MSCOMMLib.MSComm", "[/b]MSCommEvent_") ' second parameter (MSCommEvent_) +
' name of event (OnComm) creates the
' event handler that is called when
' the event fires
objTest.CommPort = MyPort ' select a port to use
objTest.InputLen = 0 ' if = 0, will retrieve all waiting chars
objTest.InputMode = comInputModeText ' causes Input() to return string (not array)
objTest.RThreshold = 2 ' must be non-zero to enable receive
objTest.PortOpen = TRUE ' open COM port for use
s = MyBaud & ",n,8,1" ' settings: baud,parity,bits,stop in BSTR
objTest.Settings = s ' send to COM port
msg = "Test Message "
objTest.Output = msg ' send test message out of port
objTest.PortOpen = FALSE ' close port
Set objTest = Nothing ' uninitialize reference pointer
REM ---------------------------------------------------------------------------
End Sub
Sub MSCommEvent_OnComm ' OnComm event handler
Select Case objTest.CommEvent
Case comEvReceive
rxCnt = rxCnt + objTest.InBufferCount
rxBuf = rxBuf & objTest.Input
If rxCnt >= MyThreshold Then
For i = 2 To MyThreshold Step 2
Next
flag = TRUE
rxCnt = 0
End If
Case Else
End Select
End Sub
not testet, but i think it should work.
Thomas