Question:
Serial port logger, sniffer, monitor (rs 233, Com1)?
kenny
2011-10-22 00:25:49 UTC
I'd like to monitor the communication between a computer software and a device connected by serial port with Delphi (I could use any other programming language). I know already how to write or read the port but I can't use it since is being used by the other application. any source code or information will be appreciated. thanks
Five answers:
mystic smeg
2011-10-22 02:00:15 UTC
Hi "kenny",



Serial communications via COM / USB ports is easy to establish in Delphi. However, in order to communicate with "a device" attached to a serial port, you need to understand the devices communication requirements. All devices have different requirements, different order of bits triggering different actions, etc. In addition you must also understand the communication principles of the port(s) you plan to use. BAUD rates, Stop bits, Parity, Timeouts, but to name a few.



That said, anyone on here can help you with the code to communicate with devices on a computer port in almost any language, but in order for us to give you any detailed advice on your specific requirements for the device you're trying to communicate with, you'll need to tell us what the specific device is (make/model number)?



Below is a Delphi header for a "uSerial.pas" unit I wrote a while back which encapsulates an OOP approach to serial comms. You can mail me at (mystic.smeg@yahoo.co.uk) if you think this will be of any use to you...



TSerial = class(TEObject)

private

fValidPorts: TStrings; //Internal list of valid com ports

lpDCB: TDCB; //com port settings Device Control Block (DCB)

lpTimeouts: TCommTimeouts; //com port timeouts

fhCOM: THandle; //com port handle

fPortOpen: boolean; //boolean com port open flag

fCOMPort: byte; //COM port number 0-n

fBeforeDataWrite: TBeforeDataWrite;

fAfterDataWrite: TAfterDataWrite;

fBeforeDataRead: TBeforeDataRead;

fAfterDataRead: TAfterDataRead;

function GetBaud: integer;

function GetBSize: byte;

function GetEofChar: char;

function GetErrorChar: char;

function GetEvtChar: char;

function GetParity: Integer;

function GetStopBits: integer;

function GetXoffChar: char;

function GetXoffLim: Word;

function GetXonChar: char;

function GetXonLim: Word;

procedure SetBaud(const Value: integer);

procedure SetBSize(const Value: byte);

procedure SetEofChar(const Value: char);

procedure SetErrorChar(const Value: char);

procedure SetEvtChar(const Value: char);

procedure SetParity(const Value: Integer);

procedure SetStopBits(const Value: integer);

procedure SetXoffChar(const Value: char);

procedure SetXoffLim(const Value: Word);

procedure SetXonChar(const Value: char);

procedure SetXonLim(const Value: Word);

function GetIntervalTimeout: cardinal;

function GetTotalTimeoutConstant: cardinal;

function GetTotalTimeoutMultiplier: cardinal;

procedure SetIntervalTimeout(const Value: cardinal);

procedure SetTotalTimeoutConstant(const Value: cardinal);

procedure SetTotalTimeoutMultiplier(const Value: cardinal);

public

constructor Create(PortID: Integer=0);

destructor Destroy; override;

function PortExists(ComID: integer): boolean; overload;

function PortExists: boolean; overload;

function PortRead(out Size: integer; out Success: boolean): TByteArray;

function PortWrite(data: TByteArray; Size: integer): boolean;

procedure PortReset;

function PortOpen: boolean;

procedure PortClose;

published

property COMID: byte read fCOMPort write fCOMPort;

property IsOpen: boolean read fPortOpen;

property BaudRate: integer read GetBaud write SetBaud;

property ByteSize: byte read GetBSize write SetBSize;

property Parity: Integer read GetParity write SetParity;

property StopBits: integer read GetStopBits write SetStopBits;

property XonLim: Word read GetXonLim write SetXonLim;

property XoffLim: Word read GetXoffLim write SetXoffLim;

property XonChar: char read GetXonChar write SetXonChar;

property XoffChar: char read GetXoffChar write SetXoffChar;

property ErrorChar: char read GetErrorChar write SetErrorChar;

property EofChar: char read GetEofChar write SetEofChar;

property EvtChar: char read GetEvtChar write SetEvtChar;

property IntervalTimeout: cardinal read GetIntervalTimeout write SetIntervalTimeout;

property TotalTimeoutMultiplier: cardinal read GetTotalTimeoutMultiplier write SetTotalTimeoutMultiplier;

property TotalTimeoutConstant: cardinal read GetTotalTimeoutConstant write SetTotalTimeoutConstant;

property BeforeDataWrite: TBeforeDataWrite read fBeforeDataWrite write fBeforeDataWrite;

property AfterDataWrite: TAfterDataWrite read fAfterDataWrite write fAfterDataWrite;

property BeforeDataRead: TBeforeDataRead read fBeforeDataRead write fBeforeDataRead;

property AfterDataRead: TAfterDataRead read fAfterDataRead write fAfterDataRead;

end; {class TSerial}



//useful helper function(s)

procedure GetAvailCOMPorts(out ComPorts: TStrings);



implementation

{... lots more code here...}



Mystic
2016-10-14 09:46:39 UTC
No, the DB-9 serial port won't artwork for that objective. that is a legacy RS-232 port for outdated peripherals alongside with mouses, modems, scanners, joysticks, and so on from in the previous USB develop into invented. in case you opt for for to maintain that pc, your suitable guess is to purchase an outdated pictures card for some funds it is well suited such as your pc (fits into between the unfastened inner slots on your computer).
2014-01-13 00:36:58 UTC
You can use COM Port monitor - the program monitors, displays, logs and analyzes all serial port activity in a system.

Works with Windows x32 and x64

Source:

http://www.com-port-monitoring.com/portmonitor.html
2011-10-22 00:48:40 UTC
Sounds like you are trying to sniff Credit Card numbers... Yeah, there are a ton of ways to do it, but this isn't the proper place to discuss it.
?
2011-10-22 00:30:59 UTC
There is something for Windows. I've used it, but can't remember the name. Try Google.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...