Top.Mail.Ru
Мастера DELPHI, Delphi programming community Титульная страница Поиск, карта сайта Написать письмо 
| Новости | Поиск | FAQ | Статьи | Книги | Новости VCL |
| Форумы ЧАТ | Орешник | KOL и MCK |
Форумы -» Основная («Начинающим»)/ Базы / WinAPI / Компоненты / Сети / Media / Игры / Corba и COM / KOL / FreePascal / .Net / Прочее / RSDN.ORG

« предыдущая ветвь | форум | следующая ветвь »

Проблема с записью в порт [D5]


_san_ ©   (2004-03-19 12:40:00) 

Добрый день!
Я записываю в Com-порт информацию функцией:
   if Not WriteFile( CommHandle, Transmit, dwWritten, written, @Ovr) then
   begin
     dwError := GetLastError;
    …
в win 98 все работает нормально, а вот когда пробую запись в win2000, то почему то функция WriteFile  говорит, что записано 0 байт (written = 0), хотя сами данные до устройства доходят.
В чем тут дело?


Reindeer Moss Eater   (2004-03-25 16:33:00) [1]

SetCommTimeouts


_san_   (2004-03-25 14:32:00) [2]

У меня еще вопрос.
Если у меня внешнее устройство по какой-либо причине перестает отвечать (зависло или даже просто выключено) то мое приложение намертво виснет на функции чтения или записи. Попробовал перенести их в отдельные потоки – вообще все перестало работать (и запись и чтение).
Как с этим бороться?


Digitman   (2004-03-25 10:20:00) [3]

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.

If hFile was not opened with FILE_FLAG_OVERLAPPED and lpOverlapped is NULL, the write operation starts at the current file position and WriteFile does not return until the operation has been completed.
If hFile was not opened with FILE_FLAG_OVERLAPPED and lpOverlapped is not NULL, the write operation starts at the offset specified in the OVERLAPPED structure and WriteFile does not return until the write operation has been completed.



Return Values

If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, call GetLastError.


_san_   (2004-03-25 10:14:00) [4]

Асинхронный режим – это если я открыл файл (CreateFile) c флагом FILE_FLAG_OVERLAPPED.
А если я открою файл без этого флага – в каком режиме тогда я буду работать с Com-портом.


Reindeer Moss Eater   (2004-03-19 14:31:00) [5]

В том, что так и должно быть при асинхронных операциях.
Ты же асинхронный ввод/вывод используешь.


Наверх

Титульная страница Поиск, карта сайта Написать письмо