I'm trying to test PCAN-ISO TP with Delphi, but I've encountered some issues.
Software Used: Delphi 11.3, Delphi 12
I downloaded PCAN-ISO-TP.ZIP and copied the PCANBasic.pas and PCANTP_2016.pas files from the \PCAN-ISO-TP\Samples\Samples\Delphi\05_isotp_read_write folder into a new Delphi project. The project type is a Windows VCL Application.
The problem arises when I try to run the Delphi project. I'm encountering errors in PCANTP_2016.pas at lines 1024(1024:55) and 1259(1259:107) with the message 'E2026 Constant expression expected'.
line 1024 : PCANTP_STATUS_FLAG_PCAN_STATUS = UInt32($80000000),
line 1259 : PCANTP_MSGTYPE_ANY = UInt32(PCANTP_MSGTYPE_FRAME) Or UInt32(PCANTP_MSGTYPE_ISOTP) Or UInt32($FFFFFFFF));
It seems like the issue might be related to UInt32($80000000) and UInt32($FFFFFFFF). Is there a way to resolve this problem?
I'm also curious whether the problem persists if I copy only the PCANBasic.pas and PCANTP_2016.pas files into a new Delphi project.
Error Inquiry Regarding Delphi's PCANTP_2016
Re: Error Inquiry Regarding Delphi's PCANTP_2016
Hello
Thank you for this notice.
The reason is due Range checking compiling option (under Runtime errors in Project options).
This option is enabled by default for debug configuration in new projects on Delphi 11.3 and 12.
And the range checking seems to be done with signed bounds even when {$Z4} is defined on an enumeration.
There are two ways to solve the problem:
First
You add the compiler switch command for this option at the top of the PCANTP_2016.pas file to disable range checking for this file.
Second
You change all casts/conversions from UInt32 to Integer.
Regards
M.Riedl
Thank you for this notice.
The reason is due Range checking compiling option (under Runtime errors in Project options).
This option is enabled by default for debug configuration in new projects on Delphi 11.3 and 12.
And the range checking seems to be done with signed bounds even when {$Z4} is defined on an enumeration.
There are two ways to solve the problem:
First
You add the compiler switch command for this option at the top of the PCANTP_2016.pas file to disable range checking for this file.
Code: Select all
{$R-}
You change all casts/conversions from UInt32 to Integer.
Code: Select all
...
PCANTP_STATUS_FLAG_PCAN_STATUS = Integer($80000000),
...
PCANTP_MSGTYPE_ANY = Integer(PCANTP_MSGTYPE_FRAME) Or Integer(PCANTP_MSGTYPE_ISOTP) Or Integer($FFFFFFFF));
...
M.Riedl