• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 351
  • Last Modified:

Modem Statistics

Hi Expert
I'd like to know how I can get some modem statistics like: Kbps In and Out, CRC, Buffer overruns.....  
I'm looking for something that work also on NT.
Thank you in advance.
Andrea.
0
borgo
Asked:
borgo
  • 2
1 Solution
 
rajeshveeCommented:
Please try the following :

  FHandle := CreateFile(PChar(DeviceName), GENERIC_READ or GENERIC_WRITE, 0,
    nil, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL or FILE_FLAG_OVERLAPPED, 0);
  if FHandle = INVALID_HANDLE_VALUE then
  begin
    Showmessage("ERROR_FILE_NOT_FOUND" );
  end
  else
  GetCommState(FHandle,lpDCB) where lpDcb
points to the DCB(Device-control block) structure in which the control settings information is returned.
After that U can check the various properties of DCB like :

typedef struct _DCB { // dcb  
    DWORD DCBlength;           // sizeof(DCB)
    DWORD BaudRate;            // current baud rate
    DWORD fBinary: 1;          // binary mode, no EOF check
    DWORD fParity: 1;          // enable parity checking
    DWORD fOutxCtsFlow:1;      // CTS output flow control
    DWORD fOutxDsrFlow:1;      // DSR output flow control
    DWORD fDtrControl:2;       // DTR flow control type
    DWORD fDsrSensitivity:1;   // DSR sensitivity

    DWORD fTXContinueOnXoff:1; // XOFF continues Tx
    DWORD fOutX: 1;            // XON/XOFF out flow control
    DWORD fInX: 1;             // XON/XOFF in flow control
    DWORD fErrorChar: 1;       // enable error replacement
    DWORD fNull: 1;            // enable null stripping
    DWORD fRtsControl:2;       // RTS flow control
    DWORD fAbortOnError:1;     // abort reads/writes on error
    DWORD fDummy2:17;          // reserved
    WORD wReserved;            // not currently used

    WORD XonLim;               // transmit XON threshold
    WORD XoffLim;              // transmit XOFF threshold
    BYTE ByteSize;             // number of bits/byte, 4-8
    BYTE Parity;               // 0-4=no,odd,even,mark,space
    BYTE StopBits;             // 0,1,2 = 1, 1.5, 2
    char XonChar;              // Tx and Rx XON character
    char XoffChar;             // Tx and Rx XOFF character
    char ErrorChar;            // error replacement character

    char EofChar;              // end of input character
    char EvtChar;              // received event character
    WORD wReserved1;           // reserved; do not use
} DCB;

Thanx
rajesh
0
 
rajeshveeCommented:
Sorry ,Fogot to mention u one thing
The device name Should be the name of the device  like
COM1,COM2  etc

thanks
rajesh
0
 
EmmDiehCommented:
You can read these values from the registry:
HKEY_DYN_DATA on Win 9x and
HKEY_PERFORMANCE_DATA on Win NT.

Find an example code at
http://www.magsys.co.uk/delphi/
the TRas Release 3.0 that comes with source code.
In the file rascomp32.pas look at the function TRAS.GetPerfStats for an example.

HTH

0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now