I've tried to send 4 byte message via MSComm control VB and in AutoIt. Message is "*A<msb><lsb>". This code works in VB with any value 0 or 1 in msb, and 0 to 255 in lsb.
.Output = "*A" & Chr(0) & Chr(ix)
In AutoIt this works, but not if either byte is zero, and not if lsb is 1.
$sAxName = "MSCOMMLib.MSComm.1"
$obj = ObjCreate($sAxName)
With $obj
.CommPort = 31
.Settings = "9600,N,8,1"
.PortOpen = True
.NullDiscard = False
.NullDiscard = True
.HandShaking = 0
.InputMode = 1
.DTREnable = True
.EOFEnable = False
.RTSEnable = True
EndWith
For $iCnt = 0 To 15
With $obj
.NullDiscard = False
$sMsg = "*A" & Chr(0) & Chr(Int($iCnt))
.Output = $sMsg
If $iCnt < 3 then
MsgBox(0, Default, $iCnt)
EndIf
EndWith
Sleep(200)
Next
You might expect .NullDiscard to be relevant. The VB works with this true or false, and I've tried both in AutoIt. It's possible that I have some other property different, but I've looked through them all.
I wonder if AutoIt is passing the whole string to the control, or stopping at the zero. I can't think how to prove that either way.
Chr(Int($iCnt)) works correctly for values > 2, but for 1 it doesn't do the same as Chr(1) - what am I missing here?