Thanks for your help Martin!
I had to fiddle with code a bit to get it to work. One cool thing is that I can char as the array type and directly passing the entire string in one shot. It works pretty well, but I had to use the "align 1" command to get it to work. Without that it would output all kind of garbage on the serial line.
Thanks again. What a great UDF!
$LastPacketTx = $APIPacket
$APIPacketLength = StringLen($APIPacket)
_CommSwitch($Port)
If _CommPortConnection() == '' Then
Output("Error: Comm port error")
Return
EndIf
$ByteArray = DllStructCreate("align 1;char[" & string($APIPacketLength) & "]")
DllStructSetData($ByteArray, 1, $APIPacket)
;send the bytes
_CommSendByteArray(DllStructGetPtr($ByteArray), $APIPacketLength,1)
if @error then output('_CommSendByteArrray failed')