Ignore:
Timestamp:
Jul 28, 2003, 1:35:32 PM (22 years ago)
Author:
sandervl
Message:

Updates

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kernel32/hmcomm.cpp

    r10109 r10185  
    1 /* $Id: hmcomm.cpp,v 1.39 2003-05-23 13:53:43 sandervl Exp $ */
     1/* $Id: hmcomm.cpp,v 1.40 2003-07-28 11:35:31 sandervl Exp $ */
    22
    33/*
     
    1616#include <os2win.h>
    1717#include <string.h>
     18#include <stdio.h>
    1819#include <handlemanager.h>
    1920#include "handlenames.h"
     
    6465static char *DebugCommEvent(DWORD dwEvents);
    6566static char *DebugModemStatus(DWORD dwModemStatus);
     67#ifdef DEBUG_COMOUTPUT
     68static FILE *comlog = NULL;
     69#endif
    6670#endif
    6771//******************************************************************************
     
    117121    HandleNamesAddSymbolicLink("AUX:",       "COM1");
    118122    HandleNamesAddSymbolicLink("\\\\.\\AUX", "COM1");
     123#ifdef DEBUG_COMOUTPUT
     124    comlog = fopen("comlog", "w");
     125#endif
    119126}
    120127
     
    229236            return rc;
    230237        }
     238
    231239        rc = SetBaud(pHMHandleData,9600);
    232240        dprintf(("Init Baud to 9600 rc = %d",rc));
     
    328336
    329337    *lpdwResult = (ret) ? ulBytesRead : 0;
    330     dprintf2(("KERNEL32: CommReadIOHandler %d bytes read", *lpdwResult));
     338    dprintf(("KERNEL32: CommReadIOHandler %d bytes read", *lpdwResult));
    331339
    332340    if(ret == FALSE) {
     
    335343    else {
    336344#ifdef DEBUG
     345        if(ulBytesRead < qInfo.cch) {
     346            dprintf(("WARNING: Not all data removed from queue!!"));
     347        }
    337348        dprintf2(("%d Bytes read:", ulBytesRead));
    338349        for(int i=0;i<min(ulBytesRead, 16);i++) {
     
    372383    dprintf2(("KERNEL32:CommWriteIOHandler %d byte(s) written", *lpdwResult));
    373384
     385    if(ulBytesWritten != lpRequest->nNumberOfBytes) {
     386        dprintf(("WARNING: ulBytesWritten (%d) != lpRequest->nNumberOfBytes (%d)", ulBytesWritten, lpRequest->nNumberOfBytes));
     387    }
    374388    if(ret == FALSE) {
    375389       dprintf(("!ERROR!: CommWriteIOHandler failed with rc %d", GetLastError()));
     
    432446        dwEvent |= (COMEvt&0x0100)? EV_RING:0;
    433447 
     448#ifdef DEBUG
     449        if(dwEvent & EV_ERR) {
     450            ULONG COMErr = 0;
     451
     452            rc = OSLibDosDevIOCtl( pHMHandleData->hHMHandle,
     453                    IOCTL_ASYNC,
     454                    ASYNC_GETCOMMERROR,
     455                    0,0,0,
     456                    &COMErr,2,&ulLen);
     457
     458            dprintf(("!!!!!!!----> ERROR OCCURRED (EV_ERR) reason %x <-----!!!!!", COMErr));
     459
     460        }
     461#endif
    434462        if((dwEvent & EV_RXCHAR) && (dwMask & EV_RXCHAR))
    435463        {
     
    509537    }
    510538
     539#ifdef DEBUG
     540    dprintf2(("WriteFile: bytes to write:"));
     541    for(int i=0;i<min(nNumberOfBytesToWrite, 16);i++) {
     542        dprintf2(("%x %c", ((char *)lpBuffer)[i], ((char *)lpBuffer)[i]));
     543    }
     544#endif
     545
    511546    if(pHMHandleData->dwFlags & FILE_FLAG_OVERLAPPED) {
    512547        return pDevData->iohandler->WriteFile(pHMHandleData->hWin32Handle, lpBuffer, nNumberOfBytesToWrite,
     
    517552                        &ulBytesWritten);
    518553
    519     if(lpNumberOfBytesWritten) {
     554    if(lpNumberOfBytesWritten) { 
    520555       *lpNumberOfBytesWritten = (ret) ? ulBytesWritten : 0;
    521556       dprintf2(("KERNEL32:HMDeviceCommClass::WriteFile %d byte(s) written", *lpNumberOfBytesWritten));
     
    593628        *lpNumberOfBytesRead = (ret) ? ulBytesRead : 0;
    594629        dprintf2(("KERNEL32:HMDeviceCommClass::ReadFile %d bytes read", *lpNumberOfBytesRead));
     630        if(qInfo.cch > ulBytesRead) {
     631            dprintf(("Warning: more bytes available!!"));
     632        }
    595633    }
    596634    if(ret == FALSE) {
     
    599637#ifdef DEBUG
    600638    else {
     639        int i;
    601640        dprintf2(("%d Bytes read:", ulBytesRead));
    602         for(int i=0;i<min(ulBytesRead, 16);i++) {
     641#ifdef DEBUG_COMOUTPUT
     642        char *tmp = (char *)malloc(ulBytesRead+1);
     643        memcpy(tmp, lpBuffer, ulBytesRead);
     644        tmp[ulBytesRead] = 0;
     645        dprintf2(("RF: %s", tmp));
     646        WORD sel = RestoreOS2FS();
     647        for(i=0;i<ulBytesRead;i++) {
     648            fprintf(comlog, "%c", tmp[i]);
     649        }
     650        SetFS(sel);
     651        free(tmp);
     652#endif
     653        for(i=0;i<ulBytesRead;i++) {
    603654            dprintf2(("%x %c", ((char *)lpBuffer)[i], ((char *)lpBuffer)[i]));
    604655        }
     
    893944  if(lpdwErrors == NULL)
    894945     lpdwErrors = &dwError;
    895 
     946 
    896947  dprintf(("HMDeviceCommClass::ClearCommError"));
    897948  ulLen = sizeof(USHORT);
     
    908959  *lpdwErrors |= (COMErr & 0x0008)?CE_FRAME:0;
    909960
     961  dprintf(("Error %x", *lpdwErrors));
    910962  if(lpcst)
    911963  {
     
    15301582    pCurDCB->XoffChar           = XoffChar;
    15311583    pCurDCB->ErrorChar          = ErrorChar;
     1584
     1585    dprintf(("OS/2 DCB:\n"
     1586             " WriteTimeout           : %d\n"
     1587             " ReadTimeout            : %d\n"
     1588             " CtlHandshake           : 0x%x\n"
     1589             " FlowReplace            : 0x%x\n"
     1590             " Timeout                : 0x%x\n"
     1591             " Error replacement Char : 0x%x\n"
     1592             " Break replacement Char : 0x%x\n"
     1593             " XON Char               : 0x%x\n"
     1594             " XOFF Char              : 0x%x\n",
     1595             os2dcb.usWriteTimeout,
     1596             os2dcb.usReadTimeout,
     1597             os2dcb.fbCtlHndShake,
     1598             os2dcb.fbFlowReplace,
     1599             os2dcb.fbTimeOut,
     1600             os2dcb.bErrorReplacementChar,
     1601             os2dcb.bBreakReplacementChar,
     1602             os2dcb.bXONChar,
     1603             os2dcb.bXOFFChar));
     1604
    15321605  }
    15331606
Note: See TracChangeset for help on using the changeset viewer.