Hi Everyone,
I have a question about how shoud my function look to return hex bytes from com port. At this moment it returns number of bytes that have been read but where they go ? How to access them ? It would be perfect if they were returned as a hex string.
I'm sending data like "0xBCFD0101000000AE"
It should return "0xBCFD02000000FFAE" <- i want this to be returned as a result of function
Func SendAndRead($data, $numBytesToRead, $readType = 1)
$bBinData = Binary($data)
$iNumbytes = BinaryLen($bBinData)
$tBinData = DllStructCreate("byte["&$iNumbytes&"]")
DllStructSetData($tBinData, 1, $bBinData)
$iRet = _CommSendByteArray(DllStructGetPtr($tBinData),$iNumbytes,1)
If (@error Or $iRet = -1) And $Initialized = 1 Then MsgBox($MB_SYSTEMMODAL, "Error while sending", "!Error: " & @error, 1)
$iRet = _CommReadByteArray(DllStructGetPtr($tBinData),$numBytesToRead,$readType)
If (@error Or $iRet = -1) And $Initialized = 1 Then
MsgBox($MB_SYSTEMMODAL, "Error while reading", "!Error: " & @error, 1)
Finalize()
EndIf
Return $iRet
EndFunc
Anyone can help ?
Thanks !