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