Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

please help! Project involving com port

COTTERCOTTER Member Posts: 15
I need to be able to send a string through the serial port but can't use any components that need to be installed as the program will be used on a college computer where the administrator has stopped anyone installing on the machines. Therefore I need something that requires no installation and it needs to work in both win98 and winNT. Is this possible and can anyone help?????

Please explain in detail as I'm still a novice.

many thanks

Comments

  • RickListRickList Member Posts: 22
    : I need to be able to send a string through the serial port but can't use any components that need to be installed as the program will be used on a college computer where the administrator has stopped anyone installing on the machines. Therefore I need something that requires no installation and it needs to work in both win98 and winNT. Is this possible and can anyone help?????
    :
    : Please explain in detail as I'm still a novice.
    :
    : many thanks
    :
    Hi there,

    There is a component which you can use in your Delphi programs ( http://www2.arnes.si/~sopecrni/ ) Then you just have to run the .Exe, so no install.

    Richard
  • COTTERCOTTER Member Posts: 15
    : : I need to be able to send a string through the serial port but can't use any components that need to be installed as the program will be used on a college computer where the administrator has stopped anyone installing on the machines. Therefore I need something that requires no installation and it needs to work in both win98 and winNT. Is this possible and can anyone help?????
    : :
    : : Please explain in detail as I'm still a novice.
    : :
    : : many thanks
    : :
    : Hi there,
    :
    : There is a component which you can use in your Delphi programs ( http://www2.arnes.si/~sopecrni/ ) Then you just have to run the .Exe, so no install.
    :
    : Richard

    Thanks for the help. The component I've got is quite good (TCommPortDriver or ComDrv32) but I realise the problem is not the component. I can't seem to call a function or procedure from this component without it raising an access violation when I run the program. My program compiles fine but running it brings up this access violation. The component is on the form and the source of the component is listed in the Uses clause. Could you explain to me exactly (step by step) how I attach a component and then call its procedures and functions (and default values/properties would be useful too!)

    Cheers
    :

  • RickListRickList Member Posts: 22
    : Thanks for the help. The component I've got is quite good (TCommPortDriver or ComDrv32) but I realise the problem is not the component. I can't seem to call a function or procedure from this component without it raising an access violation when I run the program. My program compiles fine but running it brings up this access violation. The component is on the form and the source of the component is listed in the Uses clause. Could you explain to me exactly (step by step) how I attach a component and then call its procedures and functions (and default values/properties would be useful too!)
    :
    : Cheers

    Well I don't have this TCommPortDriver, so I can't give you advise on that component (I'll look around if I can find some time). I've inserted a piece of code from one of my progs. It's a unit for a thread which reads from a barcodescanner attached to the Com1 port. This software is still in Debug, so there is quit a lot of CodeSite still in there.

    Come to think of it, I used to get a AV on Windows 2000 when Windows was using the Comport. Make sure there are no Modem or printerdrivers pointing to the comport you're using otherwise Windows NT will not let you connect directly to the comport.

    Richard

    [code]
    unit ucScannerThread;
    interface
    uses
    Windows,Messages,SysUtils,Classes,CPortCtl,CPort,CsIntf,Graphics;

    type
    TBCThread = Class(TThread)
    private
    oCS : TCodeSite;
    FnHandle : THandle;
    FoComport : TComport;
    FcSample : string;
    FnMessagePort : Integer;
    protected
    property oComport : TComport read FoComport write FoComport;
    procedure SendData(cValue : string);
    procedure Execute; override;
    public
    constructor Create(Handle : THandle; MessagePort : Integer);
    destructor Destroy; override;
    published
    property nHandle : THandle read FnHandle write FnHandle;
    property cSample : string read FcSample write FcSample;
    property nMessagePort : Integer read FnMessagePort write FnMessagePort;
    end;

    implementation
    { TBCThread }
    constructor TBCThread.Create (Handle : THandle; MessagePort : Integer);
    begin
    inherited Create(True); // Create suspended
    Priority := tpLowest;
    nHandle := Handle;
    nMessagePort := MessagePort;
    oComport := TComport.Create(nil);
    oComport.Events :=[];
    oComport.port := '1';
    oComport.Open;
    oCS := TCodeSite.Create(nil);
    oCS.Category := 'Scanner';
    oCS.CategoryColor := clGreen;
    end;

    destructor TBCThread.Destroy;
    begin
    oCS.Free;
    oComport.Close;
    oComPort.Free;
    inherited;
    end;

    procedure TBCThread.Execute;
    var cBuffer : string;
    begin
    while not Terminated do begin
    // Read data from Comport buffer
    cBuffer := '';
    oComPort.ReadStr(cBuffer,1);
    if Length(cBuffer) > 0 then begin
    // Check for barcode terminator (#13)
    if (ord (cBuffer[1]) = 13) then begin
    SendData(cSample);
    cSample := '';
    Continue;
    end else begin
    cSample := cSample + cBuffer[1];
    Continue;
    end;
    end else Sleep(100);
    end;
    end;

    procedure TBCThread.SendData(cValue : string);
    const nCounter : Integer = 1;
    begin
    // Message to Mainform with cValue
    oCs.SendString('Sending:', cSample);
    nCounter := nCounter + 1;
    SendMessage(nHandle,nMessagePort,Integer(PChar(cValue)),0);
    end;

    end.
    [/code]
  • Shawn CarterShawn Carter Member Posts: 0

    [ http://forcoder.org ] free video tutorials and ebooks about ( MATLAB Visual Basic .NET Go PHP Perl Assembly Objective-C Delphi Swift PL/SQL C# C Java R Ruby Visual Basic C++ Python Scratch JavaScript COBOL Alice ML F# Lua Apex Logo FoxPro Transact-SQL Hack Awk D Scala Rust ABAP SAS Julia Crystal Scheme Fortran Dart VBScript Prolog Clojure Lisp Kotlin Erlang Bash Ada LabVIEW ) _

Sign In or Register to comment.