Вниз
Скачать: CL | DM;

COM port   Найти похожие ветки 

 
Evg12   (2005-06-14 11:01) [0]

Я вот смотрю в примерах и встречаю интересный момент
при записи в порт вижу или

if not WriteFile(hPort, WriteBytes, SizeOf(WriteBytes),  dwWrite, @OverWrite) then exit;

или

dwWrite:=0;
repeat
WriteFile(hPort, WriteBytes, SizeOf(WriteBytes),  dwWrite, @OverWrite)
until dwWrite > 0;

1. Когда может возникнуть ситуация, что в первом случае записать не получится.

2. для второго случая - не возниклит ли ситуация, когда фактически в порт будет передано 2 одинаковых значения WriteBytes?


 
Digitman ©   (2005-06-14 13:15) [1]


> Когда может возникнуть ситуация, что в первом случае записать
> не получится

цитата из справки :

If hFile was opened with FILE_FLAG_OVERLAPPED and lpOverlapped is not NULL, the write operation starts at the offset specified in the OVERLAPPED structure and WriteFile may return before the write operation has been completed. In this case, WriteFile returns FALSE and the GetLastError function returns ERROR_IO_PENDING. This allows the calling process to continue processing while the write operation is being completed. The event specified in the OVERLAPPED structure is set to the signaled state upon completion of the write operation.


> для второго случая


второй пример и рассматривать всерьез не следует - в нем автор не анализирует рез-т вызова ф-ции, полагаясь на авось



Страницы: 1 вся ветка

Скачать: CL | DM;



Память: 0.45 MB
Время: 0.024 c
1-1122380177
Alexey_T-O
2005-07-26 16:16
2005.08.14
Курс $


4-1118827675
mad0max
2005-06-15 13:27
2005.08.14
Transparent STATIC


1-1122242723
bagle
2005-07-25 02:05
2005.08.14
переводчик


11-1105356483
RA
2005-01-10 14:28
2005.08.14
Изменения в PStrList


9-1114171308
VolanD666
2005-04-22 16:01
2005.08.14
Как так...




   Наверх