Текущий архив: 2005.08.14;
Скачать: 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 вся ветка
Текущий архив: 2005.08.14;
Скачать: CL | DM;
Память: 0.44 MB
Время: 0.01 c