Jump to content

therealhanuta

Members
  • Posts

    17
  • Joined

  • Last visited

1 Follower

Recent Profile Visitors

367 profile views

therealhanuta's Achievements

Seeker

Seeker (1/7)

6

Reputation

  1. Hi Melba23, I have found a solution. It is not best, because it use AdlibRegister. But it works fine. #include <Debug.au3> _DebugSetup() AdlibRegister("Debug_ReportWindowWaitClose") For $i = 1 To 100 _DebugReport($i) Sleep(100) Next Func Debug_ReportWindowWaitClose() If Not $__gbReportWindowWaitClose_Debug Then Return 0 ; use of the already opened window so no need to wait Local $nOld = Opt("WinDetectHiddenText", True) Local $hWndReportWindow = WinGetHandle($__gsReportTitle_Debug, $__gsReportWindowText_Debug) Opt("WinDetectHiddenText", $nOld) $nOld = Opt('GUIOnEventMode', 0) ; save event mode in case user script was using event mode Local Const $GUI_EVENT_CLOSE = -3 Local $aMsg While WinExists(HWnd($hWndReportWindow)) $aMsg = GUIGetMsg(1) If Not $aMsg[0] Then ExitLoop If $aMsg[1] = $hWndReportWindow And $aMsg[0] = $GUI_EVENT_CLOSE Then GUIDelete($hWndReportWindow) Exit EndIf WEnd Opt('GUIOnEventMode', $nOld) ; restore event mode EndFunc
  2. Hi thoms, you are right. separator is no longer returned CommObsolete.au3 is created for backward compatibility
  3. Hi thoms, thanks for your solution. I have taken your approach and have made some changes. I have replaced ReceiveData & ReceiveLine with ReceiveBinary & ReceiveString. To read only one byte: _CommAPI_ReceiveByte($hFile, 1, 1) To read a line: _CommAPI_ReceiveString($hFile, 1, 0, @CRLF)
  4. Hi thoms, I can't find any error. For me COM10 is working fine. Are you using function _CommAPI_OpenPort or _CommAPI_OpenCOMPort? Func _CommAPI_OpenPort(Const $sMode) Local $sFileName = "\\.\" & StringLeft($sMode, StringInStr($sMode, ":") - 1) Local $hFile = _WinAPI_CreateFile($sFileName, 3, 6) Line 103 is responsible for COM ports greater than 9.
  5. Hi thoms, I fixed @error handling, but I can't help you to create an example, because I have never used this function. Maybe this can help you to create an examples for us: http://www.codeproject.com/Articles/2682/Serial-Communication-in-Windows (Search for WaitCommEvent)
  6. Hello Marcsf73, I have added a similar function, now. An example you can find here: http://www.autoitscript.com/wiki/CommAPI_Examples#Separator Hello adom, here you can find the changelog: http://www.autoitscript.com/wiki/CommAPI#Changelog
  7. Hi everybody! You can found this constant in file "C:\Program Files (x86)\AutoIt3\Include\FileConstants.au3". I thought that I could use it for Execute + Read + Write. But I have just realized that I was wrong. Now, I have changed this line to increase compatibility for all. Using of $iShare = 2 + 6 has now effect for serial communication. The modified line is therefore as follows: Local $hFile = _WinAPI_CreateFile($sFileName, 3, 6)
  8. Please, have a look into documentation: ; Name ..........: _CommAPI_ReceiveData ; Description ...: Receives data (RxD/RX/RD) to a specified communications device. ; Syntax ........: _CommAPI_ReceiveData(Const $hFile[, $iTimeout = 0]) ; Parameters ....: $hFile - [in] A handle to the communications device. ; $iTimeout - [in] An integer value for total read timeout in milliseconds. ; Return values .: Success - Received string ; Failure - Empty string ; Author ........: ; Modified ......: ; Remarks .......: If the result contains Chr(0), you should convert the result with function Binary(). Local Const $sToken = "<CR>" Local $sResult = "" Local $iPosition = 0 Do $sResult &= _CommAPI_ReceiveData($hFile) $iPosition = StringInStr($sResult, $sToken) If $iPosition > 0 Then MsgBox(0,0,StringLeft($sResult,$iPosition-1)) $sResult = StringMid($sResult,$iPosition+StringLen($sToken)) EndIf Until Not $sResult And $iPosition
  9. Some new changes: Rename CommAPIStructures.au3 to CommAPIConstants.au3 Replace hex values with Constants
  10. 15 is sum of PURGE_TXABORT, PURGE_RXABORT, PURGE_TXCLEAR and PURGE_RXCLEAR. More details you can find here: http://msdn.microsoft.com/en-us/library/aa363428(v=vs.85).aspx 5000 means a max timeout of 5 seconds. I think you are using an old version. One month ago I changed timeout handling. You have to use build in String functions like StringRegExp or StringInStr.
  11. Hi sulfurious, there are 3 useful tools.that I use: command MODE in command line (it shows you the current settings of COM ports) HTerm as a better HyperTerminal (German developer site, but English GUI) Null-modem emulator com0com (virtual serial port driver for test purposes) First, try following steps: run MODE run HyperTerminal run MODE again compare both results if there is a different, this is the solution If there is no different, try application HTerm. Play with options "CTS Flow control", DTR and RTS.
  12. No, you have to close port before you can use _CommAPI_OpenCOMPort again. Instead of this you can use function _CommAPI_ChangeCommStateElement. Or you can use _CommAPI_BuildCommDCB in combination with _CommAPI_SetCommState. No, because I use only DLL calls and no COM object. You habe to check @error after every function. I would expect, that @error is set when you try to transmit or receive data. Unfortunately I habe no USB-to-serial converter to test this.
×
×
  • Create New...