{$MODE Delphi} verses {$mode objfpc}{$H+} lazarus / 31-LCL ---------------------------------------------------------------------- jcdammeyer · 2020-08-06 17:53 I have created an application that inside its' own create method just does this. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   // Create the interface form that handles all the physical I/O  CommConnection := TCommForm.FormCreate(           CANUSB_COM,                    // For now hard coded to USB CAN dongle.            'CANopen',                   // Form Caption            '\Software\AutomationArtisans\CANopenCom',   // Where to store config.            Sender);   CommConnection.OnRxMsg := SerialRxData;  After that the method Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i  SerialRxData(Sender : TObject; var s : string); is called to parse the string sent by the CANUSB dongle.  When I switch over to an MCP2515 on a Pi or the internal CAN device on a Beagle I'll format the messages from those to look like what the CANUSB sends so the application won't know the difference.  Just depends on what is passed to the FormCreate method. Well guess what? In Lazarus this line kept failing with a missing parameters message.  Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   CommConnection.OnRxMsg := SerialRxData; I even created a simple two form "hello world" program to bring it down to basics.  Still no luck.  Eventually I had to comment out: // {$mode objfpc}{$H+} Replacing it with: {$MODE Delphi} After that it worked.  And it still works on the Beagle running Linux. Inside the main form I have: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i     // Connection to the CAN hardware    CommConnection : TCommForm;    // Called by the DoRxMsg method in TCommForm.    procedure SerialRxData(Sender : TObject; var s : string);  And the attached commform.pas shows the associated types and properties that make it all happen. My question is: If I went back to {$mode objfpc}{$H+} What needs to be done to be able to pass that callback function using the objfpc mode?  Or is that even possible in non-Delphi mode? ---------------------------------------------------------------------- howardpc · 2020-08-07 20:19 see https://forum.lazarus.freepascal.org/index.php/topic,50922.msg3727 00.html#msg372700 ---------------------------------------------------------------------- marcov · 2020-08-07 20:21 Yes, this is the main "feature" that sets objfpc apart from Delphi. ---------------------------------------------------------------------- jcdammeyer · 2020-08-07 20:27 I did try the @ in front of the function but for some reason it didn't appear to work.  I had tried a few other things at the same time so maybe I was distracted.  Thanks for the suggestions.  And sorry for locking the thread.  It was totally unintentional. John ---------------------------------------------------------------------- TRon · 2020-08-07 21:06 Quote from: jcdammeyer on August 07, 2020, 10:27:59 pmI did try the @ in front of the function but for some reason it didn't appear to work.  I had tried a few other things at the same time so maybe I was distracted.  Thanks for the suggestions.  Must be indeed as we all seem to agree that was the issue  QuoteAnd sorry for locking the thread.  It was totally unintentional. Don't worry too much about it. It is/was simply strange as even if you made a mistake and know the answer it is common here to post your answer (as courtesy to other readers) or just write "never mind, solved it myself" (former is preferred). Just let us know if you are still having issue(s) with that code (or other code for that matter). ---------------------------------------------------------------------- jcdammeyer · 2020-08-07 21:55 Quote from: TRon on August 07, 2020, 11:06:27 pmJust let us know if you are still having issue(s) with that code (or other code for that matter). About to try that now.  Thanks.   I will post my results. ---------------------------------------------------------------------- jcdammeyer · 2020-08-07 22:20 I changed two things. First in all the files changed mode back. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i {$mode objfpc}{$H+}//{$MODE Delphi}   Then only one single change and a compile and run. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i CommConnection.OnRxMsg := @SerialRxData;  And the results are... drum roll...  Success!  And given that I was sure I'd tried that already I'm surprised.  But I must have been doing something else weird at the same time. BTW. When this CANopen Lite monitor is done I will be releasing the source code that will run on PCs, Raspberries and Beagles.  It will use the USB port for the CANUSB dongle (or any micro that follows that protocol)  but also SocketCAN on the Beagle and Pi which will use either the Beagle internal CAN device or an SPI based MCP2515. But of course the connection to socket CAN won't be C but FPC inside Lazarus. https://www.beyondlogic.org/example-c-socketcan-code/