Starting Out with CAN_USB

This forum covers issues concerning multiple software products.

Re: Starting Out with CAN_USB

Postby U.Wilhelm » Fri 26. Feb 2016, 09:55

Here some info from our Software Developers.
You also could use the OO PAS Version within Lazarus:

Code: Select all
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, PCANBasic;
type
  { TForm1 }
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
  private
    { private declarations }
  public
    { public declarations }
  end;
var
  Form1: TForm1;
implementation
{$R *.lfm}
{ TForm1 }

procedure TForm1.FormCreate(Sender: TObject);
begin
  // Initialize the PCAN-Basic, Channel 1
  TPCANBasic.Initialize($51, TPCANBaudrate.PCAN_BAUD_1M);
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
  // Uninitialize the PCAN-Basic, Channel 1
  TPCANBasic.Uninitialize($51);
end;

end.


The sample project is available for download:
PCANBasicTest-Lazarus.zip
PCANBasic Sample Project for Lazarus
(133.42 KiB) Downloaded 156 times
--------------------------------
PEAK-System Technik
Technical Support Team
support@peak-system.com
-------------------------------
User avatar
U.Wilhelm
Sales & Support
Sales & Support
 
Posts: 1002
Joined: Fri 10. Sep 2010, 18:34
Location: Darmstadt

Re: Starting Out with CAN_USB

Postby docwat » Fri 26. Feb 2016, 10:28

Hi Uwe,

That is a mine of information and is most helpful. Just now, I have returned to the CAN_Basic UNIT1.pas.

I had built my own Initialise, Read and write routines which worked fine but I rather liked the ERROR options of Kenet Wagner's Unit1 code so I am simplifying them to replace my initial efforts.

I will certainly explore your information which may suggest still better options.

Lazarus is so close to Delphi that I have found no problems, bur I am not using your form where there may be differencies. Lazarus does provide DELPHI to Lazarus conversion routines but I have never tried them out.

As ever,

Vielen Dank
docwat
 
Posts: 12
Joined: Sun 14. Feb 2016, 23:52

Re: Starting Out with CAN_USB

Postby docwat » Fri 4. Mar 2016, 15:40

Hi Uwe,

I have managed to get the CanBasic Unit to work fine within my Lazarus IDE so I can use the CAN_USB within our product.

The PeakView example throws up a few oddities which were partly resolved by using the Lazarus Delphi to Lazarus
conversion tool and I still have work to do to use a Lazarus.lfm Form Unit rather than the Delphi .dfm file. I have had to manually build the Lazarus.lfm and I rather think that the problems can be resolved by further work.

I am now pretty sure that I can complete writing my PC code using your .DLL which makes me extremely happy. The whole purpose of the work was to do away with a virtual serial comport. The DLL works far better with more simple code.


Vielen Dank,

Docwat
docwat
 
Posts: 12
Joined: Sun 14. Feb 2016, 23:52

Re: Starting Out with CAN_USB

Postby U.Wilhelm » Fri 4. Mar 2016, 15:49

Cool ! Good Luck for your project !
--------------------------------
PEAK-System Technik
Technical Support Team
support@peak-system.com
-------------------------------
User avatar
U.Wilhelm
Sales & Support
Sales & Support
 
Posts: 1002
Joined: Fri 10. Sep 2010, 18:34
Location: Darmstadt

Re: Starting Out with CAN_USB

Postby gioazz » Tue 17. May 2016, 14:45

Hello I'm also trying to use the usb peak in lazarus (1.4.2 win 32) but I have not figured out how you solved. I made several attempts, using the lazarus tool by importing the example in APIs PCAN basic package but the compiler has found several errors.
Some years ago, mr. Keneth Wagner-Rivas helped me with a version for delphi 7 that works good.
In Lazarus I also tried to import this project whitout solution... other errors compiler.
Suggestions ?
Thanks, Giorgio

Code: Select all
Compile the project, Destination: PCANBasicExample.exe: Exit code 1, Errors: 11 Warnings: 1, tips: 11
PCANBasic.pas (58.53) Note: Values ​​in enumeration types have to be ascending
PCANBasic.pas (396.35) Note: Values ​​in enumeration types have to be ascending
PCANBasic.pas (439.38) Note: Values ​​in enumeration types have to be ascending
Unit1.pas (179.46) Hint: Parameter "Action" not used
Unit1.pas (514.14) Error: Identifier not found "CreateEvent"
Unit1.pas (756.3) Error: Identifier not found "ZeroMemory"
Unit1.pas (793.3) Error: Identifier not found "ZeroMemory"
Unit1.pas (833.69) Hint: Local variable "CANTimeStamp" does not Seem to be initialized
Unit1.pas (833.55) Hint: Local variable "CANMsg" does not Seem to be initialized
Unit1.pas (849.68) Hint: Local variable "CANTimeStamp" does not Seem to be initialized
Unit1.pas (849.54) Hint: Local variable "CANMsg" does not Seem to be initialized
Unit1.pas (918.3) Error: Identifier not found "ZeroMemory"
Unit1.pas (930.69) Hint: Converting the operands to "Int64" before doing the add could prevent overflow errors.
Unit1.pas (957.5) Error: Identifier not found "TerminateThread"
Unit1.pas (973.17) Error: Identifier not found "CreateThread"
Unit1.pas (985.5) Error: Identifier not found "TerminateThread"
Unit1.pas (1019.7) Error: Identifier not found "WaitForSingleObject"
Unit1.pas (1019.49) Error: Identifier not found "WAIT_OBJECT_0"
Unit1.pas (1222.3) Error: Identifier not found "TerminateThread"
Unit1.pas (1247.33) Hint: Local variable "iBuffer" does not Seem to be initialized
Unit1.pas (1304.29) Hint: Local variable "iBuffer" does not Seem to be initialized
Unit1.pas (1413.17) Error: Identifier not found "GetCurrentDirectory"
Unit1.pas (1414.56) Warning: Local variable "szDirectory" does not Seem to be initialized
Last edited by M.Gerber on Thu 19. May 2016, 08:15, edited 1 time in total.
Reason: Reformatted the log for better readability.
gioazz
 
Posts: 1
Joined: Tue 17. May 2016, 13:55

Re: Starting Out with CAN_USB

Postby U.Wilhelm » Wed 18. May 2016, 11:11

Sorry - as you could read in the first post - we do not official support this language - you could use our nonOOP Pascal Header to include the DLL to your project by your own.
--------------------------------
PEAK-System Technik
Technical Support Team
support@peak-system.com
-------------------------------
User avatar
U.Wilhelm
Sales & Support
Sales & Support
 
Posts: 1002
Joined: Fri 10. Sep 2010, 18:34
Location: Darmstadt

Previous

Return to Software



This website uses cookies for analytics, for logins to the online shop and the forum, and for the handling of an order. By browsing this website you agree to the use of cookies. Detailed information on their use can be found in our privacy policy.

OKPrivacy Policy