Recent

Author Topic: CAN-BUS SocketCAN  (Read 49140 times)

jcdammeyer

  • Full Member
  • ***
  • Posts: 195
  • Embedded System Developer
    • Automation Artisans Inc.
Re: CAN-BUS SocketCAN
« Reply #105 on: September 28, 2021, 07:58:59 pm »
There we go.  The 29 bit Extended IDs in addition to 11 bit Standard IDs are now also supported in the lazcandump.  The Extended ID message is only sent on change of one of the two checkboxes in LinuxCNC with a single byte of null data.  ie.  No important information.  Just the message to show it works.  The captured data here from the CANUSB  was done with puTTY into the BBB while lazcandump was also running on a terminal screen on the BBB working with the internal CAN1.

Oh and via puTTY I can run lazcandump can1 while it's also running on the BBB terminal session so it's sharing nicely.

Next step, make lazcandump  work on the Pi4

Quote
slcan0       298 [7]  00 00 00 00 01 00 00
slcan0       298 [7]  00 00 00 00 01 00 00
slcan0       318 [1]  04
slcan0  12345678 [1]  00
slcan0       718 [1]  05
slcan0       298 [7]  00 44 00 00 01 00 00
slcan0       298 [7]  00 44 00 00 01 00 00
slcan0       718 [1]  05
slcan0       298 [7]  00 44 00 00 01 00 00
slcan0       318 [1]  00
slcan0  12345678 [1]  00
slcan0       298 [7]  00 00 00 00 01 00 00


jcdammeyer

  • Full Member
  • ***
  • Posts: 195
  • Embedded System Developer
    • Automation Artisans Inc.
Re: CAN-BUS SocketCAN
« Reply #106 on: September 29, 2021, 05:29:31 am »
I'm ready to try it on the Raspberry Pi4.  However something odd and this may not be the right thread to ask the question.
 
The Pi4 has the folder fcpupdeluxe as shown in the attached photo.  However there's no shortcut to it on the desktop.  I don't remember at what point I stopped with the installation or if I even installed it.

The BBB has this as the desktop link:
Quote
[Desktop Entry]
Version=1.0
Encoding=UTF-8
Type=Application
Icon=/home/debian/fpcupdeluxe/lazarus/images/icons/lazarus.ico
Exec=/home/debian/fpcupdeluxe/lazarus/lazarus --pcp="/home/debian/fpcupdeluxe/config_lazarus" %f
Name=Lazarus_fpcupdeluxe
GenericName=Lazarus IDE with Free Pascal Compiler
Category=Application;IDE;Development;GUIDesigner;Programming;
Categories=Application;IDE;Development;GUIDesigner;Programming;
Keywords=editor;Pascal;IDE;FreePascal;fpc;Design;Designer;


Suggestions?
Thanks
John

avra

  • Hero Member
  • *****
  • Posts: 2261
    • Additional info
Re: CAN-BUS SocketCAN
« Reply #107 on: September 29, 2021, 09:32:15 am »
I also did put them into unxsockh.inc but it didn't have any effect.
That would have also worked after FPC rebuilding.
Unfortunately at this point you lose me on what to do there.  I ran fpcupdeluxe to install the same version on the PC, Pi3/4 and BBB.  I would need the simpleton step by step procedure to do the 'FPC rebuilding' along with a "why I am doing what I'm doing"
FPC rebuild steps for Windows: https://forum.lazarus.freepascal.org/index.php/topic,55358.msg411825.html. Shouldn't be too difficult to adapt for Linux. Ah, yes... do not forget to rebuild Lazarus as well, so IDE can be aware of FPC changes.

Quote
No idea why canreceive.lpr won't compile into an executable.
What is the compilation error message? What FPC/LAZ/OS/ARCH/Bitness combo was used? Did you manage to compile other demos?
I opened up the .lpi project from Lazarus and did a build.  The screen capture I posted earlier and again here shows the result.  I tried a number of options with no success in creating an executable.
I can see on the screenshot that compilation was a success, so canreceive file should be created. It also seams that you tried to run it from IDE, which I do not recommend. Better try to run it from the terminal. If file canreceive exists, then maybe you just need to manually flag it as an executable? What about other demos? Could you compile them and run, or not?

I do have a zip of the entire conference proceedings (47MB) including my presentation (1.4MB) all too big to post here.
What was the topic of your presentation?

The Pi4 has the folder fcpupdeluxe as shown in the attached photo.  However there's no shortcut to it on the desktop.  I don't remember at what point I stopped with the installation or if I even installed it.

The BBB has this as the desktop link:
Excluding path difference, I have identical desktop shortcut on my Debian XFCE system so you should be good to copy and use yours in another system.

I'm so glad to see your progress.  :D
« Last Edit: September 29, 2021, 09:44:46 am by avra »
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

jcdammeyer

  • Full Member
  • ***
  • Posts: 195
  • Embedded System Developer
    • Automation Artisans Inc.
