Показать полную графическую версию : [решено] Чтение из COM порта
Как можно выставить таймауты для чтения ком-порта?
Нашел такое: http://www.autoitscript.com/forum/index.php?showtopic=45842&st=0&p=341916&#entry341916 (http://) 
там есть:
;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
_CommGetString() возвращает строку. _CommReadByte() возвращает байт. Про время не понял...в том примере видимо _CommGetString() было в цикле с периодом в 200мс.
Вот она:
;================================================================================
;
; 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
w3d1, смотри выше :)
В том-то и дело, что цикла там нет
Вся проблема в том, что непонятно что в длл-ке (см первое сообщение) зашито, есть ли там эта настройка.
По обсуждению из  http://www.autoitscript.com/forum/index.php?showtopic=45842&st=0&p=341916&#entry341916 (http://)  не понял, а вопросы задавать - не настолько хорошо английский знаю.
Сделал через MsComm32.ocx
© OSzone.net 2001-2012
vBulletin v3.6.4, Copyright ©2000-2025, Jelsoft Enterprises Ltd.
Available in ZeroNet 1osznRoVratMCN3bFoFpR2pSV5c9z6sTC