ok, had to dig a bit deeper, this sendserial function look's like to be a bit bugy.
copy the attached DLL file to C:\Mach3 and use this code:
' *****************************************************************************************************
'
' Mach3 / Cypress Enable script code to use the ELEKTOR Serial.dll Dynamic Link Library for serial port
' communication and control from a Mach3 script.
'
' *****************************************************************************************************
' Pass in the portnumber to open (1 for COM1, 2 for COM2 etc). Get the port number in return if successfull.
Declare Function OpenCOM Lib "Serial.dll" (ByVal Port As Integer) As Integer
' Closes the opened port, no parameters to pass. Always returns 0.
Declare Function CloseCOM Lib "Serial.dll" As Integer
' Gets the Windows handle.
Declare Function GetHandle Lib "Serial.dll" As Integer
' Pass in a character to be sent. Datatype was declared as Char but no such type exists in Cypress, Integer seems to work if handled properly.
Declare Function SendCharCOM Lib "Serial.dll" (ByVal ch As Integer) As Integer
' Function expects an Integer sent as ByRef ("pointer to an integer") and returns TRUE if data is available
Declare Function ReadCharCOM Lib "Serial.dll" (ByRef ch As Integer) As Boolean
' Returns true if a COM port with the passed in number exists and is free to use.
Declare Function COMPortExists Lib "Serial.dll" (ByVal Port As Integer) As Integer
' Gets the port number of the currently opend port, zero if no port is opened (?)
Declare Function GetPortNr Lib "Serial.dll" As Integer
' 0=None, 1=odd, 2=even, 3=mark 4=space?????
Declare Function ParitySet Lib "Serial.dll"(ByVal par As Integer) As Boolean
' 4-8 are valid
Declare Function BitsPerByteSet Lib "Serial.dll" (ByVal pbp As Integer) As Boolean
' Any baudrate is valid, returns false if not possible.
Declare Function BaudRateSet Lib "Serial.dll" (ByVal BaudRate As Long) As Boolean
' 0=1 stopbit, 1=1.5 stopbit, 2=2 stopbits. (1.5 may not be valid on all hardware)
Declare Function StopBitsSet Lib "Serial.dll" (ByVal stp As Integer) As Boolean
' ************************** End of function declaration for the Serial.dll library ***********************************
Sub Main
On Error GoTo HandleIt
Dim TxChar As Integer
Dim TxString As String
Dim ComPort As Integer
ComPort =1
sendbyte1 = &H01
sendbyte2 = &H06
sendbyte3 = &H00
sendbyte4 = &H01
sendbyte5 = &H00
sendbyte6 = &H04
sendbyte7 = &HD9
sendbyte8 = &HC9
'try to open the Comport
If OpenCom(ComPort) <> ComPort Then ' Open COM port
MsgBox("Couldn't open COM port!!")
Result = CloseCom() ' Close the port.
Exit Sub ' Nothing left to do, exit
End If
ParitySet(0) ' Set parity to NONE
BitsPerByteSet(8) ' Set databits to 8
StopBitsSet(0) ' Set stopbits to 1
BaudrateSet(9600) ' Set baudrate to 9600
'send the byte's
SendCharCOM(Asc(Chr(sendbyte1)))
SendCharCOM(Asc(Chr(sendbyte2)))
SendCharCOM(Asc(Chr(sendbyte3)))
SendCharCOM(Asc(Chr(sendbyte4)))
SendCharCOM(Asc(Chr(sendbyte5)))
SendCharCOM(Asc(Chr(sendbyte6)))
SendCharCOM(Asc(Chr(sendbyte7)))
SendCharCOM(Asc(Chr(sendbyte8)))
Result = CloseCom() ' Close the port.
Exit Sub
' *************************************************************************************************************************
HandleIt:
' If an error occurs we must close the port or it will be left open and unusable.
MsgBox("An unexpected error occured. Closing comport and Exiting" & CloseCom())
Exit Sub
' *************************************************************************************************************************
End Sub