Re: CAN-BUS SocketCAN
« Reply #108 on: September 29, 2021, 10:06:15 am »
1. Really.  It didn't compile it.  Very strange.
Quote
debian@ebb:/$ sudo find / -name canreceive*
[sudo] password for debian:
/home/debian/lazarus/AvraCAN/canreceive.lpi
/home/debian/lazarus/AvraCAN/canreceive.lpr
/home/debian/lazarus/AvraCAN/backup/canreceive.lpi
/home/debian/lazarus/AvraCAN/backup/canreceive.lpr
/home/debian/lazarus/AvraCAN/backup/canreceive.lps
/home/debian/lazarus/AvraCAN/canreceive.lps
debian@ebb:/$

2. The paper was titled "A large scale CAN bus system".  I put the document here:  http://www.autoartisans.com/rings/ALargeScaleCANbusSystem.pdf

3. I'll try creating a shortcut.  I have no worries about both the CANUSB and SPI MCP2515 working as they both work with the C language candump.

avra

  • Hero Member
  • *****
  • Posts: 2261
    • Additional info
Re: CAN-BUS SocketCAN
« Reply #109 on: September 30, 2021, 11:33:57 am »
1. Really.  It didn't compile it.  Very strange.
Do you have problems generating executable only with canreceive demo, or you have problems with all demos (hlcanreceive...)? If all demos suffer the same problem, then it might be dir/file access rights problem and you could try another directory or fix access rights.
« Last Edit: September 30, 2021, 11:37:18 am by avra »
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

jcdammeyer

  • Full Member
  • ***
  • Posts: 195
  • Embedded System Developer
    • Automation Artisans Inc.
Re: CAN-BUS SocketCAN
« Reply #110 on: September 30, 2021, 06:47:00 pm »
1. Really.  It didn't compile it.  Very strange.
Do you have problems generating executable only with canreceive demo, or you have problems with all demos (hlcanreceive...)? If all demos suffer the same problem, then it might be dir/file access rights problem and you could try another directory or fix access rights.

Haven't had a chance to try that yet.  Yesterday was a battle to get fpcupdeluxe installed on the Pi4 LinuxCNC.  Each time a failure near the end.  Google on the error and others have had the same and the support statement was closing this issue it's a Lazarus problem...

But eventually I did get it running and have the same version of Lazarus installed on the Pi4.  Now to make sure that LED sample works.  Probably have to add the same changes we did in the spring to the library.

Then on BBB finally after much feedback from Robert Nelson got Buster and a Buster kernel installed on the BBB. 

So today I'll take another look at your examples.  Are you compiling them from within Lazarus or just using FPC and command line?

jcdammeyer

  • Full Member
  • ***
  • Posts: 195
  • Embedded System Developer
    • Automation Artisans Inc.
Re: CAN-BUS SocketCAN
« Reply #111 on: September 30, 2021, 09:34:19 pm »
1. Really.  It didn't compile it.  Very strange.
Do you have problems generating executable only with canreceive demo, or you have problems with all demos (hlcanreceive...)? If all demos suffer the same problem, then it might be dir/file access rights problem and you could try another directory or fix access rights.

Haven't had a chance to try that yet.  Yesterday was a battle to get fpcupdeluxe installed on the Pi4 LinuxCNC. 

So today I'll take another look at your examples.  Are you compiling them from within Lazarus or just using FPC and command line?

Alright.  My project loads and compiles correctly on the Pi4 with Lazarus.
I load yours, say hlcanreceive.lpi and the screen shot says it all I think.
Your canreceive.lpi does have files because I added them on the beagle and then dragged that folder over to the Pi.
As you can see on the screen shot I'm using Lazarus IDE v2.0.10  since that's what's on the Beagle.  Also it's the only one that would actually install without lazarus compile failures on the Pi4.  On the WIN-PC with 2.0.8 r62944 it behaves the same.  The source code file doesn't appear.

So let's look at the .lpi file for the simple console application I made from within Lazarus and had the key elements of your receive code cut and pasted.  Using the now 30 year old CodeWright from Borland with the side by side compare perhaps you can see why mine loads the lpr file.  In the Project inspector mine shows ConsoleApplication.pas.

Hopefully this helps?





jcdammeyer

  • Full Member
  • ***
  • Posts: 195
  • Embedded System Developer
    • Automation Artisans Inc.
Re: CAN-BUS SocketCAN
« Reply #112 on: September 30, 2021, 09:37:51 pm »
Here's a zip of the console application

avra

  • Hero Member
  • *****
  • Posts: 2261
    • Additional info
Re: CAN-BUS SocketCAN
« Reply #113 on: October 01, 2021, 12:19:34 pm »
After seeing that your project inspector is empty, and that when comparing LPIs - one XML file has <BuildModes Count = "1"> and the other one has just <BuildModes>, it is clear that all LPI files have been saved in new Lazarus 2.1+ XML file format, and that was the reason why you have not been able to load project properly, because you have old Lazarus 2.0. For a quick fix you can use this tool: https://sourceforge.net/p/lazarus-ccr/svn/HEAD/tree/applications/fixlp/, but as a permanent solution I will change all project files to be saved in old compatibility mode.
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

avra

  • Hero Member
  • *****
  • Posts: 2261
    • Additional info
