Компьютерный форум OSzone.net  

Компьютерный форум OSzone.net (http://forum.oszone.net/index.php)
-   AutoIt (http://forum.oszone.net/forumdisplay.php?f=103)
-   -   [решено] Чтение из COM порта (http://forum.oszone.net/showthread.php?t=150176)

w3d1 10-09-2009 14:46 1215699

Чтение из COM порта
 
Как можно выставить таймауты для чтения ком-порта?
Нашел такое: http://www.autoitscript.com/forum/index.php?showtopic=45842&st=0&p=341916&#entry341916

там есть:
Код:

;gets characters received returning when one of these conditions is met:       
;receive @CR, received 20 characters or 200ms has elapsed       
$instr = _CommGetString()

не могу понять как увеличить время или количество символов и вообще убрать возврат по @CR.

Alex2103 10-09-2009 16:03 1215761

_CommGetString() возвращает строку. _CommReadByte() возвращает байт. Про время не понял...в том примере видимо _CommGetString() было в цикле с периодом в 200мс.

w3d1 11-09-2009 07:44 1216295

Вот она:

Код:

;================================================================================
;
; Function Name:  _CommGetstring()
; Description:    Get whatever characters are available received by the port for the selected channel
; Parameters:    none
; Returns:  on success the string and @error is 0
;          if input buffer empty then empty string returned
;          on failure an empty string and @error set to the error set by DllCall
; Notes: Use GetLIne to get a whole line treminated by @CR or a defined character.
;=================================================================================

Func _Commgetstring()
        ;get a string NB could be part of a line depending on what is in buffer
        Local $vDllAns
        ;$sStr1 = ''
        ;$vDllAns = DllCall($hDll,'str','GetByte')
        $vDllAns = DllCall($hDll, 'str', 'GetString')

        If @error <> 0 Then
                SetError(1)
                ConsoleWrite('error in _commgetstring' & @CRLF)
                Return ''
        EndIf
        Return $vDllAns[0]
EndFunc  ;==>_Commgetstring


Alex2103 11-09-2009 08:06 1216298

w3d1, смотри выше :)

w3d 11-09-2009 18:38 1216747

В том-то и дело, что цикла там нет

Вся проблема в том, что непонятно что в длл-ке (см первое сообщение) зашито, есть ли там эта настройка.
По обсуждению из http://www.autoitscript.com/forum/index.php?showtopic=45842&st=0&p=341916&#entry341916 не понял, а вопросы задавать - не настолько хорошо английский знаю.

w3d1 18-09-2009 12:36 1221745

Сделал через MsComm32.ocx


Время: 12:42.

Время: 12:42.
© OSzone.net 2001-