Hello! I've already post the
bug(http://bugs.winehq.org/show_bug.cgi?id=19713) on this subject, but i
need more help. So I've decided to write here.
There is a problem in wine. When I use asynchronous serial port read, 
data never comes. Event, caused by select comes. But operation status
stays pending, and i can't do anything to this serial port anymore. In
windows it never get pending, and port can be accessed just after data
arrival. Seems to be wineserver problem, but i don't know, where to look
at. What code respond for asynchronous serial port in wineserver?
Alexander.
P.S. Test program attached.
#include <windows.h>
#include <stdio.h>

int main()
{
    HANDLE hSerial = CreateFile("\\\\.\\COM1", GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, 0);

    DCB dcbSerialParams = {0};
    dcbSerialParams.DCBlength=sizeof(dcbSerialParams);
    dcbSerialParams.BaudRate=CBR_9600;
    dcbSerialParams.ByteSize=8;
    dcbSerialParams.StopBits=ONESTOPBIT;
    dcbSerialParams.Parity=NOPARITY;
    dcbSerialParams.fBinary		= 1;
    dcbSerialParams.fDtrControl = DTR_CONTROL_DISABLE;
    dcbSerialParams.fRtsControl = RTS_CONTROL_DISABLE;
    SetCommState(hSerial, &dcbSerialParams);

    COMMTIMEOUTS timeouts={0};
    timeouts.ReadIntervalTimeout=250;
    timeouts.ReadTotalTimeoutConstant=250;
    timeouts.ReadTotalTimeoutMultiplier=250;
    timeouts.WriteTotalTimeoutMultiplier = timeouts.WriteTotalTimeoutConstant = 250;
    SetCommTimeouts(hSerial, &timeouts);

    SetupComm(hSerial, 1024, 1024);
    PurgeComm(hSerial, PURGE_TXCLEAR | PURGE_RXCLEAR | PURGE_TXABORT | PURGE_RXABORT);

    SetCommMask(hSerial, EV_RXCHAR);

    int iters = 0;
    DWORD	dwResult       = 0;
    DWORD	dwReadResult = 0;
    DWORD   dwOvRes     = 0;
    DWORD   bOvResult = 0;
    char	buffer[2048];
    DWORD	dwRead       = 0;
    DWORD evtMask, dwError;
    DWORD dwTest;
    OVERLAPPED ovOverlapped;
    ovOverlapped.Offset = ovOverlapped.OffsetHigh = 0;
    ovOverlapped.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);


    BOOL bRes = WaitCommEvent(hSerial, &evtMask, &ovOverlapped);
    if(!bRes)
    {
	dwError=GetLastError();
	if (dwError == ERROR_IO_PENDING)
	{
	      printf("dwError = ERROR_IO_PENDING\n");
	      printf("*** All preparations is done. Now we are gonna wait for event.\n");
	      dwResult = WaitForSingleObject(ovOverlapped.hEvent, INFINITE);

	      do
	      {
		  bOvResult = GetOverlappedResult(hSerial, &ovOverlapped, &dwOvRes, FALSE);
		  dwError=GetLastError();
		  printf("ovOverlapped.Internal = %lu\n", ovOverlapped.Internal);
		  printf("dwError = %d\n", dwError);
		  printf("bOvResult = %d\n", bOvResult);
		  if (bOvResult) break;
		  if(ovOverlapped.Internal==259)
		    printf("*** ovOverlapped.Internal==259. That means, that event is in progress. It is a bug. Because in windows it will never reach this point. It seems that data get stuck somewhere, but event is sent. If we try to read data, we'll get nothing.\n");
		  Sleep(500);
	      } while (dwError == ERROR_IO_INCOMPLETE);

	      if (bOvResult)
	      {
		  printf("*** All is done good. It means, that we are in Windows, or Wine is fixed(hope so).\n");
		  printf("OK.\n");
		  if (evtMask & EV_RXCHAR)
		  {
		      printf("EV_RXCHAR.\n");

		  }

	      } else
	      {
		  printf("BAD.\n");
	      }
	  }
    }
    return 0;
}


Reply via email to