Re: CAN-BUS SocketCAN
« Reply #114 on: October 01, 2021, 01:23:36 pm »
Attached latest SocketCAN with fixed example projects LPIs. Old Lazarus is now able to open all projects.
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

jcdammeyer

  • Full Member
  • ***
  • Posts: 195
  • Embedded System Developer
    • Automation Artisans Inc.
Re: CAN-BUS SocketCAN
« Reply #115 on: October 01, 2021, 06:22:27 pm »
Attached latest SocketCAN with fixed example projects LPIs. Old Lazarus is now able to open all projects.

I'll try it today.   

At the moment I have to stay with the old Lazarus.  After the 4th try with Stable, Trunk and a mix of those I finally went Trunk and 2.0.10 for Lazarus on the Debian Pi4 LinuxCNC install.   That's the only one that actually would build to completion and put the icon on the desktop.  And at that point I was able to build my code along with that LED 7 segment display program that had the paint issue.  I've forgotten exactly what that was.  Will have to look through the old posts although the code seems to work.

jcdammeyer

  • Full Member
  • ***
  • Posts: 195
  • Embedded System Developer
    • Automation Artisans Inc.
Re: CAN-BUS SocketCAN
« Reply #116 on: October 01, 2021, 06:28:41 pm »
After seeing that your project inspector is empty, and that when comparing LPIs - one XML file has <BuildModes Count = "1"> and the other one has just <BuildModes>, it is clear that all LPI files have been saved in new Lazarus 2.1+ XML file format, and that was the reason why you have not been able to load project properly, because you have old Lazarus 2.0. For a quick fix you can use this tool: https://sourceforge.net/p/lazarus-ccr/svn/HEAD/tree/applications/fixlp/, but as a permanent solution I will change all project files to be saved in old compatibility mode.

I've downloaded it to my PC and then dragged and dropped onto the Pi and the Beagle via windows explorer.  Since I'm running 2.0.10 on the Windows systems too I'll also try it there.

What was the reasoning to cripple all old versions of Lazarus with a change to the project format?  Would it not have been better to leave the old and add a replacement for Buildmodes that would be ignored?  For backward compatibility?

jcdammeyer

  • Full Member
  • ***
  • Posts: 195
  • Embedded System Developer
    • Automation Artisans Inc.
Re: CAN-BUS SocketCAN
« Reply #117 on: October 01, 2021, 06:37:54 pm »
After seeing that your project inspector is empty, and that when comparing LPIs - one XML file has <BuildModes Count = "1"> and the other one has just <BuildModes>, it is clear that all LPI files have been saved in new Lazarus 2.1+ XML file format, and that was the reason why you have not been able to load project properly, because you have old Lazarus 2.0. For a quick fix you can use this tool: https://sourceforge.net/p/lazarus-ccr/svn/HEAD/tree/applications/fixlp/, but as a permanent solution I will change all project files to be saved in old compatibility mode.

I've downloaded it to my PC and then dragged and dropped onto the Pi and the Beagle via windows explorer.  Since I'm running 2.0.10 on the Windows systems too I'll also try it there.

As the screen shot shows, it went from no files in the project to the list with the members.pas missing and of course won't compile because termio is missing but then this project was never meant to be compatible with windows lazarus so that's no real surprise.

More when I get to the Linux systems.


jcdammeyer

  • Full Member
  • ***
  • Posts: 195
  • Embedded System Developer
    • Automation Artisans Inc.
Re: CAN-BUS SocketCAN
« Reply #118 on: October 01, 2021, 11:22:43 pm »
Amazing how much time this eats up.

Although the fixlp program compiled and ran and modified the lpi programs it did not create a workable solution.  At least not with 2.0.10

I downloaded the can.zip and that one did work with canreceive.lpi and after modifying to use slcan0 I was able to capture a CAN message.  However compiling hlcanreceive.lpi created a list of 5 files as shown in the screen capture but it breaks. The one I converted had 7 files including members.pas and sockios.pas which also doesn't compile.

So there are still some path issues.
the -canzip is from the latest can.zip posted.  The -fixlp is the older one that was 'fixed' by fixlp.

jcdammeyer

  • Full Member
  • ***
  • Posts: 195
  • Embedded System Developer
    • Automation Artisans Inc.
Re: CAN-BUS SocketCAN
« Reply #119 on: October 02, 2021, 02:05:15 am »
Loaded the LinuxCNC MicroSD into the Pi4.
Created fixlp folder and compiled fixlp
ran from AvraCAN
./fixlp/fixlp hlcanreceive.lpi
which created the new .lpi and .lpi.bak
Check with file compare and only the expected changes were there.  As the screen shot shows, the members.pas file is not to be found but there are 7 files there.
Added the PC_CAN and AF_CAN constants and compiled for slcan0.
Then first ran it with slcan0 and saw a real CAN message from the Lawicel CANUSB.
Next recompiled with can0 and saw a real CAN message from the MCP2515 HAT.

No idea why the other Pi Linux system is having trouble.

Next I'll try this on the BeagleBone Black.

 

TinyPortal © 2005-2018